diff --git a/Software/ChainLube/src/config.cpp b/Software/ChainLube/src/config.cpp index 85642b2..7d656e7 100644 --- a/Software/ChainLube/src/config.cpp +++ b/Software/ChainLube/src/config.cpp @@ -19,6 +19,7 @@ void InitEEPROM() if (!checkEEPROMavailable()) { globals.systemStatus = sysStat_Error; + MaintainDTC(DTC_NO_EEPROM_FOUND, true); return; } GetConfig_EEPROM(); @@ -131,6 +132,7 @@ void FormatConfig_EEPROM() { LubeConfig_t defaults; LubeConfig = defaults; + LubeConfig.EEPROM_Version = eeVersion; StoreConfig_EEPROM(); } @@ -151,10 +153,10 @@ void MovePersistencePage_EEPROM(boolean reset) PersistenceData.writeCycleCounter = 0; // check if we reached the End of the EEPROM and Startover at the beginning - if ((startofPersistence + eePersistenceMarker + sizeof(PersistenceData)) > ee.getDeviceSize() || reset) - { - eePersistenceMarker = 0; - } + // if ((startofPersistence + eePersistenceMarker + sizeof(PersistenceData)) > ee.getDeviceSize() || reset) + // { + // eePersistenceMarker = 0; + // } ee.updateByte(0, (uint8_t)(eePersistenceMarker >> 8)); ee.updateByte(1, (uint8_t)(eePersistenceMarker & 0xFF)); diff --git a/Software/ChainLube/src/lubeapp.cpp b/Software/ChainLube/src/lubeapp.cpp index 45df04d..dd818ca 100644 --- a/Software/ChainLube/src/lubeapp.cpp +++ b/Software/ChainLube/src/lubeapp.cpp @@ -7,8 +7,18 @@ void RunLubeApp(uint32_t add_milimeters) MaintainDTC(DTC_TANK_EMPTY, (PersistenceData.tankRemain_µl < LubeConfig.amountPerDose_µl)); + static tSystem_Status preserverSysStatusError; + if (getlastDTC(true) < DTC_LAST_DTC) + { + if (globals.systemStatus != sysStat_Error) + preserverSysStatusError = globals.systemStatus; globals.systemStatus = sysStat_Error; + } + else + { + globals.systemStatus = preserverSysStatusError; + } // Add traveled Distance in mm PersistenceData.TravelDistance_highRes_mm += add_milimeters; diff --git a/Software/ChainLube/src/main.cpp b/Software/ChainLube/src/main.cpp index 2cb9c53..255f017 100644 --- a/Software/ChainLube/src/main.cpp +++ b/Software/ChainLube/src/main.cpp @@ -59,6 +59,7 @@ void toggleWiFiAP(boolean shutdown = false); void SystemShutdown(); uint32_t Process_Impulse_WheelSpeed(); void EEPROMCyclicPDS_callback(); +void initGlobals(); #ifdef FEATURE_ENABLE_REMOTE_DEBUG RemoteDebug Debug; @@ -192,6 +193,7 @@ void setup() u8x8.refreshDisplay(); initWebUI(); + initGlobals(); EEPROMCyclicPDSTicker.start(); Serial.println("Setup Done"); } @@ -246,6 +248,14 @@ String IpAddress2String(const IPAddress &ipAddress) String(ipAddress[3]); } +void initGlobals() +{ + globals.purgePulses = 0; + globals.requestEEAction = EE_IDLE; + globals.resumeStatus = sysStat_Normal; + globals.systemStatus = sysStat_Startup; +} + #ifdef FEATURE_ENABLE_REMOTE_DEBUG void processCmdRemoteDebug() { @@ -309,6 +319,7 @@ void RemotDebug_printSystemInfo() : "UNKNOWN")); debugA("OTA-Pass: %s", QUOTE(ADMIN_PASSWORD)); debugA("Git-Revison: %s", GIT_REV); + debugA("Sw-Version: %d.%02d", SW_VERSION_MAJOR, SW_VERSION_MINOR); } void RemoteDebug_dumpConfig()