From 3e571a515dde749a5d2cf96ef4beec7363189e09 Mon Sep 17 00:00:00 2001 From: Marcel Peterkau Date: Fri, 31 May 2024 13:58:36 +0200 Subject: [PATCH] some Init-Stuff optimized and made Log nicer --- Software/include/eeprom.h | 2 +- Software/src/eeprom.cpp | 5 +++-- Software/src/main.cpp | 18 +++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Software/include/eeprom.h b/Software/include/eeprom.h index 72dda52..4314727 100644 --- a/Software/include/eeprom.h +++ b/Software/include/eeprom.h @@ -90,7 +90,7 @@ const configData_t ConfigData_defaults = { 0 // checksum }; -void InitEEPROM(); +boolean InitEEPROM(); void EEPROM_Process(); void StoreConfig_EEPROM(); void GetConfig_EEPROM(); diff --git a/Software/src/eeprom.cpp b/Software/src/eeprom.cpp index f23ee0c..b094c65 100644 --- a/Software/src/eeprom.cpp +++ b/Software/src/eeprom.cpp @@ -35,12 +35,13 @@ boolean checkEEPROMavailable(); * * This function initializes the EEPROM using the I2C_eeprom instance and checks if it's available. */ -void InitEEPROM() +boolean InitEEPROM() { + Wire.begin(); ConfigData = ConfigData_defaults; PersistenceData = {0}; ee.begin(); - checkEEPROMavailable(); + return checkEEPROMavailable(); } /** diff --git a/Software/src/main.cpp b/Software/src/main.cpp index e02ddce..95ccb50 100644 --- a/Software/src/main.cpp +++ b/Software/src/main.cpp @@ -110,13 +110,19 @@ void setup() Serial.print("\n\n-------------------START-------------------\n"); Serial.print(globals.DeviceNameId); - Serial.print("\nby Hiabuto Defense\n"); + Serial.print("\nby Hiabuto Defense\n\n"); // Initialize EEPROM, load configuration, and persistence data from EEPROM - InitEEPROM(); - GetConfig_EEPROM(); - GetPersistence_EEPROM(); - Serial.print("\nEE-Init done"); + if (InitEEPROM()) + { + GetConfig_EEPROM(); + GetPersistence_EEPROM(); + Serial.printf("Initialized EEPROM at Address 0x%02X\n", I2C_EE_ADDRESS); + } + else + { + Serial.print("EEPROM not Initialized\n"); + } if (i2c_io.begin()) { @@ -209,7 +215,6 @@ void setup() // Start cyclic EEPROM updates for Persistence Data Structure (PDS) tmrEEPROMCyclicPDS.start(); - Serial.print("\nSetup Done\n"); disp_FAC_1.init(); disp_FAC_1.setBrightness(5); @@ -218,7 +223,6 @@ void setup() disp_FAC_3.init(); disp_FAC_3.setBrightness(5); - tmrEEPROMCyclicPDS.start(); tmrFactionTicker.start(); tmrInputGetter.start();