|
RSeries astromech firmware
|
|
Go to the documentation of this file.
33 template<
int bufferSize = 32>
47 #if !defined(ESP32) || (defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 2)
48 Wire.onReceive(i2cEvent);
50 #warning NOTE: I2C receiver will not work. Upgrade to version 2.0.4
64 #if !defined(ESP32) || (defined(ESP_ARDUINO_VERSION_MAJOR) && ESP_ARDUINO_VERSION_MAJOR >= 2)
65 Wire.onReceive(i2cEvent);
67 #warning NOTE: I2C receiver will not work. Upgrade to version 2.0.4
72 void begin(
byte i2caddress = 0x19)
74 Wire.begin(i2caddress);
82 if (fCmdReady && *fCmdString != 0)
84 if (fCmdString[1] == 0 && fCmdString[0] >= 0 && fCmdString[0] <= 9)
88 if (fCallback !=
nullptr)
90 fCallback(fCmdString);
101 char fCmdString[bufferSize];
102 volatile bool fCmdReady =
false;
103 void (*fCallback)(
char*) =
nullptr;
105 void handleEvent(
int howMany)
111 for (
byte i = 0; Wire.available();)
113 char ch = (char)Wire.read();
115 if (i <
sizeof(fCmdString) - 1 && (i != 0 || !isspace(ch)))
117 fCmdString[i++] = (ch !=
'\r') ? ch :
'\n';
125 static void i2cEvent(
int howMany)
127 (*myself())->handleEvent(howMany);
136 static constexpr
bool sCreated =
false;
static void process(char *cmd)
Calls handleCommand() for each created CommandEvent subclass.
Definition: CommandEvent.h:33
I2CReceiverBase(void(*callback)(char *)=nullptr)
Constructor.
Definition: I2CReceiver.h:43
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
void begin(byte i2caddress=0x19)
Definition: I2CReceiver.h:72
I2CReceiverBase(byte i2caddress, void(*callback)(char *)=nullptr)
Constructor.
Definition: I2CReceiver.h:60
virtual void animate() override
Dispatch any received i2c event to CommandEvent.
Definition: I2CReceiver.h:80
Base template of automatic forwarder from i2c to CommandEvent.
Definition: I2CReceiver.h:34
I2CReceiverBase I2CReceiver
Definition: I2CReceiver.h:155
#define UNUSED_ARG(arg)
Definition: ReelTwo.h:25