Mercurial > public > ostc4
diff Small_CPU/Src/scheduler.c @ 668:079bb5b22c06 Betatest
Rework charge cycle:
The charge counter is increasing decreasing also if the real value is maybe not defined (definition is done for example by a completed charging cycle). This caused some problems with invalid displayed charge per centage values. To avoid this the state of an unknow counter value was introduced. The indication is done by converting the counter into a negativ value.
author | Ideenmodellierer |
---|---|
date | Sat, 12 Mar 2022 22:48:45 +0100 |
parents | 1b995079c045 |
children | 52d68cf9994c |
line wrap: on
line diff
--- a/Small_CPU/Src/scheduler.c Sat Mar 12 22:42:56 2022 +0100 +++ b/Small_CPU/Src/scheduler.c Sat Mar 12 22:48:45 2022 +0100 @@ -127,6 +127,8 @@ global.I2C_SystemStatus = HAL_ERROR; // 0x00 would be everything working + global.lifeData.battery_voltage = BATTERY_DEFAULT_VOLTAGE; + global.lifeData.pressure_ambient_bar = INVALID_PREASURE_VALUE; global.lifeData.pressure_surface_bar = INVALID_PREASURE_VALUE; decom_reset_with_1000mbar(&global.lifeData); @@ -1064,6 +1066,7 @@ { global.dataSendToMaster.mode = 0; global.deviceDataSendToMaster.mode = 0; + secondsCount = 0; /* prevent button wake up problem while in sleep_prepare * sleep prepare does I2C_DeInit() @@ -1150,6 +1153,7 @@ clearDecoNow = 0; setButtonsNow = 0; reinitGlobals(); + ReInit_battery_charger_status_pins(); } @@ -1579,8 +1583,17 @@ void copyBatteryData(void) { uint8_t boolBatteryData = !global.dataSendToMaster.boolBatteryData; + global.lifeData.battery_charge = get_charge(); global.dataSendToMaster.data[boolBatteryData].battery_voltage = get_voltage(); - global.dataSendToMaster.data[boolBatteryData].battery_charge= get_charge(); + + if(battery_gas_gauge_isChargeValueValid()) + { + global.dataSendToMaster.data[boolBatteryData].battery_charge= global.lifeData.battery_charge; + } + else + { + global.dataSendToMaster.data[boolBatteryData].battery_charge = global.lifeData.battery_charge * -1.0; /* negate value to show that this is just an assumption */ + } global.dataSendToMaster.boolBatteryData = boolBatteryData; }