# HG changeset patch # User Ideenmodellierer # Date 1647122471 -3600 # Node ID c00a80f26641f92db0044a4e86716becbe90e404 # Parent b456be1e152d906b7b93eaf6d4be974b7b4ad1ed Added Charging view: In case the charger is connected to the OSTC a new menu will be shown in the customer view section. The new view shows a charging current indicator, the current charge percentage and an estimation how long the completion of the charging cycle will take (hour window). Some multi language text definitions have been added to support the new view. diff -r b456be1e152d -r c00a80f26641 Common/Inc/data_central.h --- a/Common/Inc/data_central.h Sat Mar 12 22:58:22 2022 +0100 +++ b/Common/Inc/data_central.h Sat Mar 12 23:01:11 2022 +0100 @@ -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 diff -r b456be1e152d -r c00a80f26641 Discovery/Inc/tHome.h --- a/Discovery/Inc/tHome.h Sat Mar 12 22:58:22 2022 +0100 +++ b/Discovery/Inc/tHome.h Sat Mar 12 23:01:11 2022 +0100 @@ -71,6 +71,7 @@ CVIEW_Hello, CVIEW_CompassDebug, CVIEW_SummaryOfLeftCorner, + CVIEW_Charger, CVIEW_END, CVIEW_T3_Decostop, CVIEW_T3_TTS, diff -r b456be1e152d -r c00a80f26641 Discovery/Inc/text_multilanguage.h --- a/Discovery/Inc/text_multilanguage.h Sat Mar 12 22:58:22 2022 +0100 +++ b/Discovery/Inc/text_multilanguage.h Sat Mar 12 23:01:11 2022 +0100 @@ -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, diff -r b456be1e152d -r c00a80f26641 Discovery/Src/t7.c --- a/Discovery/Src/t7.c Sat Mar 12 22:58:22 2022 +0100 +++ b/Discovery/Src/t7.c Sat Mar 12 23:01:11 2022 +0100 @@ -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); + } + +} diff -r b456be1e152d -r c00a80f26641 Discovery/Src/text_multilanguage.c --- a/Discovery/Src/text_multilanguage.c Sat Mar 12 22:58:22 2022 +0100 +++ b/Discovery/Src/text_multilanguage.c Sat Mar 12 23:01:11 2022 +0100 @@ -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}},