Skip to content

Commit

Permalink
send messages from inputs only after the config was read (#344)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian M <[email protected]>
  • Loading branch information
elral and DocMoebiuz authored Jan 6, 2025
1 parent c55adee commit 0d1ea68
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ uint16_t configLengthEEPROM = 0;
boolean configActivated = false;
uint16_t pNameBuffer = 0; // pointer for nameBuffer during reading of config
const uint16_t configLengthFlash = sizeof(CustomDeviceConfig);
bool boardReady = false;

void resetConfig();
void readConfig();
Expand All @@ -94,6 +95,11 @@ bool configStoredInEEPROM()
return configLengthEEPROM > 0;
}

bool getBoardReady()
{
return boardReady;
}

// ************************************************************
// configBuffer handling
// ************************************************************
Expand Down Expand Up @@ -605,6 +611,7 @@ void OnGetConfig()
}
}
cmdMessenger.sendCmdEnd();
boardReady = true;
}

void OnGetInfo()
Expand Down
2 changes: 2 additions & 0 deletions src/MF_Analog/Analog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace Analog

void handlerOnAnalogChange(int value, const char *name)
{
if (!getBoardReady())
return;
cmdMessenger.sendCmdStart(kAnalogChange);
cmdMessenger.sendCmdArg(name);
cmdMessenger.sendCmdArg(value);
Expand Down
2 changes: 2 additions & 0 deletions src/MF_Button/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace Button

void handlerButtonOnChange(uint8_t eventId, const char *name)
{
if (!getBoardReady())
return;
cmdMessenger.sendCmdStart(kButtonChange);
cmdMessenger.sendCmdArg(name);
cmdMessenger.sendCmdArg(eventId);
Expand Down
2 changes: 2 additions & 0 deletions src/MF_DigInMux/DigInMux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace DigInMux

void handlerOnDigInMux(uint8_t eventId, uint8_t channel, const char *name)
{
if (!getBoardReady())
return;
cmdMessenger.sendCmdStart(kDigInMuxChange);
cmdMessenger.sendCmdArg(name);
cmdMessenger.sendCmdArg(channel);
Expand Down
2 changes: 2 additions & 0 deletions src/MF_Encoder/Encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace Encoder

void handlerOnEncoder(uint8_t eventId, const char *name)
{
if (!getBoardReady())
return;
cmdMessenger.sendCmdStart(kEncoderChange);
cmdMessenger.sendCmdArg(name);
cmdMessenger.sendCmdArg(eventId);
Expand Down
2 changes: 2 additions & 0 deletions src/MF_InputShifter/InputShifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace InputShifter

void handlerInputShifterOnChange(uint8_t eventId, uint8_t pin, const char *name)
{
if (!getBoardReady())
return;
cmdMessenger.sendCmdStart(kInputShifterChange);
cmdMessenger.sendCmdArg(name);
cmdMessenger.sendCmdArg(pin);
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ void OnGetInfo(void);
void OnGenNewSerial(void);
void OnSetName(void);
void restoreName(void);
bool getBoardReady();

// config.h

0 comments on commit 0d1ea68

Please sign in to comment.