KrisKasprzak / EBYTE

Libraries to program and use UART-based EBYTE wireless data transceivers
244 stars 76 forks source link

PrintParameters on Serial2 or Serial3 #37

Closed yetoo closed 3 years ago

yetoo commented 3 years ago

Hi Kris, and thank you very much for the heavy work you've done on this library. As I was doing a project using an STM32 BluePill, I got an E32 on the Serial(1) of the BluePill, and the debug was made on the Serial3. So I made some modifications to your library to make it work. Code still compile for AVR board. if you find it useful, you can add it to Master branch. Note : In my opinion there is a better way to do it, as some STM32 boards have more that 3 Serial ports, but it's a start.

yetoo commented 3 years ago

Code it the .h file

// mehod to print parameters
    void PrintParameters();

#if defined(STM32_CORE_VERSION)
    // mehod to print parameters on serial2
    void PrintParameters2();
    // mehod to print parameters on serial3
    void PrintParameters3();
#endif
yetoo commented 3 years ago

Code it the .cpp file

#if defined(STM32_CORE_VERSION)

/*
method to print parameters on Serial2, this can be called anytime after init(), because init gets parameters
and any method updates the variables
*/
void EBYTE::PrintParameters2() {

    _ParityBit = (_Speed & 0XC0) >> 6;
    _UARTDataRate = (_Speed & 0X38) >> 3;
    _AirDataRate = _Speed & 0X07;

    _OptionTrans = (_Options & 0X80) >> 7;
    _OptionPullup = (_Options & 0X40) >> 6;
    _OptionWakeup = (_Options & 0X38) >> 3;
    _OptionFEC = (_Options & 0X07) >> 2;
    _OptionPower = (_Options & 0X03);

    Serial2.println("----------------------------------------");
    Serial2.print(F("Model no.: "));  Serial2.println(_Model, HEX);
    Serial2.print(F("Version  : "));  Serial2.println(_Version, HEX);
    Serial2.print(F("Features : "));  Serial2.println(_Features, HEX);
    Serial2.println(F(" "));
    Serial2.print(F("Mode (HEX/DEC/BIN): "));  Serial2.print(_Save, HEX); Serial2.print(F("/"));  Serial2.print(_Save, DEC); Serial2.print(F("/"));  Serial2.println(_Save, BIN);
    Serial2.print(F("AddH (HEX/DEC/BIN): "));  Serial2.print(_AddressHigh, HEX); Serial2.print(F("/")); Serial2.print(_AddressHigh, DEC); Serial2.print(F("/"));  Serial2.println(_AddressHigh, BIN);
    Serial2.print(F("AddL (HEX/DEC/BIN): "));  Serial2.print(_AddressLow, HEX); Serial2.print(F("/")); Serial2.print(_AddressLow, DEC); Serial2.print(F("/"));  Serial2.println(_AddressLow, BIN);
    Serial2.print(F("Sped (HEX/DEC/BIN): "));  Serial2.print(_Speed, HEX); Serial2.print(F("/")); Serial2.print(_Speed, DEC); Serial2.print(F("/"));  Serial2.println(_Speed, BIN);
    Serial2.print(F("Chan (HEX/DEC/BIN): "));  Serial2.print(_Channel, HEX); Serial2.print(F("/")); Serial2.print(_Channel, DEC); Serial2.print(F("/"));  Serial2.println(_Channel, BIN);
    Serial2.print(F("Optn (HEX/DEC/BIN): "));  Serial2.print(_Options, HEX); Serial2.print(F("/")); Serial2.print(_Options, DEC); Serial2.print(F("/"));  Serial2.println(_Options, BIN);
    Serial2.print(F("Addr (HEX/DEC/BIN): "));  Serial2.print(GetAddress(), HEX); Serial2.print(F("/")); Serial2.print(GetAddress(), DEC); Serial2.print(F("/"));  Serial2.println(GetAddress(), BIN);
    Serial2.println(F(" "));
    Serial2.print(F("SpeedParityBit (HEX/DEC/BIN)    : "));  Serial2.print(_ParityBit, HEX); Serial2.print(F("/"));  Serial2.print(_ParityBit, DEC); Serial2.print(F("/"));  Serial2.println(_ParityBit, BIN);
    Serial2.print(F("SpeedUARTDataRate (HEX/DEC/BIN) : "));  Serial2.print(_UARTDataRate, HEX); Serial2.print(F("/"));  Serial2.print(_UARTDataRate, DEC); Serial2.print(F("/"));  Serial2.println(_UARTDataRate, BIN);
    Serial2.print(F("SpeedAirDataRate (HEX/DEC/BIN)  : "));  Serial2.print(_AirDataRate, HEX); Serial2.print(F("/"));  Serial2.print(_AirDataRate, DEC); Serial2.print(F("/"));  Serial2.println(_AirDataRate, BIN);
    Serial2.print(F("OptionTrans (HEX/DEC/BIN)       : "));  Serial2.print(_OptionTrans, HEX); Serial2.print(F("/"));  Serial2.print(_OptionTrans, DEC); Serial2.print(F("/"));  Serial2.println(_OptionTrans, BIN);
    Serial2.print(F("OptionPullup (HEX/DEC/BIN)      : "));  Serial2.print(_OptionPullup, HEX); Serial2.print(F("/"));  Serial2.print(_OptionPullup, DEC); Serial2.print(F("/"));  Serial2.println(_OptionPullup, BIN);
    Serial2.print(F("OptionWakeup (HEX/DEC/BIN)      : "));  Serial2.print(_OptionWakeup, HEX); Serial2.print(F("/"));  Serial2.print(_OptionWakeup, DEC); Serial2.print(F("/"));  Serial2.println(_OptionWakeup, BIN);
    Serial2.print(F("OptionFEC (HEX/DEC/BIN)         : "));  Serial2.print(_OptionFEC, HEX); Serial2.print(F("/"));  Serial2.print(_OptionFEC, DEC); Serial2.print(F("/"));  Serial2.println(_OptionFEC, BIN);
    Serial2.print(F("OptionPower (HEX/DEC/BIN)       : "));  Serial2.print(_OptionPower, HEX); Serial2.print(F("/"));  Serial2.print(_OptionPower, DEC); Serial2.print(F("/"));  Serial2.println(_OptionPower, BIN);

    Serial2.println("----------------------------------------");

}

