Mercurial > public > ostc4
comparison Discovery/Src/data_central.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 | 5924a2d1d3ba |
| children |
comparison
equal
deleted
inserted
replaced
| 1037:2af07aa38531 | 1038:677d293c669f |
|---|---|
| 974 { | 974 { |
| 975 color = CLUT_NiceGreen; | 975 color = CLUT_NiceGreen; |
| 976 } | 976 } |
| 977 lastColor = color; | 977 lastColor = color; |
| 978 return color; | 978 return color; |
| 979 } | |
| 980 | |
| 981 void formatStringOfTime(char* pString, uint8_t strLen, RTC_TimeTypeDef Stime, uint8_t showAlive, uint8_t showSeconds) | |
| 982 { | |
| 983 char timeSuffix[] = {0,0,0}; | |
| 984 uint8_t hours; | |
| 985 | |
| 986 if(strLen > 10) | |
| 987 { | |
| 988 | |
| 989 hours = Stime.Hours; | |
| 990 if (settingsGetPointer()->amPMTime) | |
| 991 { | |
| 992 timeSuffix[1] = 'M'; | |
| 993 if (Stime.Hours > 11) | |
| 994 { | |
| 995 timeSuffix[0] = 'P'; | |
| 996 } | |
| 997 else | |
| 998 { | |
| 999 timeSuffix[0] = 'A'; | |
| 1000 } | |
| 1001 | |
| 1002 if (Stime.Hours % 12 == 0) | |
| 1003 { | |
| 1004 hours = 12; | |
| 1005 } | |
| 1006 else | |
| 1007 { | |
| 1008 hours = (Stime.Hours % 12); | |
| 1009 } | |
| 1010 } | |
| 1011 | |
| 1012 if(showSeconds) | |
| 1013 { | |
| 1014 if((Stime.Seconds % 2) || (!showAlive)) | |
| 1015 { | |
| 1016 snprintf(pString, strLen,"%02d:%02d:%02d\016\016%s\017",hours, Stime.Minutes, Stime.Seconds,timeSuffix); | |
| 1017 } | |
| 1018 else | |
| 1019 { | |
| 1020 snprintf(pString, strLen,"%02d\031:\030%02d\031:\030%02d\016\016%s\017",hours, Stime.Minutes, Stime.Seconds,timeSuffix); | |
| 1021 } | |
| 1022 } | |
| 1023 else | |
| 1024 { | |
| 1025 if((Stime.Seconds % 2) || (!showAlive)) | |
| 1026 { | |
| 1027 snprintf(pString, strLen,"%02d:%02d\016\016%s\017",hours, Stime.Minutes,timeSuffix); | |
| 1028 } | |
| 1029 else | |
| 1030 { | |
| 1031 snprintf(pString, strLen,"%02d\031:\030%02d\016\016%s\017",hours, Stime.Minutes,timeSuffix); | |
| 1032 } | |
| 1033 } | |
| 1034 } | |
| 979 } | 1035 } |
| 980 | 1036 |
| 981 /* returns the date in the order defined by the settings DDMMYY => X */ | 1037 /* returns the date in the order defined by the settings DDMMYY => X */ |
| 982 void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year) | 1038 void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year) |
| 983 { | 1039 { |
