comparison Discovery/Src/t7.c @ 672:c00a80f26641 Betatest

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.
author Ideenmodellierer
date Sat, 12 Mar 2022 23:01:11 +0100
parents 16833cd3a2f5
children 3c4a3d78ff2b
comparison
equal deleted inserted replaced
671:b456be1e152d 672:c00a80f26641
60 void t7_SummaryOfLeftCorner(void); 60 void t7_SummaryOfLeftCorner(void);
61 void t7_debug(void); 61 void t7_debug(void);
62 62
63 void t7_miniLiveLogProfile(void); 63 void t7_miniLiveLogProfile(void);
64 void t7_logo_OSTC(void); 64 void t7_logo_OSTC(void);
65 void t7_ChargerView(void);
65 static void t7_colorscheme_mod(char *text); 66 static void t7_colorscheme_mod(char *text);
66 67
67 uint8_t t7_test_customview_warnings(void); 68 uint8_t t7_test_customview_warnings(void);
68 void t7_show_customview_warnings(void); 69 void t7_show_customview_warnings(void);
69 70
135 CVIEW_Hello, 136 CVIEW_Hello,
136 CVIEW_sensors, 137 CVIEW_sensors,
137 CVIEW_Compass, 138 CVIEW_Compass,
138 CVIEW_Tissues, 139 CVIEW_Tissues,
139 CVIEW_sensors_mV, 140 CVIEW_sensors_mV,
140 CVIEW_END, 141 CVIEW_Charger,
141 CVIEW_END 142 CVIEW_END
142 }; 143 };
143 144
144 145
145 static uint8_t selection_custom_field = LLC_Temperature; 146 static uint8_t selection_custom_field = LLC_Temperature;
684 } 685 }
685 686
686 void t7_refresh_surface(void) 687 void t7_refresh_surface(void)
687 { 688 {
688 static float debounceAmbientPressure = 0; 689 static float debounceAmbientPressure = 0;
690 static uint8_t lastChargeStatus = 0;
689 char text[256]; 691 char text[256];
690 char timeSuffix; 692 char timeSuffix;
691 uint8_t hours; 693 uint8_t hours;
692 uint8_t loop, textIdx; 694 uint8_t loop, textIdx;
693 uint8_t date[3], year,month,day; 695 uint8_t date[3], year,month,day;
1183 } 1185 }
1184 } 1186 }
1185 } 1187 }
1186 else 1188 else
1187 { 1189 {
1190 if(lastChargeStatus == CHARGER_off)
1191 {
1192 t7_select_customview(CVIEW_Charger);
1193 }
1194
1188 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryCharging); 1195 GFX_write_string_color(&Batt24,&t7batt,text,0,CLUT_BatteryCharging);
1189 1196
1190 switch(stateUsed->chargeStatus) 1197 switch(stateUsed->chargeStatus)
1191 { 1198 {
1192 case CHARGER_running: 1199 case CHARGER_running:
1203 text[0] = '4'; 1210 text[0] = '4';
1204 text[1] = 0; 1211 text[1] = 0;
1205 GFX_write_string_color(&Batt24,&t7charge,text,0,color); 1212 GFX_write_string_color(&Batt24,&t7charge,text,0,color);
1206 } 1213 }
1207 1214
1215 lastChargeStatus = stateUsed->chargeStatus;
1208 1216
1209 1217
1210 customview_warnings = t7_test_customview_warnings_surface_mode(); 1218 customview_warnings = t7_test_customview_warnings_surface_mode();
1211 if(customview_warnings && warning_count_high_time) 1219 if(customview_warnings && warning_count_high_time)
1212 t7_show_customview_warnings_surface_mode(); 1220 t7_show_customview_warnings_surface_mode();
1607 if (((view == CVIEW_sensors) || (view == CVIEW_sensors_mV)) && 1615 if (((view == CVIEW_sensors) || (view == CVIEW_sensors_mV)) &&
1608 ((stateUsed->diveSettings.ppo2sensors_deactivated == 0x07) || (stateUsed->diveSettings.ccrOption == 0) || (stateUsed->warnings.fallback))) 1616 ((stateUsed->diveSettings.ppo2sensors_deactivated == 0x07) || (stateUsed->diveSettings.ccrOption == 0) || (stateUsed->warnings.fallback)))
1609 { 1617 {
1610 cv_disabled = 1; 1618 cv_disabled = 1;
1611 } 1619 }
1620
1621 if ((view == CVIEW_Charger) && (stateUsed->chargeStatus != CHARGER_running) && (stateUsed->chargeStatus != CHARGER_lostConnection))
1622 {
1623 cv_disabled = 1;
1624 }
1625
1626
1612 return cv_disabled; 1627 return cv_disabled;
1613 } 1628 }
1614 1629
1615 uint8_t t7_change_customview(uint8_t action) 1630 uint8_t t7_change_customview(uint8_t action)
1616 { 1631 {
1735 strcpy(text,"\032\f\001Debug"); 1750 strcpy(text,"\032\f\001Debug");
1736 GFX_write_string(&FontT42,&t7cH,text,0); 1751 GFX_write_string(&FontT42,&t7cH,text,0);
1737 // content 1752 // content
1738 t7_debug(); 1753 t7_debug();
1739 } 1754 }
1755 break;
1756
1757 case CVIEW_Charger:
1758 snprintf(text,100,"\032\f\001%c",TXT_Charging);
1759 GFX_write_string(&FontT42,&t7cH,text,0);
1760 t7_ChargerView();
1761
1740 break; 1762 break;
1741 1763
1742 case CVIEW_SummaryOfLeftCorner: 1764 case CVIEW_SummaryOfLeftCorner:
1743 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Summary); 1765 snprintf(text,100,"\032\f\001%c%c",TXT_2BYTE,TXT2BYTE_Summary);
1744 GFX_write_string(&FontT42,&t7cH,text,0); 1766 GFX_write_string(&FontT42,&t7cH,text,0);
3830 } 3852 }
3831 3853
3832 windowGimp.top = 40 + 32; 3854 windowGimp.top = 40 + 32;
3833 GFX_draw_image_monochrome(&t7screen, windowGimp, &ImgOSTC, 0); 3855 GFX_draw_image_monochrome(&t7screen, windowGimp, &ImgOSTC, 0);
3834 } 3856 }
3857
3858 static uint16_t ChargerLog[60] = {10,10,10,10,10,10,10,10,10,10,
3859 10,10,10,10,10,10,10,10,10,10,
3860 10,10,10,10,10,10,10,10,10,10,
3861 10,10,10,10,10,10,10,10,10,10,
3862 10,10,10,10,10,10,10,10,10,10,
3863 10,10,10,10,10,10,10,10,10,10};
3864
3865 uint16_t LogDeltaCharge(float charge)
3866 {
3867 static uint8_t curIndex = 0;
3868 static float averageSpeed = 0.0;
3869 uint16_t level = 0;
3870 uint16_t completeSec = 0;
3871
3872 if(charge > 0.003)
3873 {
3874 level = 2;
3875 }
3876 else if(charge > 0.0025)
3877 {
3878 level = 3;
3879 }
3880 else if(charge > 0.002)
3881 {
3882 level = 4;
3883 }
3884 else if(charge > 0.0015)
3885 {
3886 level = 5;
3887 }
3888 else if(charge > 0.001)
3889 {
3890 level = 6;
3891 }
3892 else if(charge > 0.0005)
3893 {
3894 level = 7;
3895 }
3896 else if(charge > 0.00)
3897 {
3898 level = 8;
3899 }
3900 else
3901 {
3902 level = 10;
3903 }
3904 if(curIndex < 59)
3905 {
3906 ChargerLog[curIndex++] = level;
3907 }
3908 else
3909 {
3910 memcpy (&ChargerLog[0],&ChargerLog[1],sizeof(ChargerLog) - 1);
3911 ChargerLog[curIndex] = level;
3912 }
3913 if(curIndex > 1)
3914 {
3915 averageSpeed = ((averageSpeed * (curIndex-1)) + charge) / curIndex;
3916 completeSec = (100.0 - stateUsed->lifeData.battery_charge) / averageSpeed;
3917 }
3918 else
3919 {
3920 completeSec = 0xffff;
3921 }
3922 return completeSec;
3923 }
3924
3925 uint16_t* getChargeLog()
3926 {
3927 return ChargerLog;
3928 }
3929
3930 void t7_ChargerView(void)
3931 {
3932 static float lastCharge = 0.0;
3933 float localCharge = 0.0;
3934 static uint32_t lastTick = 0;
3935 uint32_t curTick = 0;
3936 static float speed = 0.0;
3937 float deltatime = 0.0;
3938
3939 char text[256+50];
3940 uint8_t textpointer = 0;
3941 static uint16_t remainingSec = 0;
3942 uint16_t hoursto100 = 0;
3943 char indicator = '~';
3944
3945 point_t start, stop;
3946
3947 t7cY0free.WindowLineSpacing = 28 + 48 + 14;
3948 t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing;
3949 t7cY0free.WindowNumberOfTextLines = 3;
3950
3951 localCharge = stateUsed->lifeData.battery_charge;
3952 if(localCharge < 0.0)
3953 {
3954 localCharge *= -1.0;
3955 }
3956
3957 if(stateUsed->chargeStatus != CHARGER_off)
3958 {
3959 if(lastCharge != localCharge)
3960 {
3961 curTick = HAL_GetTick();
3962 deltatime = (curTick - lastTick);
3963 lastTick = curTick;
3964 if(lastCharge < localCharge)
3965 {
3966 speed = (localCharge - lastCharge) * 1000.0 / deltatime;
3967 }
3968
3969 lastCharge = localCharge;
3970 }
3971
3972 if(deltatime > 1000)
3973 {
3974 deltatime = 0;
3975 remainingSec = LogDeltaCharge(speed);
3976 speed = 0;
3977 }
3978 }
3979 textpointer += snprintf(&text[textpointer],50,"\n\r");
3980 textpointer += snprintf(&text[textpointer],50,"\001%c\n\r",TXT_ChargeHour);
3981
3982 GFX_write_string(&FontT24, &t7cY0free, text, 1);
3983
3984 hoursto100 = remainingSec / 3600; /* reduce to hours */
3985 if(hoursto100 < 1)
3986 {
3987 indicator = '<';
3988 hoursto100 = 1;
3989 }
3990 t7cY0free.WindowY0 -= 52;
3991
3992 if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->chargeStatus != CHARGER_off))
3993 {
3994 snprintf(text,60,
3995 "\001%0.2f\n\r"
3996 "\001%c%d\n\r"
3997 ,stateUsed->lifeData.battery_charge
3998 ,indicator
3999 ,hoursto100);
4000 }
4001 else
4002 {
4003 snprintf(text,60,
4004 "\001---\n\r"
4005 "\001---\n\r");
4006 }
4007 GFX_write_string(&FontT42, &t7cY0free, text, 1);
4008
4009 SWindowGimpStyle wintemp;
4010 SSettings* pSettings;
4011 pSettings = settingsGetPointer();
4012
4013
4014
4015 wintemp.left = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET + 50;
4016 wintemp.right = wintemp.left + CUSTOMBOX_SPACE_INSIDE - 100;
4017
4018
4019 if(!pSettings->FlipDisplay)
4020 {
4021 wintemp.top = 480 - t7l1.WindowY0 + 115;
4022 wintemp.bottom = wintemp.top + 100;
4023 }
4024 else
4025 {
4026 wintemp.top = t7l1.WindowY1;
4027 wintemp.bottom = wintemp.top + 200;
4028 }
4029
4030 start.x = wintemp.left-5;
4031 //start.y = wintemp.top + 100;
4032 start.y = 90;
4033
4034 stop.x = wintemp.right + 5 - start.x;
4035 //stop.y = wintemp.bottom - start.y;
4036 stop.y = 100;
4037 GFX_draw_box(&t7screen, start, stop,1, CLUT_Font020);
4038
4039 if(stateUsed->chargeStatus != CHARGER_off)
4040 {
4041 GFX_graph_print(&t7screen, &wintemp, 1,1,0, 10, getChargeLog(), 60, CLUT_Font030, NULL);
4042 }
4043 else
4044 {
4045 GFX_graph_print(&t7screen, &wintemp, 1,1,0, 10, getChargeLog(), 60, CLUT_Font031, NULL);
4046 }
4047
4048 }