comparison Discovery/Src/tMenuEditSystem.c @ 944:44599695df41 Evo_2_23

Restructure Date/Time menu: To have more space for upcoming optins the selection of the date format (DDMMYY) has been moved into a submenu. In addition the function was upgraded to support multi language handling.
author Ideenmodellierer
date Thu, 19 Dec 2024 18:58:18 +0100
parents 940f8e132638
children c6b858f2e025
comparison
equal deleted inserted replaced
943:e7f87ade3037 944:44599695df41
46 /*#define HAVE_DEBUG_VIEW */ 46 /*#define HAVE_DEBUG_VIEW */
47 static uint8_t infoPage = 0; 47 static uint8_t infoPage = 0;
48 48
49 /* Private function prototypes -----------------------------------------------*/ 49 /* Private function prototypes -----------------------------------------------*/
50 void openEdit_DateTime(void); 50 void openEdit_DateTime(void);
51 void openEdit_DateFormat(void);
51 void openEdit_Language(void); 52 void openEdit_Language(void);
52 void openEdit_Design(void); 53 void openEdit_Design(void);
53 void openEdit_Information(void); 54 void openEdit_Information(void);
54 void openEdit_Reset(void); 55 void openEdit_Reset(void);
55 void openEdit_Maintenance(void); 56 void openEdit_Maintenance(void);
58 59
59 /* Announced function prototypes -----------------------------------------------*/ 60 /* Announced function prototypes -----------------------------------------------*/
60 uint8_t OnAction_Date (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 61 uint8_t OnAction_Date (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
61 uint8_t OnAction_Time (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 62 uint8_t OnAction_Time (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
62 uint8_t OnAction_12HR (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); 63 uint8_t OnAction_12HR (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);
63 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);
64 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);
65 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);
66 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);
67 uint8_t OnAction_English (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);
235 237
236 void openEdit_DateTime(void) 238 void openEdit_DateTime(void)
237 { 239 {
238 RTC_DateTypeDef Sdate; 240 RTC_DateTypeDef Sdate;
239 RTC_TimeTypeDef Stime; 241 RTC_TimeTypeDef Stime;
240 uint8_t day,month,year,hour,minute, dateFormat, ddmmyy, mmddyy, yymmdd; 242 uint8_t day,month,year,hour,minute;
241 char text[32]; 243 char text[32];
244 char formatStr[10];
242 SSettings *pSettings; 245 SSettings *pSettings;
243 const SFirmwareData *pFirmwareInfo; 246 const SFirmwareData *pFirmwareInfo;
244 pFirmwareInfo = firmwareDataGetPointer(); 247 pFirmwareInfo = firmwareDataGetPointer();
245 const SDiveState * pStateReal = stateRealGetPointer(); 248 const SDiveState * pStateReal = stateRealGetPointer();
246 249
247 pSettings = settingsGetPointer(); 250 pSettings = settingsGetPointer();
251
252 set_globalState(StMSYS1_DateTime);
253 resetMenuEdit(CLUT_MenuPageSystem);
254
248 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); 255 translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate);
249 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); 256 translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime);
250 year = Sdate.Year; 257 year = Sdate.Year;
251 month = Sdate.Month; 258 month = Sdate.Month;
252 day = Sdate.Date; 259 day = Sdate.Date;
261 268
262 if(day < 1) 269 if(day < 1)
263 day = 1; 270 day = 1;
264 271
265 // daylightsaving = Stime.DayLightSaving; 272 // daylightsaving = Stime.DayLightSaving;
266 dateFormat = pSettings->date_format; 273
267 ddmmyy = 0; 274 switch(pSettings->date_format)
268 mmddyy = 0; 275 {
269 yymmdd = 0; 276 default:
270 277 case DDMMYY: snprintf(formatStr,10,"DDMMYY");
271 if(dateFormat == DDMMYY) 278 break;
272 ddmmyy = 1; 279 case MMDDYY: snprintf(formatStr,10,"MMDDYY");
273 else 280 break;
274 if(dateFormat == MMDDYY) 281 case YYMMDD: snprintf(formatStr,10,"YYMMDD");
275 mmddyy = 1; 282 break;
276 else 283 };
277 yymmdd = 1;
278 284
279 text[0] = '\001'; 285 text[0] = '\001';
280 text[1] = TXT_DateAndTime; 286 text[1] = TXT_DateAndTime;
281 text[2] = 0; 287 text[2] = 0;
282 288
283 write_topline(text); 289 write_topline(text);
284 290
285 write_label_fix( 20, 340, ME_Y_LINE1, &FontT42, TXT_TimeConfig); 291 write_label_fix( 20, 340, ME_Y_LINE1, &FontT42, TXT_TimeConfig);
286 write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); 292 write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format);
287 write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); 293 write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig);
288 write_label_var( 600, 800, ME_Y_LINE4, &FontT48, "\016\016DDMMYY\017"); 294 write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format);
289 write_label_fix( 20, 790, ME_Y_LINE5, &FontT42, TXT_Format);
290 // write_label_fix( 350 ,580, 250, &FontT42, TXT_Daylightsaving);
291 295
292 write_field_2digit(StMSYS1_Time, 320, 780, ME_Y_LINE1, &FontT48, "##:##", (uint32_t)hour, (uint32_t)minute, 0, 0); 296 write_field_2digit(StMSYS1_Time, 320, 780, ME_Y_LINE1, &FontT48, "##:##", (uint32_t)hour, (uint32_t)minute, 0, 0);
293 write_field_on_off(StMSYS1_12HR, 320, 790, ME_Y_LINE2, &FontT48, "12 HR", pSettings->amPMTime); 297 write_field_on_off(StMSYS1_12HR, 320, 790, ME_Y_LINE2, &FontT48, "12 HR", pSettings->amPMTime);
294 write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "##-##-20##", (uint32_t)day, (uint32_t)month, (uint32_t)year, 0); 298
295 write_field_on_off(StMSYS1_DDMMYY, 320, 790, ME_Y_LINE4, &FontT48, "DDMMYY", ddmmyy); 299 switch(pSettings->date_format)
296 write_field_on_off(StMSYS1_MMDDYY, 320, 790, ME_Y_LINE5, &FontT48, "MMDDYY", mmddyy); 300 {
297 write_field_on_off(StMSYS1_YYMMDD, 320, 790, ME_Y_LINE6, &FontT48, "YYMMDD", yymmdd); 301 default:
298 // write_field_on_off(StMSYS1_DST, 350, 580, 310, &FontT48, "Active", daylightsaving); 302 case DDMMYY: write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "##-##-20##", (uint32_t)day, (uint32_t)month, (uint32_t)year, 0);
303 break;
304 case MMDDYY: write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "##-##-20##", (uint32_t)month, (uint32_t)day, (uint32_t)year, 0);
305 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);
307 break;
308 }
309
310
311 write_field_button(StMSYS1_FORMAT, 320, 790, ME_Y_LINE4, &FontT48, formatStr);
299 312
300 setEvent(StMSYS1_Date, (uint32_t)OnAction_Date); 313 setEvent(StMSYS1_Date, (uint32_t)OnAction_Date);
301 setEvent(StMSYS1_Time, (uint32_t)OnAction_Time); 314 setEvent(StMSYS1_Time, (uint32_t)OnAction_Time);
302 setEvent(StMSYS1_12HR, (uint32_t)OnAction_12HR); 315 setEvent(StMSYS1_12HR, (uint32_t)OnAction_12HR);
303 setEvent(StMSYS1_DDMMYY, (uint32_t)OnAction_DDMMYY); 316 setEvent(StMSYS1_FORMAT, (uint32_t)OnAction_Format);
304 setEvent(StMSYS1_MMDDYY, (uint32_t)OnAction_MMDDYY);
305 setEvent(StMSYS1_YYMMDD, (uint32_t)OnAction_YYMMDD);
306 // setEvent(StMSYS1_DST, (uint32_t)OnAction_DST); 317 // setEvent(StMSYS1_DST, (uint32_t)OnAction_DST);
307 318
308 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); 319 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
309 } 320 }
310 321
316 RTC_DateTypeDef sdatestructure; 327 RTC_DateTypeDef sdatestructure;
317 328
318 const SFirmwareData *pFirmwareInfo; 329 const SFirmwareData *pFirmwareInfo;
319 pFirmwareInfo = firmwareDataGetPointer(); 330 pFirmwareInfo = firmwareDataGetPointer();
320 331
332 uint8_t mapDMY[3];
333 switch(settingsGetPointer()->date_format)
334 {
335 default:
336 case DDMMYY: mapDMY[0] = 0;
337 mapDMY[1] = 1;
338 mapDMY[2] = 2;
339 break;
340 case MMDDYY: mapDMY[0] = 1;
341 mapDMY[1] = 0;
342 mapDMY[2] = 2;
343 break;
344 case YYMMDD: mapDMY[0] = 2;
345 mapDMY[1] = 1;
346 mapDMY[2] = 0;
347 break;
348 }
349
321 if(action == ACTION_BUTTON_ENTER) 350 if(action == ACTION_BUTTON_ENTER)
322 { 351 {
323 return digitContent; 352 return digitContent;
324 } 353 }
325 if(action == ACTION_BUTTON_ENTER_FINAL) 354 if(action == ACTION_BUTTON_ENTER_FINAL)
326 { 355 {
327 evaluateNewString(editId, &newDay, &newMonth, &newYear, 0); 356 switch(settingsGetPointer()->date_format)
357 {
358 default:
359 case DDMMYY: evaluateNewString(editId, &newDay, &newMonth, &newYear, 0);
360 break;
361 case MMDDYY: evaluateNewString(editId, &newMonth, &newDay, &newYear, 0);
362 break;
363 case YYMMDD: evaluateNewString(editId, &newYear, &newMonth, &newDay, 0);
364 break;
365 }
366
328 if(newDay == 0) 367 if(newDay == 0)
329 newDay = 1; 368 newDay = 1;
330 if(newDay > 31) 369 if(newDay > 31)
331 newDay = 31; 370 newDay = 31;
332 if(newMonth == 0) 371 if(newMonth == 0)
347 sdatestructure.Year = newYear; 386 sdatestructure.Year = newYear;
348 setWeekday(&sdatestructure); 387 setWeekday(&sdatestructure);
349 388
350 setDate(sdatestructure); 389 setDate(sdatestructure);
351 390
352 tMenuEdit_newInput(editId, newDay, newMonth, newYear, 0); 391 switch(settingsGetPointer()->date_format)
392 {
393 default:
394 case DDMMYY: tMenuEdit_newInput(editId, newDay, newMonth, newYear, 0);
395 break;
396 case MMDDYY: tMenuEdit_newInput(editId, newMonth, newDay, newYear, 0);
397 break;
398 case YYMMDD: tMenuEdit_newInput(editId, newYear, newMonth, newDay, 0);
399 break;
400 }
401
353 return UNSPECIFIC_RETURN; 402 return UNSPECIFIC_RETURN;
354 } 403 }
355 if(action == ACTION_BUTTON_NEXT) /* clip values to a specific range e.g. 12 months */ 404 if(action == ACTION_BUTTON_NEXT) /* clip values to a specific range e.g. 12 months */
356 { 405 {
357 digitContentNew = digitContent + 1; 406 digitContentNew = digitContent + 1;
358 if((blockNumber == 0) && (digitContentNew > '0' + 31)) 407
408 if((blockNumber == mapDMY[0]) && (digitContentNew > '0' + 31))
409 {
359 digitContentNew = '1'; 410 digitContentNew = '1';
360 if((blockNumber == 1) && (digitContentNew > '0' + 12)) 411 }
412 if((blockNumber == mapDMY[1]) && (digitContentNew > '0' + 12))
413 {
361 digitContentNew = '1'; 414 digitContentNew = '1';
362 if((blockNumber == 2) && (digitContentNew > '0' + pFirmwareInfo->release_year + 10)) 415 }
416 if((blockNumber == mapDMY[2]) && (digitContentNew > '0' + pFirmwareInfo->release_year + 10))
417 {
363 digitContentNew = '0' + pFirmwareInfo->release_year; 418 digitContentNew = '0' + pFirmwareInfo->release_year;
419 }
364 return digitContentNew; 420 return digitContentNew;
365 } 421 }
366 if(action == ACTION_BUTTON_BACK) /* clip values to a specific range e.g. 12 months */ 422 if(action == ACTION_BUTTON_BACK) /* clip values to a specific range e.g. 12 months */
367 { 423 {
368 digitContentNew = digitContent - 1; 424 digitContentNew = digitContent - 1;
369 if((blockNumber == 0) && (digitContentNew < '1')) 425 if((blockNumber == mapDMY[0]) && (digitContentNew < '1'))
426 {
370 digitContentNew = '0' + 31; 427 digitContentNew = '0' + 31;
371 if((blockNumber == 1) && (digitContentNew < '1')) 428 }
429 if((blockNumber == mapDMY[1]) && (digitContentNew < '1'))
430 {
372 digitContentNew = '0' + 12; 431 digitContentNew = '0' + 12;
373 if((blockNumber == 2) && (digitContentNew < '0' + pFirmwareInfo->release_year)) 432 }
433 if((blockNumber == mapDMY[2]) && (digitContentNew < '0' + pFirmwareInfo->release_year))
434 {
374 digitContentNew = '0' + pFirmwareInfo->release_year + 10; 435 digitContentNew = '0' + pFirmwareInfo->release_year + 10;
436 }
375 return digitContentNew; 437 return digitContentNew;
376 } 438 }
377 /* 439 /*
378 if(action == ACTION_BUTTON_NEXT) 440 if(action == ACTION_BUTTON_NEXT)
379 { 441 {
484 546
485 pSettings = settingsGetPointer(); 547 pSettings = settingsGetPointer();
486 pSettings->amPMTime = !(pSettings->amPMTime); 548 pSettings->amPMTime = !(pSettings->amPMTime);
487 549
488 tMenuEdit_set_on_off(editId, pSettings->amPMTime); 550 tMenuEdit_set_on_off(editId, pSettings->amPMTime);
551
552 return UNSPECIFIC_RETURN;
553 }
554
555 void openEdit_DateFormat(void)
556 {
557 char text[32];
558 SSettings *pSettings;
559
560 uint8_t ddmmyy = 0;
561 uint8_t mmddyy= 0;
562 uint8_t yymmdd = 0;
563
564 pSettings = settingsGetPointer();
565
566
567 set_globalState(StMSYS1_FORMAT);
568 resetMenuEdit(CLUT_MenuPageSystem);
569 setBackMenu((uint32_t)openEdit_DateTime,0,4);
570
571 switch(pSettings->date_format)
572 {
573 default:
574 case DDMMYY: ddmmyy = 1;
575 break;
576 case MMDDYY: mmddyy = 1;
577 break;
578 case YYMMDD: yymmdd = 1;
579 break;
580 };
581
582 text[0] = '\001';
583 text[1] = TXT_Format;
584 text[2] = 0;
585
586 write_topline(text);
587
588 write_label_fix( 20, 790, ME_Y_LINE2, &FontT42, TXT_Format);
589
590 write_field_on_off(StMSYS1_DDMMYY, 320, 790, ME_Y_LINE1, &FontT48, "DDMMYY", ddmmyy);
591 write_field_on_off(StMSYS1_MMDDYY, 320, 790, ME_Y_LINE2, &FontT48, "MMDDYY", mmddyy);
592 write_field_on_off(StMSYS1_YYMMDD, 320, 790, ME_Y_LINE3, &FontT48, "YYMMDD", yymmdd);
593
594 setEvent(StMSYS1_DDMMYY, (uint32_t)OnAction_DDMMYY);
595 setEvent(StMSYS1_MMDDYY, (uint32_t)OnAction_MMDDYY);
596 setEvent(StMSYS1_YYMMDD, (uint32_t)OnAction_YYMMDD);
597
598 write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
599 }
600
601 uint8_t OnAction_Format(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
602 {
603 openEdit_DateFormat();
489 604
490 return UNSPECIFIC_RETURN; 605 return UNSPECIFIC_RETURN;
491 } 606 }
492 607
493 uint8_t OnAction_DDMMYY(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) 608 uint8_t OnAction_DDMMYY(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)