Commanders
Arduino buttons/bus library
SerialCommander.hpp File Reference
#include <Commanders.h>

Go to the source code of this file.

Macros

#define SerialCommander   SerialCommanderClass::GetCurrent()
 
#define SERIAL_COMMANDER(SERIAL_PORT)
 

Detailed Description

This is the most curious commander, because the class itself does not exists until you add the macro SERIAL_COMMANDER to your sketch.

#include "Commanders.h"

SERIAL_COMMANDER(Serial);

and in this case, it has the usual form of a Commander :

class SerialCommanderClass : Commander
{
public:
    inline SerialCommanderClass() : Commander() { }

    inline void begin() { }

    inline unsigned long loop() 
    {
        ...
    }

    static inline SerialCommanderClass &GetCurrent() 
    {
        ...
    }
    void printCommander() { ... }
};    

You should avoid to declare a SERIAL_COMMANDER if not necessary, because the Serial library delivered with the Arduino IDE allocates a lot of memory for each serial channel used. The only variable thing in this macro is the name of the serial channel to use : Serial for a UNO or a NANO, but Serial or Serial1 to 3 on a Mega or a Due. Even a SoftwareSerial (from SoftwareSerial library (https://www.arduino.cc/en/Reference/SoftwareSerial) ) or a AltSoftSerial (from the well named library.. AltSoftSerial (https://github.com/PaulStoffregen/AltSoftSerial) !) can be used.

The syntax of the message to get to throw a new event is given by the class TextInterpreter.

Events thrown:

reason id type data
message received id type data

Definition in file SerialCommander.hpp.

Macro Definition Documentation

#define SERIAL_COMMANDER

Use this macro to define a SerialCommander.

Parameters
SERIAL_PORTname of the serial port. See the file description for more information.

Definition at line 64 of file SerialCommander.hpp.

#define SerialCommander   SerialCommanderClass::GetCurrent()

Defines the normal name of the class.

Definition at line 9 of file SerialCommander.hpp.