Mercurial > public > ostc4
comparison Discovery/Src/t7.c @ 1038:677d293c669f GasConsumption
Bugfix AM/PM time:
in the previous version the AM/PM time format was not shown in the system menu and the customer Info view. To solve this problem a helper function was added which now returns a string which consideres the time format setting.
| author | Ideenmodellierer |
|---|---|
| date | Tue, 16 Sep 2025 20:13:43 +0200 |
| parents | 6e11f7327efd |
| children | 52fd91414b6c |
comparison
equal
deleted
inserted
replaced
| 1037:2af07aa38531 | 1038:677d293c669f |
|---|---|
| 703 void t7_refresh_surface(void) | 703 void t7_refresh_surface(void) |
| 704 { | 704 { |
| 705 static float debounceAmbientPressure = 0; | 705 static float debounceAmbientPressure = 0; |
| 706 static uint8_t lastChargeStatus = 0; | 706 static uint8_t lastChargeStatus = 0; |
| 707 static float lastTemperature = 100.0; | 707 static float lastTemperature = 100.0; |
| 708 char text[256]; | 708 char text[200]; |
| 709 char timeSuffix; | 709 char tmpString[20]; |
| 710 uint8_t hours; | 710 |
| 711 uint8_t loop, textIdx; | 711 uint8_t loop, textIdx; |
| 712 uint8_t date[3], year,month,day; | 712 uint8_t date[3], year,month,day; |
| 713 uint32_t color; | 713 uint32_t color; |
| 714 uint8_t customview_warnings = 0; | 714 uint8_t customview_warnings = 0; |
| 715 SButtonLock ButtonLockState; | 715 SButtonLock ButtonLockState; |
| 793 firmwareGetDate(&SdateFirmware); | 793 firmwareGetDate(&SdateFirmware); |
| 794 if(tHome_DateCode(&Sdate) < tHome_DateCode(&SdateFirmware)) | 794 if(tHome_DateCode(&Sdate) < tHome_DateCode(&SdateFirmware)) |
| 795 dateNotSet = 1; | 795 dateNotSet = 1; |
| 796 else | 796 else |
| 797 dateNotSet = 0; | 797 dateNotSet = 0; |
| 798 /* | 798 |
| 799 if(Stime.Seconds % 2) | 799 |
| 800 snprintf(text,255,"\001%02d:%02d",Stime.Hours,Stime.Minutes); | 800 |
| 801 else | 801 if((dateNotSet) && (Stime.Seconds % 2 == 0)) |
| 802 snprintf(text,255,"\001%02d\031:\020%02d",Stime.Hours,Stime.Minutes); | 802 { |
| 803 GFX_write_string(&FontT54,&t7surfaceR,text,3); | 803 formatStringOfTime(tmpString,20,Stime,0,1); |
| 804 */ | 804 snprintf(text,100,"\031\001%s",tmpString); |
| 805 // debug version: | 805 } |
| 806 | 806 else |
| 807 if (settingsGetPointer()->amPMTime) | 807 { |
| 808 { | 808 formatStringOfTime(tmpString,20,Stime,1,1); |
| 809 if (Stime.Hours > 11) | 809 snprintf(text,100,"\030\001%s",tmpString); |
| 810 { | 810 } |
| 811 timeSuffix = 'P'; | 811 GFX_write_string(&FontT48,&t7surfaceR,text,3); |
| 812 } | |
| 813 else | |
| 814 { | |
| 815 timeSuffix = 'A'; | |
| 816 } | |
| 817 | |
| 818 if (Stime.Hours % 12 == 0) | |
| 819 { | |
| 820 hours = 12; | |
| 821 } | |
| 822 else | |
| 823 { | |
| 824 hours = (Stime.Hours % 12); | |
| 825 } | |
| 826 | |
| 827 if(Stime.Seconds % 2) | |
| 828 snprintf(text,255,"\001%02d:%02d:%02d\016\016%cM\017",hours,Stime.Minutes,Stime.Seconds,timeSuffix); | |
| 829 else if(dateNotSet) | |
| 830 snprintf(text,255,"\001\031%02d:%02d:%02d\016\016%cM\017\020",hours,Stime.Minutes,Stime.Seconds,timeSuffix); | |
| 831 else | |
| 832 snprintf(text,255,"\001%02d\031:\020%02d:%02d\016\016%cM\017",hours,Stime.Minutes,Stime.Seconds,timeSuffix); | |
| 833 GFX_write_string(&FontT48,&t7surfaceR,text,3); | |
| 834 } | |
| 835 else | |
| 836 { | |
| 837 if(Stime.Seconds % 2) | |
| 838 snprintf(text,255,"\001%02d:%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); | |
| 839 else if(dateNotSet) | |
| 840 snprintf(text,255,"\001\031%02d:%02d:%02d\020",Stime.Hours,Stime.Minutes,Stime.Seconds); | |
| 841 else | |
| 842 snprintf(text,255,"\001%02d\031:\020%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); | |
| 843 GFX_write_string(&FontT54,&t7surfaceR,text,3); | |
| 844 } | |
| 845 | 812 |
| 846 if(settingsGetPointer()->date_format == DDMMYY) | 813 if(settingsGetPointer()->date_format == DDMMYY) |
| 847 { | 814 { |
| 848 day = 0; | 815 day = 0; |
| 849 month = 1; | 816 month = 1; |
| 2181 | 2148 |
| 2182 void t7_refresh_customview(void) | 2149 void t7_refresh_customview(void) |
| 2183 { | 2150 { |
| 2184 static uint8_t last_customview = CVIEW_END; | 2151 static uint8_t last_customview = CVIEW_END; |
| 2185 | 2152 |
| 2186 char text[256]; | 2153 char text[200]; |
| 2187 char timeSuffix; | 2154 char tmpString[20]; |
| 2188 uint8_t hoursToDisplay; | |
| 2189 #ifdef ENABLE_PSCR_MODE | 2155 #ifdef ENABLE_PSCR_MODE |
| 2190 uint8_t showSimPPO2 = 1; | 2156 uint8_t showSimPPO2 = 1; |
| 2191 #endif | 2157 #endif |
| 2192 uint16_t textpointer = 0; | 2158 uint16_t textpointer = 0; |
| 2193 uint16_t heading = 0; | 2159 uint16_t heading = 0; |
| 2447 GFX_write_string(&FontT42, &t7cY0free, text, 1); | 2413 GFX_write_string(&FontT42, &t7cY0free, text, 1); |
| 2448 | 2414 |
| 2449 translateDate(stateRealGetPointer()->lifeData.dateBinaryFormat, &Sdate); | 2415 translateDate(stateRealGetPointer()->lifeData.dateBinaryFormat, &Sdate); |
| 2450 translateTime(stateRealGetPointer()->lifeData.timeBinaryFormat, &Stime); | 2416 translateTime(stateRealGetPointer()->lifeData.timeBinaryFormat, &Stime); |
| 2451 | 2417 |
| 2452 if (settingsGetPointer()->amPMTime) | 2418 formatStringOfTime(tmpString,20,Stime,1,0); |
| 2453 { | 2419 snprintf(text,100,"\030\001%s",tmpString); |
| 2454 if (Stime.Hours > 11) | |
| 2455 { | |
| 2456 timeSuffix = 'P'; | |
| 2457 } | |
| 2458 else | |
| 2459 { | |
| 2460 timeSuffix = 'A'; | |
| 2461 } | |
| 2462 | |
| 2463 if (Stime.Hours % 12 == 0) | |
| 2464 { | |
| 2465 hoursToDisplay = 12; | |
| 2466 } | |
| 2467 else | |
| 2468 { | |
| 2469 hoursToDisplay = (Stime.Hours % 12); | |
| 2470 } | |
| 2471 | |
| 2472 if(Stime.Seconds % 2) | |
| 2473 textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d %cM",hoursToDisplay,Stime.Minutes,timeSuffix); | |
| 2474 else | |
| 2475 textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d %cM",hoursToDisplay,Stime.Minutes,timeSuffix); | |
| 2476 } | |
| 2477 else | |
| 2478 { | |
| 2479 if(Stime.Seconds % 2) | |
| 2480 textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d",Stime.Hours,Stime.Minutes); | |
| 2481 else | |
| 2482 textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d",Stime.Hours,Stime.Minutes); | |
| 2483 } | |
| 2484 | |
| 2485 GFX_write_string(&FontT42, &t7cY0free, text, 2); | 2420 GFX_write_string(&FontT42, &t7cY0free, text, 2); |
| 2486 | 2421 |
| 2487 // EAD / END | 2422 // EAD / END |
| 2488 // The equivalent air depth can be calculated for depths in metres as follows: | 2423 // The equivalent air depth can be calculated for depths in metres as follows: |
| 2489 // EAD = (Depth + 10) � Fraction of N2 / 0.79 - 10 (wikipedia) | 2424 // EAD = (Depth + 10) � Fraction of N2 / 0.79 - 10 (wikipedia) |
