| 
						
					 | 
					 | 
					@@ -75,12 +75,12 @@ void EEPROM_Process()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					void StoreConfig_EEPROM()
 | 
					 | 
					 | 
					 | 
					void StoreConfig_EEPROM()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					{
 | 
					 | 
					 | 
					 | 
					{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  ConfigData.checksum = 0;
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  ConfigData.checksum = Checksum_EEPROM((uint8_t *)&ConfigData, sizeof(ConfigData));
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  if (eeAvailable == false)
 | 
					 | 
					 | 
					 | 
					  if (eeAvailable == false)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return;
 | 
					 | 
					 | 
					 | 
					    return;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  ConfigData.checksum = 0;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  ConfigData.checksum = Checksum_EEPROM((uint8_t *)&ConfigData, sizeof(ConfigData));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  ee.updateBlock(startofConfigData, (uint8_t *)&ConfigData, sizeof(ConfigData));
 | 
					 | 
					 | 
					 | 
					  ee.updateBlock(startofConfigData, (uint8_t *)&ConfigData, sizeof(ConfigData));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -111,9 +111,6 @@ void GetConfig_EEPROM()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					void StorePersistence_EEPROM()
 | 
					 | 
					 | 
					 | 
					void StorePersistence_EEPROM()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					{
 | 
					 | 
					 | 
					 | 
					{
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  PersistenceData.checksum = 0;
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  PersistenceData.checksum = Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData));
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  if (eeAvailable == false)
 | 
					 | 
					 | 
					 | 
					  if (eeAvailable == false)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return;
 | 
					 | 
					 | 
					 | 
					    return;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -122,6 +119,9 @@ void StorePersistence_EEPROM()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  else
 | 
					 | 
					 | 
					 | 
					  else
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    PersistenceData.writeCycleCounter++;
 | 
					 | 
					 | 
					 | 
					    PersistenceData.writeCycleCounter++;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  PersistenceData.checksum = 0;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  PersistenceData.checksum = Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  ee.updateBlock(globals.eePersistanceAdress, (uint8_t *)&PersistenceData, sizeof(PersistenceData));
 | 
					 | 
					 | 
					 | 
					  ee.updateBlock(globals.eePersistanceAdress, (uint8_t *)&PersistenceData, sizeof(PersistenceData));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -162,6 +162,7 @@ void FormatConfig_EEPROM()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  Serial.println("Formatting Config-Partition");
 | 
					 | 
					 | 
					 | 
					  Serial.println("Formatting Config-Partition");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  ConfigData = ConfigData_defaults;
 | 
					 | 
					 | 
					 | 
					  ConfigData = ConfigData_defaults;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  StoreConfig_EEPROM();
 | 
					 | 
					 | 
					 | 
					  StoreConfig_EEPROM();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  GetConfig_EEPROM();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					void FormatPersistence_EEPROM()
 | 
					 | 
					 | 
					 | 
					void FormatPersistence_EEPROM()
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -170,8 +171,9 @@ void FormatPersistence_EEPROM()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return;
 | 
					 | 
					 | 
					 | 
					    return;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  Serial.println("Formatting Persistance-Partition");
 | 
					 | 
					 | 
					 | 
					  Serial.println("Formatting Persistance-Partition");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  memset(&PersistenceData, 0, sizeof(PersistenceData));
 | 
					 | 
					 | 
					 | 
					  PersistenceData = {0};
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  StorePersistence_EEPROM();
 | 
					 | 
					 | 
					 | 
					  StorePersistence_EEPROM();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  GetPersistence_EEPROM();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					void MovePersistencePage_EEPROM(boolean reset)
 | 
					 | 
					 | 
					 | 
					void MovePersistencePage_EEPROM(boolean reset)
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -277,7 +279,7 @@ bool ValidateEEPROM_Version()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  if (EEPROMVersionOnChip < ConfigData_defaults.EEPROM_Version)
 | 
					 | 
					 | 
					 | 
					  if (EEPROMVersionOnChip < ConfigData_defaults.EEPROM_Version)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  {
 | 
					 | 
					 | 
					 | 
					  {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    Serial.printf("EEPROM Image Version is %d, but %d expected - trying to migrate\n");
 | 
					 | 
					 | 
					 | 
					    Serial.printf("EEPROM Image Version is %d, but %d expected - trying to migrate\n", EEPROMVersionOnChip, ConfigData_defaults.EEPROM_Version);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (!MigrateEEPROM(EEPROMVersionOnChip))
 | 
					 | 
					 | 
					 | 
					    if (!MigrateEEPROM(EEPROMVersionOnChip))
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    {
 | 
					 | 
					 | 
					 | 
					    {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      Serial.print("Error\n");
 | 
					 | 
					 | 
					 | 
					      Serial.print("Error\n");
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					@@ -322,26 +324,28 @@ bool MigrateEEPROM(uint8_t fromVersion)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    //  } persistenceData_t;
 | 
					 | 
					 | 
					 | 
					    //  } persistenceData_t;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  case 1:
 | 
					 | 
					 | 
					 | 
					  case 1:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    // Migrate Persistance-Data
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    ee.readBlock(0, (uint8_t *)&persistanceMarker_onChip, sizeof(uint16_t));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (persistanceMarker_onChip < startofPersistence)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 0, (uint8_t *)&PersistenceData.writeCycleCounter, 4);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 4, (uint8_t *)&PersistenceData.faction_1_timer, 4);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 8, (uint8_t *)&PersistenceData.faction_2_timer, 4);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 12, (uint8_t *)&PersistenceData.faction_3_timer, 4);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 16, (uint8_t *)&PersistenceData.activeFaction, 4);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 20, (uint8_t *)&PersistenceData.checksum, 4);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      MovePersistencePage_EEPROM(true);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      StorePersistence_EEPROM();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // Migrate Config-Data and set defaults for Values which doesn't exists in this earlier Version
 | 
					 | 
					 | 
					 | 
					    // Migrate Config-Data and set defaults for Values which doesn't exists in this earlier Version
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ConfigData.EEPROM_Version = ConfigData_defaults.EEPROM_Version;
 | 
					 | 
					 | 
					 | 
					    ConfigData.EEPROM_Version = ConfigData_defaults.EEPROM_Version;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    strncpy(ConfigData.Faction_1_Name, ConfigData_defaults.Faction_1_Name, sizeof(ConfigData.Faction_1_Name));
 | 
					 | 
					 | 
					 | 
					    strncpy(ConfigData.Faction_1_Name, ConfigData_defaults.Faction_1_Name, sizeof(ConfigData.Faction_1_Name));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    strncpy(ConfigData.Faction_2_Name, ConfigData_defaults.Faction_2_Name, sizeof(ConfigData.Faction_2_Name));
 | 
					 | 
					 | 
					 | 
					    strncpy(ConfigData.Faction_2_Name, ConfigData_defaults.Faction_2_Name, sizeof(ConfigData.Faction_2_Name));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    strncpy(ConfigData.Faction_3_Name, ConfigData_defaults.Faction_3_Name, sizeof(ConfigData.Faction_3_Name));
 | 
					 | 
					 | 
					 | 
					    strncpy(ConfigData.Faction_3_Name, ConfigData_defaults.Faction_3_Name, sizeof(ConfigData.Faction_3_Name));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ee.readBlock(17, (uint8_t *)&ConfigData.batteryType, 4);
 | 
					 | 
					 | 
					 | 
					    ee.readBlock(17, (uint8_t *)&ConfigData.batteryType, 4);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ee.readBlock(21, (uint8_t *)ConfigData.active_faction_on_reboot, 1);
 | 
					 | 
					 | 
					 | 
					    ee.readBlock(21, (uint8_t *)&ConfigData.active_faction_on_reboot, 1);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					    StoreConfig_EEPROM();
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // Migrate Persistance-Data
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ee.readBlock(0, (uint8_t *)&persistanceMarker_onChip, sizeof(uint16_t));
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (persistanceMarker_onChip < startofPersistence)
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    {
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 0, (uint8_t *)PersistenceData.writeCycleCounter, 4);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 4, (uint8_t *)PersistenceData.faction_1_timer, 4);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 8, (uint8_t *)PersistenceData.faction_2_timer, 4);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 12, (uint8_t *)PersistenceData.faction_3_timer, 4);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 16, (uint8_t *)PersistenceData.activeFaction, 4);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ee.readBlock(persistanceMarker_onChip + 20, (uint8_t *)PersistenceData.checksum, 4);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      MovePersistencePage_EEPROM(true);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return true;
 | 
					 | 
					 | 
					 | 
					    return true;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    break;
 | 
					 | 
					 | 
					 | 
					    break;
 | 
				
			
			
		
	
	
		
		
			
				
					
					| 
						
					 | 
					 | 
					 
 |