# HG changeset patch # User Ideenmodellierer # Date 1758046423 -7200 # Node ID 677d293c669f0583322706f2bf6a19ee4b074752 # Parent 2af07aa3853163e09214b063c2b29bb666ac0fb9 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. diff -r 2af07aa38531 -r 677d293c669f Common/Inc/data_central.h --- a/Common/Inc/data_central.h Mon Sep 15 21:12:44 2025 +0200 +++ b/Common/Inc/data_central.h Tue Sep 16 20:13:43 2025 +0200 @@ -594,6 +594,7 @@ uint8_t drawingColor_from_ascentspeed(float speed); +void formatStringOfTime(char* pString, uint8_t strLen, RTC_TimeTypeDef Stime, uint8_t showAlive, uint8_t showSeconds); void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year); void getStringOfFormat_DDMMYY(char* pString, uint8_t strLen); void convertUTCToLocal(uint8_t utcHours, uint8_t utcMinutes, uint8_t* pLocalHours, uint8_t* pLocalMinutes); diff -r 2af07aa38531 -r 677d293c669f Discovery/Src/data_central.c --- 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) { diff -r 2af07aa38531 -r 677d293c669f Discovery/Src/t7.c --- a/Discovery/Src/t7.c Mon Sep 15 21:12:44 2025 +0200 +++ b/Discovery/Src/t7.c Tue Sep 16 20:13:43 2025 +0200 @@ -705,9 +705,9 @@ static float debounceAmbientPressure = 0; static uint8_t lastChargeStatus = 0; static float lastTemperature = 100.0; - char text[256]; - char timeSuffix; - uint8_t hours; + char text[200]; + char tmpString[20]; + uint8_t loop, textIdx; uint8_t date[3], year,month,day; uint32_t color; @@ -795,53 +795,20 @@ dateNotSet = 1; else dateNotSet = 0; -/* - if(Stime.Seconds % 2) - snprintf(text,255,"\001%02d:%02d",Stime.Hours,Stime.Minutes); - else - snprintf(text,255,"\001%02d\031:\020%02d",Stime.Hours,Stime.Minutes); - GFX_write_string(&FontT54,&t7surfaceR,text,3); -*/ -// debug version: - - if (settingsGetPointer()->amPMTime) + + + + if((dateNotSet) && (Stime.Seconds % 2 == 0)) { - if (Stime.Hours > 11) - { - timeSuffix = 'P'; - } - else - { - timeSuffix = 'A'; - } - - if (Stime.Hours % 12 == 0) - { - hours = 12; - } - else - { - hours = (Stime.Hours % 12); - } - - if(Stime.Seconds % 2) - snprintf(text,255,"\001%02d:%02d:%02d\016\016%cM\017",hours,Stime.Minutes,Stime.Seconds,timeSuffix); - else if(dateNotSet) - snprintf(text,255,"\001\031%02d:%02d:%02d\016\016%cM\017\020",hours,Stime.Minutes,Stime.Seconds,timeSuffix); - else - snprintf(text,255,"\001%02d\031:\020%02d:%02d\016\016%cM\017",hours,Stime.Minutes,Stime.Seconds,timeSuffix); - GFX_write_string(&FontT48,&t7surfaceR,text,3); + formatStringOfTime(tmpString,20,Stime,0,1); + snprintf(text,100,"\031\001%s",tmpString); } else { - if(Stime.Seconds % 2) - snprintf(text,255,"\001%02d:%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); - else if(dateNotSet) - snprintf(text,255,"\001\031%02d:%02d:%02d\020",Stime.Hours,Stime.Minutes,Stime.Seconds); - else - snprintf(text,255,"\001%02d\031:\020%02d:%02d",Stime.Hours,Stime.Minutes,Stime.Seconds); - GFX_write_string(&FontT54,&t7surfaceR,text,3); + formatStringOfTime(tmpString,20,Stime,1,1); + snprintf(text,100,"\030\001%s",tmpString); } + GFX_write_string(&FontT48,&t7surfaceR,text,3); if(settingsGetPointer()->date_format == DDMMYY) { @@ -2183,9 +2150,8 @@ { static uint8_t last_customview = CVIEW_END; - char text[256]; - char timeSuffix; - uint8_t hoursToDisplay; + char text[200]; + char tmpString[20]; #ifdef ENABLE_PSCR_MODE uint8_t showSimPPO2 = 1; #endif @@ -2449,39 +2415,8 @@ translateDate(stateRealGetPointer()->lifeData.dateBinaryFormat, &Sdate); translateTime(stateRealGetPointer()->lifeData.timeBinaryFormat, &Stime); - if (settingsGetPointer()->amPMTime) - { - if (Stime.Hours > 11) - { - timeSuffix = 'P'; - } - else - { - timeSuffix = 'A'; - } - - if (Stime.Hours % 12 == 0) - { - hoursToDisplay = 12; - } - else - { - hoursToDisplay = (Stime.Hours % 12); - } - - if(Stime.Seconds % 2) - textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d %cM",hoursToDisplay,Stime.Minutes,timeSuffix); - else - textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d %cM",hoursToDisplay,Stime.Minutes,timeSuffix); - } - else - { - if(Stime.Seconds % 2) - textpointer += snprintf(&text[textpointer],100,"\030\001%02d:%02d",Stime.Hours,Stime.Minutes); - else - textpointer += snprintf(&text[textpointer],100,"\030\001%02d\031:\030%02d",Stime.Hours,Stime.Minutes); - } - + formatStringOfTime(tmpString,20,Stime,1,0); + snprintf(text,100,"\030\001%s",tmpString); GFX_write_string(&FontT42, &t7cY0free, text, 2); // EAD / END diff -r 2af07aa38531 -r 677d293c669f Discovery/Src/tMenuSystem.c --- a/Discovery/Src/tMenuSystem.c Mon Sep 15 21:12:44 2025 +0200 +++ b/Discovery/Src/tMenuSystem.c Tue Sep 16 20:13:43 2025 +0200 @@ -58,7 +58,7 @@ textPointer = 0; *tab = 300; *subtext = 0; - char tmpString[15]; + char tmpString[20]; resetLineMask(StMSYS); @@ -131,14 +131,10 @@ text[textPointer++] = TXT_Date; getStringOfFormat_DDMMYY(tmpString,15); textPointer += snprintf(&text[textPointer], 40,"\016\016 %s ",tmpString); - convertStringOfDate_DDMMYY(tmpString,15,Sdate.Date, Sdate.Month, Sdate.Year); + convertStringOfDate_DDMMYY(tmpString,15,Sdate.Date, Sdate.Month, Sdate.Year); textPointer += snprintf(&text[textPointer], 40,"\017\t%s ",tmpString); - - textPointer += snprintf(&text[textPointer], 60, - "%02d:%02d:%02d" - "\n\r" - ,Stime.Hours, Stime.Minutes, Stime.Seconds - ); + formatStringOfTime(tmpString,20,Stime,0,1); + textPointer += snprintf(&text[textPointer], 60,"%s\n\r",tmpString); } else {