Mercurial > public > ostc4
diff Small_CPU/Src/batteryGasGauge.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 |
line wrap: on
line diff
--- a/Small_CPU/Src/batteryGasGauge.c Sat Mar 12 22:42:56 2022 +0100 +++ b/Small_CPU/Src/batteryGasGauge.c Sat Mar 12 22:48:45 2022 +0100 @@ -30,6 +30,8 @@ static float battery_f_voltage = BATTERY_DEFAULT_VOLTAGE; /* max assumed voltage */ static float battery_f_charge_percent = 0; +static uint8_t chargeValueKnown = 0; /* indicator if the charge of the battery is known (for example after a full charge cycle) */ + #define BGG_BATTERY_OFFSET (26123) //; 65536-(3,35Ah/0,085mAh) #define BGG_BATTERY_DIVIDER (394) //; 3,35Ah/0,085mAh/100 [%] @@ -66,7 +68,7 @@ // F8 = 11111000: // ADC auto mode (11) // Prescale M = 128 (111) - // AL/CC pin disable (0) + // AL/CC pin disable (00) // Shutdown (0) buffer[1] = 0xF8; I2C_Master_Transmit(DEVICE_BATTERYGAUGE, buffer, 2); @@ -152,6 +154,7 @@ bufferSend[2] = 0xFF; I2C_Master_Transmit( DEVICE_BATTERYGAUGE, bufferSend, 3); init_battery_gas_gauge(); + chargeValueKnown = 1; } @@ -177,7 +180,17 @@ bufferSend[2] = (uint8_t)(mAhSend & 0xFF); I2C_Master_Transmit( DEVICE_BATTERYGAUGE, bufferSend, 3); init_battery_gas_gauge(); + chargeValueKnown = 1; } +uint8_t battery_gas_gauge_isChargeValueValid(void) +{ + return chargeValueKnown; +} + +void battery_gas_gauge_setChargeValueValid(void) +{ + chargeValueKnown = 1; +} /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/