renamed eeprom-files and added migrator
This commit is contained in:
@@ -19,6 +19,7 @@ typedef enum DTCNums_e
|
||||
DTC_NO_BATMNON_FOUND,
|
||||
DTC_BAT_LOW,
|
||||
DTC_BAT_CRITICAL,
|
||||
DTC_EEPROM_MIGRATE_FAILED,
|
||||
DTC_LAST_DTC
|
||||
} DTCNums_t;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
#ifndef _EEPROM_H_
|
||||
#define _EEPROM_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC64
|
||||
#define EEPROM_ENDURANCE 1000000
|
||||
@@ -38,25 +39,36 @@ typedef enum
|
||||
} batteryType_t;
|
||||
|
||||
const char BatteryString[][10]{
|
||||
"Undefined",
|
||||
"LiPo 2S",
|
||||
"LiPo 3S"
|
||||
};
|
||||
"Undefined",
|
||||
"LiPo 2S",
|
||||
"LiPo 3S"};
|
||||
|
||||
const size_t BatteryString_Elements = sizeof(BatteryString) / sizeof(BatteryString[0]);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t EEPROM_Version = 1;
|
||||
batteryType_t batteryType = BATTERY_UNDEFINED;
|
||||
bool active_faction_on_reboot = false;
|
||||
uint32_t checksum = 0;
|
||||
uint8_t EEPROM_Version;
|
||||
batteryType_t batteryType;
|
||||
bool active_faction_on_reboot;
|
||||
char Faction_1_Name[32];
|
||||
char Faction_2_Name[32];
|
||||
char Faction_3_Name[32];
|
||||
uint32_t checksum;
|
||||
} configData_t;
|
||||
|
||||
const configData_t ConfigData_defaults = {
|
||||
0, BATTERY_LIPO_3S, 0
|
||||
2, // EEPROM_Version (incerease this if anything on Layout changes!)
|
||||
BATTERY_LIPO_3S, // batteryType
|
||||
false, // active_faction_on_reboot
|
||||
"FACTION 1", // Faction_1_Name
|
||||
"FACTION 2", // Faction_2_Name
|
||||
"FACTION 3", // Faction_3_Name
|
||||
0 // checksum
|
||||
};
|
||||
|
||||
const uint16_t startofConfigData = 16;
|
||||
const uint16_t startofPersistence = 16 + sizeof(ConfigData) + (sizeof(ConfigData) % 16);
|
||||
|
||||
void InitEEPROM();
|
||||
void EEPROM_Process();
|
||||
void StoreConfig_EEPROM();
|
||||
@@ -72,4 +84,5 @@ uint32_t ConfigSanityCheck(bool autocorrect = false);
|
||||
|
||||
extern configData_t ConfigData;
|
||||
extern persistenceData_t PersistenceData;
|
||||
#endif // _CONFIG_H_
|
||||
|
||||
#endif // _EEPROM_H_
|
@@ -6,7 +6,7 @@
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include "globals.h"
|
||||
#include "config.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
#define OLED_SDA 4
|
||||
#define OLED_SCL 15
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <AsyncJson.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "eeprom.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
|
Reference in New Issue
Block a user