Skip to content

Commit

Permalink
fast ack for save settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Feb 2, 2025
1 parent a7d47b2 commit 2215aa5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/displays/LEDMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LedMatrix::LedMatrix() {

HUB75_I2S_CFG mxconfig(PANEL_WIDTH, PANEL_HEIGHT, PANELS_NUMBER, pins);
// Without setting clkphase to false, HD panels seem to flicker.
mxconfig.clkphase = panelClkphase;
mxconfig.clkphase = (panelClkphase == 1);
mxconfig.i2sspeed =
panelI2sspeed == 20
? HUB75_I2S_CFG::clk_speed::HZ_20M
Expand Down
20 changes: 12 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ void DoRestart(int sec) {
WiFi.disconnect(true);
}
display->DisplayText("Restart", 0, 0, 255, 0, 0);
sleep(sec);
vTaskDelay(pdMS_TO_TICKS(sec * 1000));
display->ClearScreen();
delay(20);
ESP.restart();
}

void Restart() { DoRestart(1); }
void Restart() { DoRestart(2); }

void RestartAfterError() { DoRestart(30); }

Expand Down Expand Up @@ -966,8 +966,13 @@ static uint8_t IRAM_ATTR HandleData(uint8_t *pData, size_t len) {
return 1;
}

case 30: // save settings
case 30: // save settings 0x1e
{
if (!wifiActive) {
Serial.write(CtrlChars, N_ACK_CHARS);
Serial.flush();
}
display->DisplayText("Saving settings ...", 0, 0, 255, 0, 0);
SaveLum();
SaveDebug();
SaveTransport();
Expand All @@ -980,13 +985,11 @@ static uint8_t IRAM_ATTR HandleData(uint8_t *pData, size_t len) {
#ifdef ZEDMD_HD_HALF
SaveYOffset();
#endif
headerBytesReceived = 0;
numCtrlCharsFound = 0;
if (wifiActive) break;
return 1;
return 3;
}

case 31: // reset
case 31: // reset 0x1f
{
if (!wifiActive) {
Serial.write(CtrlChars, N_ACK_CHARS);
Expand Down Expand Up @@ -1337,11 +1340,12 @@ void Task_ReadSerial(void *pvParameters) {
while (!Serial);
break;
}
if (3 == result) break; // fast ack has been sent
Serial.write(CtrlChars, N_ACK_CHARS);
Serial.flush();
if (1 == result) break; // Wait for the next FRAME header
noDataMs = 0;
} else {
if (1 == result) break; // Wait for the next FRAME header
if (++noDataMs > 5000) {
transportActive = false;
noDataMs = 0;
Expand Down

0 comments on commit 2215aa5

Please sign in to comment.