23static const size_t MAX_ID = (
24#define X(type, ID) max(ID,
33static uint8_t variables[MAX_ID + 1][8];
39void updateVariable(
size_t varID,
const uint8_t *dataArr) {
43 memcpy(variables[ID], dataArr, 8); \
44 Log.p("serial_var_response", "Data received for varID:", ID); \
45 Log.i(LOG_ID, "Int value:", *(int *)(variables + ID)); \
46 Log.i(LOG_ID, "Approximate Float value:", (int)*(float *)(variables + ID)); \
51 Log.
i(LOG_ID,
"Invalid varID:", varID);
56 static elapsedMillis timeElapsed;
57 static uint8_t buffer[9];
62 Log.
i(LOG_ID,
"Waiting for data");
65 if (Serial.available()) {
66 buffer[++c] = Serial.read();
67 }
else if (timeElapsed > 1500) {
68 Log.
w(LOG_ID,
"Timeout waiting for data");
73 uint8_t varID = buffer[0];
75 updateVariable(varID, buffer + 1);
Configure global build properties.
const char * LOG_TAG
Type definition of logging tags This typedef is necessary to allow for easier manipulation of code by...
Logging::Log_t Log
The global logging object.
Compilation of various helpful preprocessor macros.
#define SERIALVARS
X Macro of all the serial vars and their data type.
SerialVar is used for variables that can be modified over usb serial while still being used during ru...
void receiveSerialVar()
Receive a variable over serial.
uint8_t * getVariable(size_t ID)
Get the Serial Variable for a given ID.
void w(LOG_TAG TAG, LOG_MSG message)
Log a string using a warning tag.
void i(LOG_TAG TAG, LOG_MSG message)
Log a string using an info tag.