/*
method to print parameters on Serial3, this can be called anytime after init(), because init gets parameters
and any method updates the variables
*/

void EBYTE::PrintParameters3() {

    _ParityBit = (_Speed & 0XC0) >> 6;
    _UARTDataRate = (_Speed & 0X38) >> 3;
    _AirDataRate = _Speed & 0X07;

    _OptionTrans = (_Options & 0X80) >> 7;
    _OptionPullup = (_Options & 0X40) >> 6;
    _OptionWakeup = (_Options & 0X38) >> 3;
    _OptionFEC = (_Options & 0X07) >> 2;
    _OptionPower = (_Options & 0X03);

    Serial3.println("----------------------------------------");
    Serial3.print(F("Model no.: "));  Serial3.println(_Model, HEX);
    Serial3.print(F("Version  : "));  Serial3.println(_Version, HEX);
    Serial3.print(F("Features : "));  Serial3.println(_Features, HEX);
    Serial3.println(F(" "));
    Serial3.print(F("Mode (HEX/DEC/BIN): "));  Serial3.print(_Save, HEX); Serial3.print(F("/"));  Serial3.print(_Save, DEC); Serial3.print(F("/"));  Serial3.println(_Save, BIN);
    Serial3.print(F("AddH (HEX/DEC/BIN): "));  Serial3.print(_AddressHigh, HEX); Serial3.print(F("/")); Serial3.print(_AddressHigh, DEC); Serial3.print(F("/"));  Serial3.println(_AddressHigh, BIN);
    Serial3.print(F("AddL (HEX/DEC/BIN): "));  Serial3.print(_AddressLow, HEX); Serial3.print(F("/")); Serial3.print(_AddressLow, DEC); Serial3.print(F("/"));  Serial3.println(_AddressLow, BIN);
    Serial3.print(F("Sped (HEX/DEC/BIN): "));  Serial3.print(_Speed, HEX); Serial3.print(F("/")); Serial3.print(_Speed, DEC); Serial3.print(F("/"));  Serial3.println(_Speed, BIN);
    Serial3.print(F("Chan (HEX/DEC/BIN): "));  Serial3.print(_Channel, HEX); Serial3.print(F("/")); Serial3.print(_Channel, DEC); Serial3.print(F("/"));  Serial3.println(_Channel, BIN);
    Serial3.print(F("Optn (HEX/DEC/BIN): "));  Serial3.print(_Options, HEX); Serial3.print(F("/")); Serial3.print(_Options, DEC); Serial3.print(F("/"));  Serial3.println(_Options, BIN);
    Serial3.print(F("Addr (HEX/DEC/BIN): "));  Serial3.print(GetAddress(), HEX); Serial3.print(F("/")); Serial3.print(GetAddress(), DEC); Serial3.print(F("/"));  Serial3.println(GetAddress(), BIN);
    Serial3.println(F(" "));
    Serial3.print(F("SpeedParityBit (HEX/DEC/BIN)    : "));  Serial3.print(_ParityBit, HEX); Serial3.print(F("/"));  Serial3.print(_ParityBit, DEC); Serial3.print(F("/"));  Serial3.println(_ParityBit, BIN);
    Serial3.print(F("SpeedUARTDataRate (HEX/DEC/BIN) : "));  Serial3.print(_UARTDataRate, HEX); Serial3.print(F("/"));  Serial3.print(_UARTDataRate, DEC); Serial3.print(F("/"));  Serial3.println(_UARTDataRate, BIN);
    Serial3.print(F("SpeedAirDataRate (HEX/DEC/BIN)  : "));  Serial3.print(_AirDataRate, HEX); Serial3.print(F("/"));  Serial3.print(_AirDataRate, DEC); Serial3.print(F("/"));  Serial3.println(_AirDataRate, BIN);
    Serial3.print(F("OptionTrans (HEX/DEC/BIN)       : "));  Serial3.print(_OptionTrans, HEX); Serial3.print(F("/"));  Serial3.print(_OptionTrans, DEC); Serial3.print(F("/"));  Serial3.println(_OptionTrans, BIN);
    Serial3.print(F("OptionPullup (HEX/DEC/BIN)      : "));  Serial3.print(_OptionPullup, HEX); Serial3.print(F("/"));  Serial3.print(_OptionPullup, DEC); Serial3.print(F("/"));  Serial3.println(_OptionPullup, BIN);
    Serial3.print(F("OptionWakeup (HEX/DEC/BIN)      : "));  Serial3.print(_OptionWakeup, HEX); Serial3.print(F("/"));  Serial3.print(_OptionWakeup, DEC); Serial3.print(F("/"));  Serial3.println(_OptionWakeup, BIN);
    Serial3.print(F("OptionFEC (HEX/DEC/BIN)         : "));  Serial3.print(_OptionFEC, HEX); Serial3.print(F("/"));  Serial3.print(_OptionFEC, DEC); Serial3.print(F("/"));  Serial3.println(_OptionFEC, BIN);
    Serial3.print(F("OptionPower (HEX/DEC/BIN)       : "));  Serial3.print(_OptionPower, HEX); Serial3.print(F("/"));  Serial3.print(_OptionPower, DEC); Serial3.print(F("/"));  Serial3.println(_OptionPower, BIN);

    Serial3.println("----------------------------------------");

}
#endif