diff options
Diffstat (limited to 'apps/screens.c')
-rw-r--r-- | apps/screens.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/apps/screens.c b/apps/screens.c index d997590623..2e7dbd84ed 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -345,9 +345,10 @@ static void say_time(int cursorpos, const struct tm *tm) | |||
345 | 345 | ||
346 | bool set_time_screen(const char* title, struct tm *tm) | 346 | bool set_time_screen(const char* title, struct tm *tm) |
347 | { | 347 | { |
348 | bool done = false; | 348 | struct viewport viewports[NB_SCREENS]; |
349 | bool done = false, usb = false; | ||
349 | int cursorpos = 0; | 350 | int cursorpos = 0; |
350 | unsigned int statusbar_height = 0; | 351 | unsigned int s; |
351 | unsigned char offsets_ptr[] = | 352 | unsigned char offsets_ptr[] = |
352 | { OFF_HOURS, OFF_MINUTES, OFF_SECONDS, OFF_YEAR, 0, OFF_DAY }; | 353 | { OFF_HOURS, OFF_MINUTES, OFF_SECONDS, OFF_YEAR, 0, OFF_DAY }; |
353 | 354 | ||
@@ -359,15 +360,16 @@ bool set_time_screen(const char* title, struct tm *tm) | |||
359 | offsets_ptr[IDX_DAY] = OFF_YEAR; | 360 | offsets_ptr[IDX_DAY] = OFF_YEAR; |
360 | } | 361 | } |
361 | 362 | ||
362 | if(global_settings.statusbar) | ||
363 | statusbar_height = STATUSBAR_HEIGHT; | ||
364 | |||
365 | /* speak selection when screen is entered */ | 363 | /* speak selection when screen is entered */ |
366 | say_time(cursorpos, tm); | 364 | say_time(cursorpos, tm); |
367 | 365 | ||
366 | #ifdef HAVE_TOUCHSCREEN | ||
367 | enum touchscreen_mode old_mode = touchscreen_get_mode(); | ||
368 | touchscreen_set_mode(TOUCHSCREEN_BUTTON); | ||
369 | #endif | ||
368 | while (!done) { | 370 | while (!done) { |
369 | int button; | 371 | int button; |
370 | unsigned int i, s, realyear, min, max; | 372 | unsigned int i, realyear, min, max; |
371 | unsigned char *ptr[6]; | 373 | unsigned char *ptr[6]; |
372 | unsigned char buffer[20]; | 374 | unsigned char buffer[20]; |
373 | int *valptr = NULL; | 375 | int *valptr = NULL; |
@@ -413,7 +415,6 @@ bool set_time_screen(const char* title, struct tm *tm) | |||
413 | int pos, nb_lines; | 415 | int pos, nb_lines; |
414 | unsigned int separator_width, weekday_width; | 416 | unsigned int separator_width, weekday_width; |
415 | unsigned int j, width, prev_line_height; | 417 | unsigned int j, width, prev_line_height; |
416 | struct viewport viewports[NB_SCREENS]; | ||
417 | /* 6 possible cursor possitions, 2 values stored for each: x, y */ | 418 | /* 6 possible cursor possitions, 2 values stored for each: x, y */ |
418 | unsigned int cursor[6][2]; | 419 | unsigned int cursor[6][2]; |
419 | struct viewport *vp = &viewports[s]; | 420 | struct viewport *vp = &viewports[s]; |
@@ -453,7 +454,7 @@ bool set_time_screen(const char* title, struct tm *tm) | |||
453 | prev_line_height *= 2; | 454 | prev_line_height *= 2; |
454 | } | 455 | } |
455 | screen->getstringsize(ptr[i], &width, NULL); | 456 | screen->getstringsize(ptr[i], &width, NULL); |
456 | cursor[i][INDEX_Y] = prev_line_height + statusbar_height; | 457 | cursor[i][INDEX_Y] = prev_line_height; |
457 | cursor[i][INDEX_X] = j; | 458 | cursor[i][INDEX_X] = j; |
458 | j += width + separator_width; | 459 | j += width + separator_width; |
459 | } | 460 | } |
@@ -527,15 +528,7 @@ bool set_time_screen(const char* title, struct tm *tm) | |||
527 | break; | 528 | break; |
528 | } | 529 | } |
529 | 530 | ||
530 | #ifdef HAVE_TOUCHSCREEN | ||
531 | enum touchscreen_mode old_mode = touchscreen_get_mode(); | ||
532 | |||
533 | touchscreen_set_mode(TOUCHSCREEN_BUTTON); | ||
534 | #endif | ||
535 | button = get_action(CONTEXT_SETTINGS_TIME, TIMEOUT_BLOCK); | 531 | button = get_action(CONTEXT_SETTINGS_TIME, TIMEOUT_BLOCK); |
536 | #ifdef HAVE_TOUCHSCREEN | ||
537 | touchscreen_set_mode(old_mode); | ||
538 | #endif | ||
539 | switch ( button ) { | 532 | switch ( button ) { |
540 | case ACTION_STD_PREV: | 533 | case ACTION_STD_PREV: |
541 | cursorpos = clamp_value_wrap(--cursorpos, 5, 0); | 534 | cursorpos = clamp_value_wrap(--cursorpos, 5, 0); |
@@ -567,11 +560,16 @@ bool set_time_screen(const char* title, struct tm *tm) | |||
567 | 560 | ||
568 | default: | 561 | default: |
569 | if (default_event_handler(button) == SYS_USB_CONNECTED) | 562 | if (default_event_handler(button) == SYS_USB_CONNECTED) |
570 | return true; | 563 | done = usb = true; |
571 | break; | 564 | break; |
572 | } | 565 | } |
573 | } | 566 | } |
574 | return false; | 567 | FOR_NB_SCREENS(s) |
568 | screens[s].scroll_stop(&viewports[s]); | ||
569 | #ifdef HAVE_TOUCHSCREEN | ||
570 | touchscreen_set_mode(old_mode); | ||
571 | #endif | ||
572 | return usb; | ||
575 | } | 573 | } |
576 | #endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */ | 574 | #endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */ |
577 | 575 | ||