Mercurial > public > ostc4
comparison Discovery/Src/tMenuEditSystem.c @ 949:c6b858f2e025 Evo_2_23 tip
GNSS UTC in Date-Time menu:
The UTC time provided by the gnss module is not shown in the date-time settings menu. If a valid time signal is available then the OSTC RTC may be set to it by selecting the UTC menu entry. The time zone has to be selected manually. This is possible using a separate edit line.
author | Ideenmodellierer |
---|---|
date | Sun, 22 Dec 2024 21:19:21 +0100 |
parents | 44599695df41 |
children |
comparison
equal
deleted
inserted
replaced
948:abdd72c8b567 | 949:c6b858f2e025 |
---|---|
64 uint8_t OnAction_Format (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 64 uint8_t OnAction_Format (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
65 uint8_t OnAction_DDMMYY (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 65 uint8_t OnAction_DDMMYY (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
66 uint8_t OnAction_MMDDYY (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 66 uint8_t OnAction_MMDDYY (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
67 uint8_t OnAction_YYMMDD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 67 uint8_t OnAction_YYMMDD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
68 uint8_t OnAction_DST (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 68 uint8_t OnAction_DST (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
69 uint8_t OnAction_UTC (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
70 uint8_t OnAction_SetGnss (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | |
69 uint8_t OnAction_English (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 71 uint8_t OnAction_English (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
70 uint8_t OnAction_German (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 72 uint8_t OnAction_German (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
71 uint8_t OnAction_French (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 73 uint8_t OnAction_French (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
72 uint8_t OnAction_Italian (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 74 uint8_t OnAction_Italian (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
73 uint8_t OnAction_Espanol (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); | 75 uint8_t OnAction_Espanol (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); |
233 } | 235 } |
234 | 236 |
235 /* Private functions ---------------------------------------------------------*/ | 237 /* Private functions ---------------------------------------------------------*/ |
236 | 238 |
237 | 239 |
238 void openEdit_DateTime(void) | 240 void refresh_DateTime() |
239 { | 241 { |
240 RTC_DateTypeDef Sdate; | 242 RTC_DateTypeDef Sdate; |
241 RTC_TimeTypeDef Stime; | 243 RTC_TimeTypeDef Stime; |
242 uint8_t day,month,year,hour,minute; | 244 uint8_t day,month,year,hour,minute; |
243 char text[32]; | 245 char text[32]; |
244 char formatStr[10]; | 246 char formatStr[20]; |
245 SSettings *pSettings; | 247 SSettings *pSettings; |
246 const SFirmwareData *pFirmwareInfo; | 248 const SFirmwareData *pFirmwareInfo; |
249 #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 | |
250 uint8_t localHours = 0; | |
251 uint8_t localMinutes = 0; | |
252 #endif | |
247 pFirmwareInfo = firmwareDataGetPointer(); | 253 pFirmwareInfo = firmwareDataGetPointer(); |
248 const SDiveState * pStateReal = stateRealGetPointer(); | 254 const SDiveState * pStateReal = stateRealGetPointer(); |
249 | 255 |
250 pSettings = settingsGetPointer(); | 256 pSettings = settingsGetPointer(); |
251 | |
252 set_globalState(StMSYS1_DateTime); | |
253 resetMenuEdit(CLUT_MenuPageSystem); | |
254 | 257 |
255 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); | 258 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); |
256 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); | 259 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); |
257 year = Sdate.Year; | 260 year = Sdate.Year; |
258 month = Sdate.Month; | 261 month = Sdate.Month; |
267 month = 1; | 270 month = 1; |
268 | 271 |
269 if(day < 1) | 272 if(day < 1) |
270 day = 1; | 273 day = 1; |
271 | 274 |
272 // daylightsaving = Stime.DayLightSaving; | 275 getStringOfFormat_DDMMYY(formatStr, 20); |
273 | |
274 switch(pSettings->date_format) | |
275 { | |
276 default: | |
277 case DDMMYY: snprintf(formatStr,10,"DDMMYY"); | |
278 break; | |
279 case MMDDYY: snprintf(formatStr,10,"MMDDYY"); | |
280 break; | |
281 case YYMMDD: snprintf(formatStr,10,"YYMMDD"); | |
282 break; | |
283 }; | |
284 | 276 |
285 text[0] = '\001'; | 277 text[0] = '\001'; |
286 text[1] = TXT_DateAndTime; | 278 text[1] = TXT_DateAndTime; |
287 text[2] = 0; | 279 text[2] = 0; |
288 | 280 |
290 | 282 |
291 write_label_fix( 20, 340, ME_Y_LINE1, &FontT42, TXT_TimeConfig); | 283 write_label_fix( 20, 340, ME_Y_LINE1, &FontT42, TXT_TimeConfig); |
292 write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); | 284 write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); |
293 write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); | 285 write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); |
294 write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format); | 286 write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format); |
287 #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 | |
288 write_label_var( 20, 340, ME_Y_LINE5, &FontT42, "GNSS"); | |
289 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_TIMEZONE); | |
290 write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); | |
291 #endif | |
292 | |
293 | |
294 tMenuEdit_newInput(StMSYS1_Time, hour, minute, 0, 0); | |
295 tMenuEdit_set_on_off(StMSYS1_12HR, pSettings->amPMTime); | |
296 | |
297 switch(pSettings->date_format) | |
298 { | |
299 default: | |
300 case DDMMYY: tMenuEdit_newInput(StMSYS1_Date, day, month, year, 0); | |
301 break; | |
302 case MMDDYY: tMenuEdit_newInput(StMSYS1_Date, month, day, year, 0); | |
303 break; | |
304 case YYMMDD: tMenuEdit_newInput(StMSYS1_Date, year, month, day, 0); | |
305 break; | |
306 } | |
307 tMenuEdit_newButtonText(StMSYS1_FORMAT, formatStr); | |
308 | |
309 #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 | |
310 if(pStateReal->lifeData.gnssData.alive & GNSS_ALIVE_STATE_TIME) | |
311 { | |
312 convertUTCToLocal(pStateReal->lifeData.gnssData.DateTime.hour, pStateReal->lifeData.gnssData.DateTime.min, &localHours, &localMinutes); | |
313 convertStringOfDate_DDMMYY(formatStr, 20, pStateReal->lifeData.gnssData.DateTime.day | |
314 , pStateReal->lifeData.gnssData.DateTime.month | |
315 , pStateReal->lifeData.gnssData.DateTime.year); | |
316 snprintf(text, 32, "%02d:%02d - %s", localHours, localMinutes, formatStr); | |
317 tMenuEdit_newButtonText(StMSYS1_GNSSDT, text); | |
318 } | |
319 else | |
320 { | |
321 snprintf(text, 32, "--:--"); | |
322 write_label_var( 320, 790, ME_Y_LINE5, &FontT42, text); | |
323 } | |
324 tMenuEdit_newInput(StMSYS1_ZONE, pSettings->timeZone.hours, pSettings->timeZone.minutes, 0, 0); | |
325 #endif | |
326 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | |
327 } | |
328 void openEdit_DateTime(void) | |
329 { | |
330 RTC_DateTypeDef Sdate; | |
331 RTC_TimeTypeDef Stime; | |
332 uint8_t day,month,year,hour,minute; | |
333 char text[32]; | |
334 char formatStr[20]; | |
335 SSettings *pSettings; | |
336 const SFirmwareData *pFirmwareInfo; | |
337 | |
338 pFirmwareInfo = firmwareDataGetPointer(); | |
339 const SDiveState * pStateReal = stateRealGetPointer(); | |
340 | |
341 pSettings = settingsGetPointer(); | |
342 | |
343 set_globalState(StMSYS1_DateTime); | |
344 resetMenuEdit(CLUT_MenuPageSystem); | |
345 | |
346 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); | |
347 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); | |
348 year = Sdate.Year; | |
349 month = Sdate.Month; | |
350 day = Sdate.Date; | |
351 hour = Stime.Hours; | |
352 minute= Stime.Minutes; | |
353 | |
354 if(year < pFirmwareInfo->release_year) | |
355 year = pFirmwareInfo->release_year; | |
356 | |
357 if(month < 1) | |
358 month = 1; | |
359 | |
360 if(day < 1) | |
361 day = 1; | |
362 | |
363 getStringOfFormat_DDMMYY(formatStr, 20); | |
364 | |
365 text[0] = '\001'; | |
366 text[1] = TXT_DateAndTime; | |
367 text[2] = 0; | |
368 | |
369 write_topline(text); | |
370 | |
371 write_label_fix( 20, 340, ME_Y_LINE1, &FontT42, TXT_TimeConfig); | |
372 write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); | |
373 write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); | |
374 write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format); | |
375 #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 | |
376 write_label_var( 20, 340, ME_Y_LINE5, &FontT42, "GNSS"); | |
377 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_TIMEZONE); | |
378 write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); | |
379 #endif | |
295 | 380 |
296 write_field_2digit(StMSYS1_Time, 320, 780, ME_Y_LINE1, &FontT48, "##:##", (uint32_t)hour, (uint32_t)minute, 0, 0); | 381 write_field_2digit(StMSYS1_Time, 320, 780, ME_Y_LINE1, &FontT48, "##:##", (uint32_t)hour, (uint32_t)minute, 0, 0); |
297 write_field_on_off(StMSYS1_12HR, 320, 790, ME_Y_LINE2, &FontT48, "12 HR", pSettings->amPMTime); | 382 write_field_on_off(StMSYS1_12HR, 320, 790, ME_Y_LINE2, &FontT48, "12 HR", pSettings->amPMTime); |
298 | 383 |
299 switch(pSettings->date_format) | 384 switch(pSettings->date_format) |
305 break; | 390 break; |
306 case YYMMDD: write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "20##-##-##", (uint32_t)year, (uint32_t)month, (uint32_t)day, 0); | 391 case YYMMDD: write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "20##-##-##", (uint32_t)year, (uint32_t)month, (uint32_t)day, 0); |
307 break; | 392 break; |
308 } | 393 } |
309 | 394 |
310 | |
311 write_field_button(StMSYS1_FORMAT, 320, 790, ME_Y_LINE4, &FontT48, formatStr); | 395 write_field_button(StMSYS1_FORMAT, 320, 790, ME_Y_LINE4, &FontT48, formatStr); |
396 | |
397 #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 | |
398 snprintf(text, 32, "--:--"); | |
399 write_field_button(StMSYS1_GNSSDT, 320, 790, ME_Y_LINE5, &FontT48, text); | |
400 write_field_sdigit(StMSYS1_ZONE, 320, 780, ME_Y_LINE6, &FontT48, "UTC: ###:###", pSettings->timeZone.hours, pSettings->timeZone.minutes,0,0); | |
401 #endif | |
312 | 402 |
313 setEvent(StMSYS1_Date, (uint32_t)OnAction_Date); | 403 setEvent(StMSYS1_Date, (uint32_t)OnAction_Date); |
314 setEvent(StMSYS1_Time, (uint32_t)OnAction_Time); | 404 setEvent(StMSYS1_Time, (uint32_t)OnAction_Time); |
315 setEvent(StMSYS1_12HR, (uint32_t)OnAction_12HR); | 405 setEvent(StMSYS1_12HR, (uint32_t)OnAction_12HR); |
316 setEvent(StMSYS1_FORMAT, (uint32_t)OnAction_Format); | 406 setEvent(StMSYS1_FORMAT, (uint32_t)OnAction_Format); |
317 // setEvent(StMSYS1_DST, (uint32_t)OnAction_DST); | 407 #if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 |
318 | 408 setEvent(StMSYS1_GNSSDT, (uint32_t)OnAction_SetGnss); |
409 setEvent(StMSYS1_ZONE, (uint32_t)OnAction_UTC); | |
410 #endif | |
319 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); | 411 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); |
320 } | 412 } |
321 | 413 |
322 | 414 |
323 uint8_t OnAction_Date(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 415 uint8_t OnAction_Date(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |
550 tMenuEdit_set_on_off(editId, pSettings->amPMTime); | 642 tMenuEdit_set_on_off(editId, pSettings->amPMTime); |
551 | 643 |
552 return UNSPECIFIC_RETURN; | 644 return UNSPECIFIC_RETURN; |
553 } | 645 } |
554 | 646 |
647 uint8_t OnAction_SetGnss(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
648 { | |
649 RTC_DateTypeDef sdatestructure; | |
650 RTC_TimeTypeDef stimestructure; | |
651 uint8_t localHours = 0; | |
652 uint8_t localMinutes = 0; | |
653 | |
654 const SDiveState * pStateReal = stateRealGetPointer(); | |
655 | |
656 if(pStateReal->lifeData.gnssData.alive & GNSS_ALIVE_STATE_TIME) | |
657 { | |
658 convertUTCToLocal(pStateReal->lifeData.gnssData.DateTime.hour, pStateReal->lifeData.gnssData.DateTime.min, &localHours, &localMinutes); | |
659 stimestructure.Hours = localHours; | |
660 stimestructure.Minutes = localMinutes; | |
661 stimestructure.Seconds = 0; | |
662 setTime(stimestructure); | |
663 | |
664 sdatestructure.Date = pStateReal->lifeData.gnssData.DateTime.day; | |
665 sdatestructure.Month = pStateReal->lifeData.gnssData.DateTime.month; | |
666 sdatestructure.Year = pStateReal->lifeData.gnssData.DateTime.year; | |
667 setWeekday(&sdatestructure); | |
668 setDate(sdatestructure); | |
669 } | |
670 return UNSPECIFIC_RETURN; | |
671 } | |
672 | |
555 void openEdit_DateFormat(void) | 673 void openEdit_DateFormat(void) |
556 { | 674 { |
557 char text[32]; | 675 char text[32]; |
558 SSettings *pSettings; | 676 SSettings *pSettings; |
559 | 677 |
644 | 762 |
645 tMenuEdit_set_on_off(editId, 1); | 763 tMenuEdit_set_on_off(editId, 1); |
646 tMenuEdit_set_on_off(StMSYS1_MMDDYY, 0); | 764 tMenuEdit_set_on_off(StMSYS1_MMDDYY, 0); |
647 tMenuEdit_set_on_off(StMSYS1_DDMMYY, 0); | 765 tMenuEdit_set_on_off(StMSYS1_DDMMYY, 0); |
648 | 766 |
767 return UNSPECIFIC_RETURN; | |
768 } | |
769 | |
770 uint8_t OnAction_UTC(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | |
771 { | |
772 SSettings *settings = settingsGetPointer(); | |
773 const SDiveState * pStateReal = stateRealGetPointer(); | |
774 int32_t utcHour; | |
775 uint32_t utcMinutes; | |
776 uint8_t digitContentNew; | |
777 uint8_t localHours = 0; | |
778 uint8_t localMinutes = 0; | |
779 char text[32]; | |
780 char timeStr[20]; | |
781 | |
782 switch (action) { | |
783 case ACTION_BUTTON_ENTER: | |
784 | |
785 return digitContent; | |
786 case ACTION_BUTTON_ENTER_FINAL: | |
787 { | |
788 | |
789 evaluateNewString(editId, (uint32_t *)&utcHour, &utcMinutes, NULL, NULL); | |
790 | |
791 if (utcHour > 14) { | |
792 utcHour = 14; | |
793 } else if (utcHour < -12) { | |
794 utcHour = -12; | |
795 } | |
796 | |
797 if (utcMinutes % 15 != 0) | |
798 { | |
799 utcMinutes = (utcMinutes / 15) * 15; | |
800 } | |
801 if(utcMinutes > 45) | |
802 { | |
803 utcMinutes = 45; | |
804 } else if (utcMinutes < 0) { | |
805 utcMinutes = 0; | |
806 } | |
807 settings->timeZone.hours = utcHour; | |
808 settings->timeZone.minutes = utcMinutes; | |
809 | |
810 tMenuEdit_newInput(editId, ((input_u)utcHour).uint32, utcMinutes, 0, 0); | |
811 convertUTCToLocal(pStateReal->lifeData.gnssData.DateTime.hour, pStateReal->lifeData.gnssData.DateTime.min, &localHours, &localMinutes); | |
812 convertStringOfDate_DDMMYY(timeStr, 20, pStateReal->lifeData.gnssData.DateTime.day | |
813 , pStateReal->lifeData.gnssData.DateTime.month | |
814 , pStateReal->lifeData.gnssData.DateTime.year); | |
815 snprintf(text, 32, "%2d:%2d - %s", localHours, localMinutes, timeStr); | |
816 tMenuEdit_newButtonText(StMSYS1_GNSSDT, text); | |
817 } | |
818 | |
819 break; | |
820 case ACTION_BUTTON_NEXT: | |
821 if ((blockNumber == 0) && (digitNumber == 0)) { | |
822 digitContentNew = togglePlusMinus(digitContent); | |
823 } else { | |
824 digitContentNew = digitContent + 1; | |
825 if (digitContentNew > '9') { | |
826 digitContentNew = '0'; | |
827 } | |
828 } | |
829 | |
830 return digitContentNew; | |
831 case ACTION_BUTTON_BACK: | |
832 if ((blockNumber == 0) && (digitNumber == 0)) { | |
833 digitContentNew = togglePlusMinus(digitContent); | |
834 } else { | |
835 digitContentNew = digitContent - 1; | |
836 if (digitContentNew < '0') { | |
837 digitContentNew = '9'; | |
838 } | |
839 } | |
840 return digitContentNew; | |
841 } | |
649 return UNSPECIFIC_RETURN; | 842 return UNSPECIFIC_RETURN; |
650 } | 843 } |
651 | 844 |
652 | 845 |
653 uint8_t OnAction_DST(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) | 846 uint8_t OnAction_DST(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) |