Mercurial > public > ostc4
diff 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 |
line wrap: on
line diff
--- a/Discovery/Src/data_central.c Mon Sep 15 21:12:44 2025 +0200 +++ b/Discovery/Src/data_central.c Tue Sep 16 20:13:43 2025 +0200 @@ -978,6 +978,62 @@ return color; } +void formatStringOfTime(char* pString, uint8_t strLen, RTC_TimeTypeDef Stime, uint8_t showAlive, uint8_t showSeconds) +{ + char timeSuffix[] = {0,0,0}; + uint8_t hours; + + if(strLen > 10) + { + + hours = Stime.Hours; + if (settingsGetPointer()->amPMTime) + { + timeSuffix[1] = 'M'; + if (Stime.Hours > 11) + { + timeSuffix[0] = 'P'; + } + else + { + timeSuffix[0] = 'A'; + } + + if (Stime.Hours % 12 == 0) + { + hours = 12; + } + else + { + hours = (Stime.Hours % 12); + } + } + + if(showSeconds) + { + if((Stime.Seconds % 2) || (!showAlive)) + { + snprintf(pString, strLen,"%02d:%02d:%02d\016\016%s\017",hours, Stime.Minutes, Stime.Seconds,timeSuffix); + } + else + { + snprintf(pString, strLen,"%02d\031:\030%02d\031:\030%02d\016\016%s\017",hours, Stime.Minutes, Stime.Seconds,timeSuffix); + } + } + else + { + if((Stime.Seconds % 2) || (!showAlive)) + { + snprintf(pString, strLen,"%02d:%02d\016\016%s\017",hours, Stime.Minutes,timeSuffix); + } + else + { + snprintf(pString, strLen,"%02d\031:\030%02d\016\016%s\017",hours, Stime.Minutes,timeSuffix); + } + } + } +} + /* returns the date in the order defined by the settings DDMMYY => X */ void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year) {
