You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to change the way the #define statements in config.h are implemented behind the scenes. The existing code literally just builds the various defined parameter values into the code at compile time. At runtime there's nothing that needs to happen... it's already all built into the compiled code.
The proposed feature retains the existing #define statements in config.h, but behind the scenes the runtime code updates values stored in EEPROM for each #define statement that isn't commented out. The goal is that we can change config.h so that every single #define statement is commented out by default... the user only needs to uncomment those values that they want to change.
So basically whenever LiBCM sees that new firmware is installed (see function "wasFirmwareJustUpdated"), the runtime code should update the values in EEPROM corresponding to each #define statement the user has uncommented in config.h.
You can probably just add something like the following for each #define statement in config.h to wasFirmwareJustUpdated():
#ifdef BATTERY_TYPE_5AhG3
EEPROM.update(EEPROM_ADDRESS_BATTERY_TYPE, BATTERY_IS_5AhG3);
#elif defined BATTERY_TYPE_47AhFoMoCo
EEPROM.update(EEPROM_ADDRESS_BATTERY_TYPE, BATTERY_IS_47AhFoMoCo);
#endif
After making the above changes, you'd of course need to change all the existing #ifdef commands that reference config.h #define statements to read the value from EEPROM during runtime. Reading from EEPROM is slower than RAM, but is probably fast enough... I already read from EEPROM every single loop to determine if the firmware is expired. You can read from EEPROM infinity times (i.e. read lifetime count is infinite).
The primary objective here is that the user no longer has to modify config.h each time they load the firmware... they only need to uncomment the specific config.h #define parameters they want to change... if they leave everything commented out, then LiBCM just uses the latest values stored in EEPROM.
Runtime code should certainly verify a valid hardware configuration exists... similar to the various #error preprocessor checks that exist now. Basically all #error checks will need to be rewritten to occur at runtime (inside the wasFirmwareJustUpdated function).
The text was updated successfully, but these errors were encountered:
I'd like to change the way the #define statements in config.h are implemented behind the scenes. The existing code literally just builds the various defined parameter values into the code at compile time. At runtime there's nothing that needs to happen... it's already all built into the compiled code.
The proposed feature retains the existing #define statements in config.h, but behind the scenes the runtime code updates values stored in EEPROM for each #define statement that isn't commented out. The goal is that we can change config.h so that every single #define statement is commented out by default... the user only needs to uncomment those values that they want to change.
So basically whenever LiBCM sees that new firmware is installed (see function "wasFirmwareJustUpdated"), the runtime code should update the values in EEPROM corresponding to each #define statement the user has uncommented in config.h.
You can probably just add something like the following for each #define statement in config.h to wasFirmwareJustUpdated():
#ifdef BATTERY_TYPE_5AhG3
EEPROM.update(EEPROM_ADDRESS_BATTERY_TYPE, BATTERY_IS_5AhG3);
#elif defined BATTERY_TYPE_47AhFoMoCo
EEPROM.update(EEPROM_ADDRESS_BATTERY_TYPE, BATTERY_IS_47AhFoMoCo);
#endif
After making the above changes, you'd of course need to change all the existing #ifdef commands that reference config.h #define statements to read the value from EEPROM during runtime. Reading from EEPROM is slower than RAM, but is probably fast enough... I already read from EEPROM every single loop to determine if the firmware is expired. You can read from EEPROM infinity times (i.e. read lifetime count is infinite).
The primary objective here is that the user no longer has to modify config.h each time they load the firmware... they only need to uncomment the specific config.h #define parameters they want to change... if they leave everything commented out, then LiBCM just uses the latest values stored in EEPROM.
Runtime code should certainly verify a valid hardware configuration exists... similar to the various #error preprocessor checks that exist now. Basically all #error checks will need to be rewritten to occur at runtime (inside the wasFirmwareJustUpdated function).
The text was updated successfully, but these errors were encountered: