changeset 674:8ebf7a27c189 Betatest

Zusammenf?hren
author heinrichsweikamp
date Wed, 30 Mar 2022 18:01:29 +0200
parents c00a80f26641 (diff) d7c5d592076b (current diff)
children 3c4a3d78ff2b
files
diffstat 14 files changed, 319 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/Common/Inc/data_central.h	Wed Mar 30 18:00:21 2022 +0200
+++ b/Common/Inc/data_central.h	Wed Mar 30 18:01:29 2022 +0200
@@ -31,6 +31,7 @@
 
 #include "settings.h"
 #include "stm32f4xx_hal.h"
+#include "configuration.h"
 
 #define BUEHLMANN_STRUCT_MAX_GASES 11
 #define BUEHLMANN_STRUCT_MAX_ASCENDRATES 3
--- a/Discovery/Inc/tHome.h	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Inc/tHome.h	Wed Mar 30 18:01:29 2022 +0200
@@ -71,6 +71,7 @@
 		CVIEW_Hello,
 		CVIEW_CompassDebug,
 		CVIEW_SummaryOfLeftCorner,
+		CVIEW_Charger,
 		CVIEW_END,
 		CVIEW_T3_Decostop,
 		CVIEW_T3_TTS,
--- a/Discovery/Inc/text_multilanguage.h	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Inc/text_multilanguage.h	Wed Mar 30 18:01:29 2022 +0200
@@ -71,10 +71,11 @@
 		TXT_Temperature,
 		TXT_FutureTTS,
 		TXT_Gas,
-		TXT_Time,
+		TXT_ChargeHour,
 		TXT_Date,
 		TXT_Format,
 		TXT_Warning,
+		TXT_Charging,
 		TXT_o2Sensors,
 		TXT_Brightness,
 		TXT_Cave,
--- a/Discovery/Src/base.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Src/base.c	Wed Mar 30 18:01:29 2022 +0200
@@ -1153,6 +1153,13 @@
         /* important levelAmbient 300 - 1200 */
         levelAmbient = 10 * pStateReal->lifeData.ambient_light_level;
 
+        if((pStateReal->chargeStatus == CHARGER_running) || (pStateReal->chargeStatus == CHARGER_lostConnection))
+        {
+        	levelMax = 1000;
+        	levelMin = 500;
+        }
+        else
+        {
         switch(	pSettings->brightness + blBoost)
         {
         case 0: /* Cave */
@@ -1194,6 +1201,7 @@
 //			wasLostConnection = 0;
         }
 //	}
+        }
 
     if(levelAmbient > levelActual)
         levelActual += levelUpStep_100ms;
@@ -1205,8 +1213,9 @@
         levelActual = levelMax;
     else
     if(levelActual < levelMin)
+    {
         levelActual = levelMin;
-
+    }
 //	sConfig.Pulse = levelActual / 20;
     sConfig.Pulse = (levelMin + ((levelMax - levelMin)/2)) / 20; // added 170306
 
@@ -1214,8 +1223,8 @@
     if(sConfig.Pulse > 600)
         sConfig.Pulse = 600;
     else
-    if(sConfig.Pulse < 100)
-        sConfig.Pulse = 100;
+    if(sConfig.Pulse < 25)
+        sConfig.Pulse = 25;
 
     HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL);
     HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL);
@@ -1718,17 +1727,30 @@
 			switch(status.base)
 			{
 			case BaseHome:
-				// added hw 161027
-				if(!(stateRealGetPointer()->warnings.lowBattery) && (stateRealGetPointer()->lifeData.battery_charge > 9))
+				/* The RTE will mark a charge value as suspect after startup. Main know the update condition and may confirm that the value is most likely valid */
+	//			if(!(stateRealGetPointer()->warnings.lowBattery) && ((stateRealGetPointer()->lifeData.battery_charge > 9) || (wasFirmwareUpdateCheckBattery)))
 				{
-					stateRealGetPointerWrite()->lastKnownBatteryPercentage = stateRealGetPointer()->lifeData.battery_charge;
+					if(stateRealGetPointer()->lifeData.battery_charge < 0.0)
+					{
+						if(fabs(stateRealGetPointerWrite()->lastKnownBatteryPercentage - fabs(stateRealGetPointer()->lifeData.battery_charge)) < 1.0)
+						{
+							setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage);	/* confirm that value provided by RTE is valid (maybe reset happened) */
+						}
+					}
+					else
+					{
+						if(!(stateRealGetPointer()->warnings.lowBattery) && (stateRealGetPointer()->lifeData.battery_charge > 9))
+						{
+							stateRealGetPointerWrite()->lastKnownBatteryPercentage = stateRealGetPointer()->lifeData.battery_charge;
+						}
+					}
 				}
-				else if((wasFirmwareUpdateCheckBattery) && (timeout_in_seconds > 3))
+				if((wasFirmwareUpdateCheckBattery) && (timeout_in_seconds > 3))
 				{
 					wasFirmwareUpdateCheckBattery = 0;
 					setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); // added 170306
 					if(	(settingsGetPointer()->lastKnownBatteryPercentage > 0)
-					&& 	(settingsGetPointer()->lastKnownBatteryPercentage <= 100)
+					&& 	(settingsGetPointer()->lastKnownBatteryPercentage <= 101.0)
 					&& 	(stateRealGetPointer()->warnings.lowBattery))
 					{
 						setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage);
--- a/Discovery/Src/check_warning.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Src/check_warning.c	Wed Mar 30 18:01:29 2022 +0200
@@ -348,7 +348,7 @@
 
 static int8_t check_Battery(SDiveState * pDiveState)
 {
-	if(pDiveState->lifeData.battery_charge < 10)
+	if((pDiveState->lifeData.battery_charge > 0) && (pDiveState->lifeData.battery_charge < 10))
 		pDiveState->warnings.lowBattery = 1;
 	else
 		pDiveState->warnings.lowBattery = 0;
--- a/Discovery/Src/logbook.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Src/logbook.c	Wed Mar 30 18:01:29 2022 +0200
@@ -1309,7 +1309,14 @@
 		logbook_SetCompartmentDesaturation(pStateReal);
 		logbook_SetLastStop(pStateReal->diveSettings.last_stop_depth_bar);
 		gheader.batteryVoltage = pStateReal->lifeData.battery_voltage * 1000;
-		gheader.batteryCharge = pStateReal->lifeData.battery_charge;
+		if(pStateReal->lifeData.battery_charge > 0.0)
+		{
+			gheader.batteryCharge = pStateReal->lifeData.battery_charge;
+		}
+		else
+		{
+			gheader.batteryCharge = 0.0;
+		}
 		logbook_EndDive();
 		bDiveMode = 0;
 	} else
--- a/Discovery/Src/t7.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Src/t7.c	Wed Mar 30 18:01:29 2022 +0200
@@ -62,6 +62,7 @@
 
 void t7_miniLiveLogProfile(void);
 void t7_logo_OSTC(void);
+void t7_ChargerView(void);
 static void t7_colorscheme_mod(char *text);
 
 uint8_t t7_test_customview_warnings(void);
@@ -137,7 +138,7 @@
     CVIEW_Compass,
     CVIEW_Tissues,
     CVIEW_sensors_mV,
-    CVIEW_END,
+	CVIEW_Charger,
     CVIEW_END
 };
 
@@ -686,6 +687,7 @@
 void t7_refresh_surface(void)
 {
 	static float debounceAmbientPressure = 0;
+	static uint8_t lastChargeStatus = 0;
     char text[256];
     char timeSuffix;
     uint8_t hours;
@@ -1185,6 +1187,11 @@
     }
     else
     {
+        if(lastChargeStatus == CHARGER_off)
+        {
+        	t7_select_customview(CVIEW_Charger);
+        }
+
         GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryCharging);
 
         switch(stateUsed->chargeStatus)
@@ -1205,6 +1212,7 @@
         GFX_write_string_color(&Batt24,&t7charge,text,0,color);
     }
 
+    lastChargeStatus = stateUsed->chargeStatus;
 
 
     customview_warnings = t7_test_customview_warnings_surface_mode();
@@ -1609,6 +1617,13 @@
     {
       	cv_disabled = 1;
     }
+
+    if ((view == CVIEW_Charger) && (stateUsed->chargeStatus != CHARGER_running) && (stateUsed->chargeStatus != CHARGER_lostConnection))
+    {
+       	cv_disabled = 1;
+    }
+
+
     return cv_disabled;
 }
 
@@ -1739,6 +1754,13 @@
         }
         break;
 
+    case CVIEW_Charger:
+             snprintf(text,100,"\032\f\001%c",TXT_Charging);
+            GFX_write_string(&FontT42,&t7cH,text,0);
+            t7_ChargerView();
+
+        break;
+
     case CVIEW_SummaryOfLeftCorner:
         snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Summary);
         GFX_write_string(&FontT42,&t7cH,text,0);
@@ -3832,3 +3854,195 @@
     windowGimp.top = 40 + 32;
     GFX_draw_image_monochrome(&t7screen, windowGimp, &ImgOSTC, 0);
 }
+
+static uint16_t ChargerLog[60] = {10,10,10,10,10,10,10,10,10,10,
+								  10,10,10,10,10,10,10,10,10,10,
+								  10,10,10,10,10,10,10,10,10,10,
+								  10,10,10,10,10,10,10,10,10,10,
+								  10,10,10,10,10,10,10,10,10,10,
+								  10,10,10,10,10,10,10,10,10,10};
+
+uint16_t LogDeltaCharge(float charge)
+{
+	static uint8_t curIndex = 0;
+	static float averageSpeed = 0.0;
+	uint16_t level = 0;
+	uint16_t completeSec = 0;
+
+	if(charge > 0.003)
+	{
+		level = 2;
+	}
+	else if(charge > 0.0025)
+	{
+			level = 3;
+	}
+	else if(charge > 0.002)
+	{
+			level = 4;
+	}
+	else if(charge > 0.0015)
+	{
+			level = 5;
+	}
+	else if(charge > 0.001)
+	{
+			level = 6;
+	}
+	else if(charge > 0.0005)
+	{
+			level = 7;
+	}
+	else if(charge > 0.00)
+	{
+			level = 8;
+	}
+	else
+	{
+		level = 10;
+	}
+	if(curIndex < 59)
+	{
+		ChargerLog[curIndex++] = level;
+	}
+	else
+	{
+		memcpy (&ChargerLog[0],&ChargerLog[1],sizeof(ChargerLog) - 1);
+		ChargerLog[curIndex] = level;
+	}
+	if(curIndex > 1)
+	{
+		averageSpeed = ((averageSpeed * (curIndex-1)) + charge) / curIndex;
+		completeSec = (100.0 - stateUsed->lifeData.battery_charge) / averageSpeed;
+	}
+	else
+	{
+		completeSec = 0xffff;
+	}
+	return completeSec;
+}
+
+uint16_t* getChargeLog()
+{
+	return ChargerLog;
+}
+
+void t7_ChargerView(void)
+{
+	static float lastCharge = 0.0;
+	float localCharge = 0.0;
+	static uint32_t lastTick = 0;
+	uint32_t curTick = 0;
+	static float speed = 0.0;
+	float deltatime = 0.0;
+
+    char text[256+50];
+    uint8_t textpointer = 0;
+    static uint16_t remainingSec = 0;
+    uint16_t hoursto100 = 0;
+    char indicator = '~';
+
+    point_t start, stop;
+
+    t7cY0free.WindowLineSpacing = 28 + 48 + 14;
+    t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing;
+    t7cY0free.WindowNumberOfTextLines = 3;
+
+    localCharge = stateUsed->lifeData.battery_charge;
+    if(localCharge < 0.0)
+    {
+    	localCharge *= -1.0;
+    }
+
+    if(stateUsed->chargeStatus != CHARGER_off)
+    {
+		if(lastCharge != localCharge)
+		{
+			curTick = HAL_GetTick();
+			deltatime = (curTick - lastTick);
+			lastTick = curTick;
+			if(lastCharge < localCharge)
+			{
+				speed = (localCharge - lastCharge) * 1000.0 / deltatime;
+			}
+
+			lastCharge = localCharge;
+		}
+
+		if(deltatime > 1000)
+		{
+			deltatime = 0;
+			remainingSec = LogDeltaCharge(speed);
+			speed = 0;
+		}
+    }
+    textpointer += snprintf(&text[textpointer],50,"\n\r");
+    textpointer += snprintf(&text[textpointer],50,"\001%c\n\r",TXT_ChargeHour);
+
+    GFX_write_string(&FontT24, &t7cY0free, text, 1);
+
+    hoursto100 = remainingSec / 3600;		/* reduce to hours */
+    if(hoursto100 < 1)
+    {
+    	indicator = '<';
+    	hoursto100 = 1;
+    }
+    t7cY0free.WindowY0 -= 52;
+
+    if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->chargeStatus != CHARGER_off))
+    {
+		snprintf(text,60,
+			"\001%0.2f\n\r"
+			"\001%c%d\n\r"
+			,stateUsed->lifeData.battery_charge
+			,indicator
+			,hoursto100);
+    }
+    else
+    {
+		snprintf(text,60,
+			"\001---\n\r"
+			"\001---\n\r");
+    }
+    GFX_write_string(&FontT42, &t7cY0free, text, 1);
+
+    SWindowGimpStyle wintemp;
+	SSettings* pSettings;
+	pSettings = settingsGetPointer();
+
+
+
+    wintemp.left = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + 50;
+    wintemp.right = wintemp.left + CUSTOMBOX_SPACE_INSIDE - 100;
+
+
+    if(!pSettings->FlipDisplay)
+    {
+    	wintemp.top = 480 - t7l1.WindowY0 + 115;
+    	wintemp.bottom = wintemp.top + 100;
+    }
+    else
+    {
+    	wintemp.top = t7l1.WindowY1;
+    	wintemp.bottom = wintemp.top + 200;
+    }
+
+    start.x =  wintemp.left-5;
+    //start.y =  wintemp.top + 100;
+    start.y =  90;
+
+    stop.x = wintemp.right + 5 - start.x;
+    //stop.y = wintemp.bottom - start.y;
+    stop.y = 100;
+    GFX_draw_box(&t7screen, start, stop,1, CLUT_Font020);
+
+    if(stateUsed->chargeStatus != CHARGER_off)
+    {
+    	GFX_graph_print(&t7screen, &wintemp, 1,1,0, 10, getChargeLog(), 60, CLUT_Font030, NULL);
+    }
+    else
+    {
+        	GFX_graph_print(&t7screen, &wintemp, 1,1,0, 10, getChargeLog(), 60, CLUT_Font031, NULL);
+    }
+
+}
--- a/Discovery/Src/tMenuEditSystem.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Src/tMenuEditSystem.c	Wed Mar 30 18:01:29 2022 +0200
@@ -1081,7 +1081,7 @@
 #endif
 
 
-        if(stateRealGetPointer()->lifeData.battery_charge == 0)
+        if(stateRealGetPointer()->lifeData.battery_charge <= 0)
         {
             text[0] = TXT_2BYTE;
             text[1] = TXT2BYTE_SetBatteryCharge;
--- a/Discovery/Src/text_multilanguage.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Discovery/Src/text_multilanguage.c	Wed Mar 30 18:01:29 2022 +0200
@@ -459,11 +459,11 @@
 static uint8_t text_IT_PSClosedCircuit[] = "PSC circuit";
 static uint8_t text_ES_PSClosedCircuit[] = "PSC circuit";
 
-static uint8_t text_EN_Time[] = "Time";
-static uint8_t text_DE_Time[] = "Uhrzeit";
-static uint8_t text_FR_Time[] = "Heure";
-static uint8_t text_IT_Time[] = "Ora";
-static uint8_t text_ES_Time[] = "Hora";
+static uint8_t text_EN_ChargeHour[] = "Hour(s) till 100%";
+static uint8_t text_DE_ChargeHour[] = "Stunde(n) bis 100%";
+static uint8_t text_FR_ChargeHour[] = "";
+static uint8_t text_IT_ChargeHour[] = "";
+static uint8_t text_ES_ChargeHour[] = "";
 
 static uint8_t text_EN_Date[] = "Date";
 static uint8_t text_DE_Date[] = "Datum";
@@ -1140,6 +1140,13 @@
 static uint8_t text_IT_Warning[] = "Pericolo";
 static uint8_t text_ES_Warning[] = "Peligro";
 
+// Customview Header
+static uint8_t text_EN_Charging[] = "Charging";
+static uint8_t text_DE_Charging[] = "Ladezyklus";
+static uint8_t text_FR_Charging[] = "";
+static uint8_t text_IT_Charging[] = "";
+static uint8_t text_ES_Charging[] = "";
+
 // Menu SYS2 sub Information
 static uint8_t text_EN_Usage_Battery[] = "Battery life";
 static uint8_t text_DE_Usage_Battery[] = "Batterie-Nutzung";
@@ -1762,10 +1769,11 @@
     {(uint8_t)TXT_ActualGradient,   {text_EN_ActualGradient, text_DE_ActualGradient, text_FR_ActualGradient, text_IT_ActualGradient, text_ES_ActualGradient}},
     {(uint8_t)TXT_Stopwatch, 		{text_EN_Stopwatch, text_DE_Stopwatch, text_FR_Stopwatch, text_IT_Stopwatch, text_ES_Stopwatch}},
     {(uint8_t)TXT_Gas, 				{text_EN_Gas, text_DE_Gas, text_FR_Gas, text_IT_Gas, text_ES_Gas}},
-    {(uint8_t)TXT_Time, 			{text_EN_Time, text_DE_Time, text_FR_Time, text_IT_Time, text_ES_Time}},
+    {(uint8_t)TXT_ChargeHour,		{text_EN_ChargeHour, text_DE_ChargeHour, text_FR_ChargeHour, text_IT_ChargeHour, text_ES_ChargeHour}},
     {(uint8_t)TXT_Date, 			{text_EN_Date, text_DE_Date, text_FR_Date, text_IT_Date, text_ES_Date}},
     {(uint8_t)TXT_Format, 			{text_EN_Format, text_DE_Format, text_FR_Format, text_IT_Format, text_ES_Format}},
     {(uint8_t)TXT_Warning, 			{text_EN_Warning, text_DE_Warning, text_FR_Warning, text_IT_Warning, text_ES_Warning}},
+    {(uint8_t)TXT_Charging, 		{text_EN_Charging, text_DE_Charging, text_FR_Charging, text_IT_Charging, text_ES_Charging}},
     {(uint8_t)TXT_o2Sensors, 		{text_EN_o2Sensors, text_DE_o2Sensors, text_FR_o2Sensors, text_IT_o2Sensors, text_ES_o2Sensors}},
     {(uint8_t)TXT_Brightness, 		{text_EN_Brightness, text_DE_Brightness, text_FR_Brightness, text_IT_Brightness, text_ES_Brightness}},
     {(uint8_t)TXT_Cave, 			{text_EN_Cave, text_DE_Cave, text_FR_Cave, text_IT_Cave, text_ES_Cave}},
--- a/Small_CPU/Inc/batteryGasGauge.h	Wed Mar 30 18:00:21 2022 +0200
+++ b/Small_CPU/Inc/batteryGasGauge.h	Wed Mar 30 18:01:29 2022 +0200
@@ -35,6 +35,8 @@
 #define BATTERY_ENDOF_CHARGE_VOLTAGE			(4.05f)
 #define BATTERY_CHARGER_CONNECTED_VOLTAGE		(4.2f)
 
+#define BATTERY_CHARGE_UNKNOWN					(-1.0f)
+
 void init_battery_gas_gauge(void);
 
 float get_voltage(void);
@@ -45,6 +47,10 @@
 void battery_gas_gauge_set(float percentage);
 uint8_t battery_gas_gauge_CheckConfigOK(void);
 
+uint8_t battery_gas_gauge_isChargeValueValid(void);
+void battery_gas_gauge_setChargeValueValid(void);
+
+
 #ifdef __cplusplus
 }
 #endif
--- a/Small_CPU/Src/baseCPU2.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Small_CPU/Src/baseCPU2.c	Wed Mar 30 18:01:29 2022 +0200
@@ -166,9 +166,9 @@
 // See CPU2-RTE.ld
 const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= {
 		.versionFirst = 2,
-		.versionSecond = 7,
+		.versionSecond = 8,
 		.versionThird = 0,
-		.versionBeta = 0,
+		.versionBeta = 1,
 
 /* 4 bytes with trailing 0 */
 		.signature = "mh",
--- a/Small_CPU/Src/batteryCharger.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Small_CPU/Src/batteryCharger.c	Wed Mar 30 18:01:29 2022 +0200
@@ -39,8 +39,8 @@
 
 #define CHARGER_DEBOUNCE_SECONDS	(6u)		/* 6 seconds used to avoid problems with charger interrupts / disconnections */
 
-uint8_t battery_i_charge_status = 0;
-uint16_t battery_charger_counter = 0;
+static uint8_t battery_i_charge_status = 0;
+static uint16_t battery_charger_counter = 0;
 
 #ifdef ENABLE_CHARGER_STATUS_V2
 static chargerState_t batteryChargerState = Charger_NotConnected;
@@ -141,7 +141,6 @@
 {
 #ifdef ENABLE_CHARGER_STATUS_V2
 	static uint8_t notifyChargeComplete = 0;
-	static float chargeValueAtStart = 0;
 #endif 
 
 	#ifdef OSTC_ON_DISCOVERY_HARDWARE
@@ -158,10 +157,6 @@
 			{
 				battery_gas_gauge_set_charge_full();
 			}
-			else										/* unknown state => reset to 0% */
-			{
-				battery_gas_gauge_set(0);
-			}
 			batteryChargerState = Charger_NotConnected;
 		}
 	}
@@ -176,13 +171,15 @@
 													batteryChargerState = Charger_LostConnection;
 													battery_charger_counter = CHARGER_DEBOUNCE_SECONDS;
 											break;
-				case Charger_LostConnection:		if(get_voltage() >= BATTERY_ENDOF_CHARGE_VOLTAGE)	 	/* the charger stops charging when charge current is 1/10 	*/
-																											/* Basically it is OK to rate a charging as complete if a defined voltage is reached */
+				case Charger_LostConnection:		/* the charger stops charging when charge current is 1/10 	*/
+													/* Basically it is OK to rate a charging as complete if a defined voltage is reached */
+													if(((battery_gas_gauge_isChargeValueValid() == 0) || (global.lifeData.battery_charge < 90)) && (get_voltage() >= BATTERY_ENDOF_CHARGE_VOLTAGE))
 													{
 														batteryChargerState = Charger_Finished;
 														global.dataSendToMaster.chargeStatus = CHARGER_complete;
 														global.deviceDataSendToMaster.chargeStatus = CHARGER_complete;
 														notifyChargeComplete = 1;
+														battery_charger_counter = 0;
 													}
 				/* no break */
 				case Charger_WarmUp:
@@ -210,13 +207,6 @@
 																HAL_Delay(50);		/* I2C operations are pending in the background. Wait to avoid data loose in caused to potential change to sleep state */
 															}
 														}
-														else
-														{
-															if(chargeValueAtStart < 1.0) /* charging started with unknown value => reset charge state reported by charger */
-															{
-																battery_gas_gauge_set(0);
-															}
-														}
 														batteryChargerState = Charger_NotConnected;
 													}
 											break;
@@ -232,7 +222,6 @@
 					case Charger_NotConnected:		battery_i_charge_status = 1;
 													battery_charger_counter = 0;
 													batteryChargerState = Charger_WarmUp;
-													chargeValueAtStart = global.lifeData.battery_charge;
 											break;
 					case Charger_LostConnection:		batteryChargerState = Charger_Active;
 											break;
@@ -268,6 +257,10 @@
 													}
 													else
 													{
+														if(global.lifeData.battery_charge > 100.0)				/* still charging but indicator is set to full => decrease to 99% to keep count increasing */
+														{
+															battery_gas_gauge_set(99.0);
+														}
 														if(batteryChargerState == Charger_Finished)				/* voltage dropped below the hysteresis again => charging restarted */
 														{
 															batteryChargerState = Charger_Active;
--- a/Small_CPU/Src/batteryGasGauge.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Small_CPU/Src/batteryGasGauge.c	Wed Mar 30 18:01:29 2022 +0200
@@ -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****/
--- a/Small_CPU/Src/scheduler.c	Wed Mar 30 18:00:21 2022 +0200
+++ b/Small_CPU/Src/scheduler.c	Wed Mar 30 18:01:29 2022 +0200
@@ -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;
 }