comparison 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
comparison
equal deleted inserted replaced
667:8c3d495afc69 668:079bb5b22c06
125 global.ButtonPICdata[2] = 0xFF; 125 global.ButtonPICdata[2] = 0xFF;
126 global.ButtonPICdata[3] = 0xFF; 126 global.ButtonPICdata[3] = 0xFF;
127 127
128 global.I2C_SystemStatus = HAL_ERROR; // 0x00 would be everything working 128 global.I2C_SystemStatus = HAL_ERROR; // 0x00 would be everything working
129 129
130 global.lifeData.battery_voltage = BATTERY_DEFAULT_VOLTAGE;
131
130 global.lifeData.pressure_ambient_bar = INVALID_PREASURE_VALUE; 132 global.lifeData.pressure_ambient_bar = INVALID_PREASURE_VALUE;
131 global.lifeData.pressure_surface_bar = INVALID_PREASURE_VALUE; 133 global.lifeData.pressure_surface_bar = INVALID_PREASURE_VALUE;
132 decom_reset_with_1000mbar(&global.lifeData); 134 decom_reset_with_1000mbar(&global.lifeData);
133 135
134 global.demo_mode = 0; 136 global.demo_mode = 0;
1062 1064
1063 void scheduleSleepMode(void) 1065 void scheduleSleepMode(void)
1064 { 1066 {
1065 global.dataSendToMaster.mode = 0; 1067 global.dataSendToMaster.mode = 0;
1066 global.deviceDataSendToMaster.mode = 0; 1068 global.deviceDataSendToMaster.mode = 0;
1069 secondsCount = 0;
1067 1070
1068 /* prevent button wake up problem while in sleep_prepare 1071 /* prevent button wake up problem while in sleep_prepare
1069 * sleep prepare does I2C_DeInit() 1072 * sleep prepare does I2C_DeInit()
1070 */ 1073 */
1071 if(global.mode != MODE_SLEEP) 1074 if(global.mode != MODE_SLEEP)
1148 /* new section for system after Standby */ 1151 /* new section for system after Standby */
1149 scheduleUpdateLifeData(-1); 1152 scheduleUpdateLifeData(-1);
1150 clearDecoNow = 0; 1153 clearDecoNow = 0;
1151 setButtonsNow = 0; 1154 setButtonsNow = 0;
1152 reinitGlobals(); 1155 reinitGlobals();
1156 ReInit_battery_charger_status_pins();
1153 } 1157 }
1154 1158
1155 1159
1156 1160
1157 /* Private functions ---------------------------------------------------------*/ 1161 /* Private functions ---------------------------------------------------------*/
1577 1581
1578 //Supports threadsave copying!!! 1582 //Supports threadsave copying!!!
1579 void copyBatteryData(void) 1583 void copyBatteryData(void)
1580 { 1584 {
1581 uint8_t boolBatteryData = !global.dataSendToMaster.boolBatteryData; 1585 uint8_t boolBatteryData = !global.dataSendToMaster.boolBatteryData;
1586 global.lifeData.battery_charge = get_charge();
1582 global.dataSendToMaster.data[boolBatteryData].battery_voltage = get_voltage(); 1587 global.dataSendToMaster.data[boolBatteryData].battery_voltage = get_voltage();
1583 global.dataSendToMaster.data[boolBatteryData].battery_charge= get_charge(); 1588
1589 if(battery_gas_gauge_isChargeValueValid())
1590 {
1591 global.dataSendToMaster.data[boolBatteryData].battery_charge= global.lifeData.battery_charge;
1592 }
1593 else
1594 {
1595 global.dataSendToMaster.data[boolBatteryData].battery_charge = global.lifeData.battery_charge * -1.0; /* negate value to show that this is just an assumption */
1596 }
1584 global.dataSendToMaster.boolBatteryData = boolBatteryData; 1597 global.dataSendToMaster.boolBatteryData = boolBatteryData;
1585 } 1598 }
1586 1599
1587 1600
1588 //Supports threadsave copying!!! 1601 //Supports threadsave copying!!!