void error(String message) { if(self.isInState(Start)) { sd.initErrorPrint(&terminal); } else { sd.errorPrint(&terminal); } terminal.flush(); errorMessage = message; self.transitionTo(Error); }
void renderError() { Display.setTextColor(RED, BLACK); /***** Error Message *****/ Display.setTextSize(1); Display.setCursor(1, 55); Display.println(errorMessage); if(self.isInState(Start)) { sd.initErrorPrint(&Display); } else { sd.errorPrint(&Display); } }
void render() { uint32_t start = millis(); if(clear) { clear = false; Display.fillScreen(BLACK); } if(true == self.isInState(Error)) { renderError(); } else { renderClock(); } renderStatus(); frameTime = millis() - start; }
void renderStatus() { /***** RSSI Indicator *****/ drawIcon(1, 1, 12, abs(WiFi.RSSI()), YELLOW, WHITE); Display.setTextColor(YELLOW, BLACK); /***** SSID *****/ Display.setTextSize(1); Display.setCursor(18, 6); Display.print(WiFi.SSID()); /***** Snooze Indicator *****/ Display.setCursor(120, 6); if(true == self.isInState(Snuze)) { Display.print('Z'); } else { Display.print(' '); } }
void computeKeypadInput(char key) { static uint8_t index = 0; static time_t modifiedTime; if (fsm.isInState(_waitState)) { switch (key) { case '#': lcd.clear(); fsm.transitionTo(_menuState); break; } } if (fsm.isInState(_menuState)) { switch (key) { case '#': lcd.clear(); fsm.transitionTo(_waitState); break; case '*': lcd.clear(); // We have to call an empty state or the menuState function // will not be called fsm.immediateTransitionTo(_emptyState); fsm.transitionTo(_menuState); break; case '1': lcd.clear(); fsm.transitionTo(_changeHourState); break; case '2': lcd.clear(); fsm.transitionTo(_changeStartLedState); break; case '3': lcd.clear(); fsm.transitionTo(_changeStopLedState); break; } } if (fsm.isInState(_changeHourState) or fsm.isInState(_changeStartLedState) or fsm.isInState(_changeStopLedState) or fsm.isInState(_changeFadeInState) or fsm.isInState(_changeFadeOutState)) { switch (key) { case '*': if (index != 6) { break; } index = 0; lcd.clear(); if (fsm.isInState(_changeHourState)) { RTC.set(modifiedTime); setSyncProvider(RTC.get); fsm.transitionTo(_waitState); } else if (fsm.isInState(_changeStartLedState)) { led.setStartTime(modifiedTime); led.saveEepromDatas(); fsm.transitionTo(_changeFadeInState); } else if (fsm.isInState(_changeStopLedState)) { led.setStopTime(modifiedTime); led.saveEepromDatas(); fsm.transitionTo(_changeFadeOutState); } else if (fsm.isInState(_changeFadeInState)) { led.setFadeInTime(modifiedTime); led.saveEepromDatas(); fsm.transitionTo(_waitState); } else if (fsm.isInState(_changeFadeOutState)) { led.setFadeOutTime(modifiedTime); led.saveEepromDatas(); fsm.transitionTo(_waitState); } break; case '#': index = 0; lcd.clear(); fsm.transitionTo(_waitState); break; default: modifiedTime = computeUserInput(index, atoi(&key)); index++; break; } } }