Mercurial > public > ostc4
diff Small_CPU/Src/batteryGasGauge.c @ 437:6c824f902934
Merged in Ideenmodellierer/ostc4/Improve_BatteryGasGauge (pull request #40)
Improve BatteryGasGauge
author | heinrichsweikamp <bitbucket@heinrichsweikamp.com> |
---|---|
date | Mon, 24 Feb 2020 07:58:37 +0000 |
parents | aa286a4926c2 |
children | 1b995079c045 |
line wrap: on
line diff
--- a/Small_CPU/Src/batteryGasGauge.c Tue Feb 18 12:41:45 2020 +0100 +++ b/Small_CPU/Src/batteryGasGauge.c Mon Feb 24 07:58:37 2020 +0000 @@ -64,7 +64,7 @@ buffer[0] = 0x01; // F8 = 11111000: - // Vbat 3.0V (11) + // ADC auto mode (11) // Prescale M = 128 (111) // AL/CC pin disable (0) // Shutdown (0) @@ -127,8 +127,8 @@ // max/full: 0.085 mAh * 1 * 65535 = 5570 mAh battery_f_charge_percent_local = (float)(bufferReceive[2] * 256); battery_f_charge_percent_local += (float)(bufferReceive[3]); - battery_f_charge_percent_local -= BGG_BATTERY_OFFSET; - battery_f_charge_percent_local /= BGG_BATTERY_DIVIDER; + battery_f_charge_percent_local -= BGG_BATTERY_OFFSET; /* Because of the prescalar 128 the counter assumes a max value of 5570mAh => normalize to 3350mAh*/ + battery_f_charge_percent_local /= BGG_BATTERY_DIVIDER; /* transform to percentage */ if(battery_f_charge_percent_local < 0) battery_f_charge_percent_local = 0;