summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/screens.c69
1 files changed, 45 insertions, 24 deletions
diff --git a/apps/screens.c b/apps/screens.c
index 8fad3eb260..42ea9f29c9 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -64,6 +64,7 @@
64#include "backdrop.h" 64#include "backdrop.h"
65#include "viewport.h" 65#include "viewport.h"
66#include "appevents.h" 66#include "appevents.h"
67#include "language.h"
67 68
68#ifdef HAVE_LCD_BITMAP 69#ifdef HAVE_LCD_BITMAP
69#include "bitmaps/usblogo.h" 70#include "bitmaps/usblogo.h"
@@ -532,29 +533,35 @@ static void say_time(int cursorpos, const struct tm *tm)
532#define INDEX_Y 1 533#define INDEX_Y 1
533 534
534#define SEPARATOR ":" 535#define SEPARATOR ":"
536
537#define IDX_HOURS 0
538#define IDX_MINUTES 1
539#define IDX_SECONDS 2
540#define IDX_YEAR 3
541#define IDX_MONTH 4
542#define IDX_DAY 5
543
544#define OFF_HOURS 0
545#define OFF_MINUTES 3
546#define OFF_SECONDS 6
547#define OFF_YEAR 9
548#define OFF_DAY 14
549
535bool set_time_screen(const char* title, struct tm *tm) 550bool set_time_screen(const char* title, struct tm *tm)
536{ 551{
537 bool done = false; 552 bool done = false;
538 int button;
539 unsigned int i, j, s;
540 int cursorpos = 0; 553 int cursorpos = 0;
541 unsigned int realyear;
542 unsigned int width;
543 unsigned int min, max;
544 unsigned int statusbar_height = 0; 554 unsigned int statusbar_height = 0;
545 unsigned int separator_width, weekday_width; 555 unsigned char offsets_ptr[] =
546 unsigned int prev_line_height; 556 { OFF_HOURS, OFF_MINUTES, OFF_SECONDS, OFF_YEAR, 0, OFF_DAY };
547 static unsigned char daysinmonth[] =
548 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
549 unsigned char buffer[20];
550 struct viewport viewports[NB_SCREENS];
551 int nb_lines;
552
553 /* 6 possible cursor possitions, 2 values stored for each: x, y */
554 unsigned int cursor[6][2];
555 557
556 int *valptr = NULL; 558 if (lang_is_rtl())
557 unsigned char *ptr[6]; 559 {
560 offsets_ptr[IDX_HOURS] = OFF_SECONDS;
561 offsets_ptr[IDX_SECONDS] = OFF_HOURS;
562 offsets_ptr[IDX_YEAR] = OFF_DAY;
563 offsets_ptr[IDX_DAY] = OFF_YEAR;
564 }
558 565
559 if(global_settings.statusbar) 566 if(global_settings.statusbar)
560 statusbar_height = STATUSBAR_HEIGHT; 567 statusbar_height = STATUSBAR_HEIGHT;
@@ -563,13 +570,18 @@ bool set_time_screen(const char* title, struct tm *tm)
563 say_time(cursorpos, tm); 570 say_time(cursorpos, tm);
564 571
565 while (!done) { 572 while (!done) {
573 int button;
574 unsigned int i, s, realyear, min, max;
575 unsigned char *ptr[6];
576 unsigned char buffer[20];
577 int *valptr = NULL;
578 static unsigned char daysinmonth[] =
579 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
580
566 /* for easy acess in the drawing loop */ 581 /* for easy acess in the drawing loop */
567 ptr[0] = buffer; /* hours */ 582 for (i = 0; i < 6; i++)
568 ptr[1] = buffer + 3; /* minutes */ 583 ptr[i] = buffer + offsets_ptr[i];
569 ptr[2] = buffer + 6; /* seconds */ 584 ptr[IDX_MONTH] = str(LANG_MONTH_JANUARY + tm->tm_mon); /* month name */
570 ptr[3] = buffer + 9; /* year */
571 ptr[4] = str(LANG_MONTH_JANUARY + tm->tm_mon); /* monthname */
572 ptr[5] = buffer + 14; /* day of month */
573 585
574 /* calculate the number of days in febuary */ 586 /* calculate the number of days in febuary */
575 realyear = tm->tm_year + 1900; 587 realyear = tm->tm_year + 1900;
@@ -602,8 +614,16 @@ bool set_time_screen(const char* title, struct tm *tm)
602 614
603 FOR_NB_SCREENS(s) 615 FOR_NB_SCREENS(s)
604 { 616 {
617 int pos, nb_lines;
618 unsigned int separator_width, weekday_width;
619 unsigned int j, width, prev_line_height;
620 struct viewport viewports[NB_SCREENS];
621 /* 6 possible cursor possitions, 2 values stored for each: x, y */
622 unsigned int cursor[6][2];
605 struct viewport *vp = &viewports[s]; 623 struct viewport *vp = &viewports[s];
606 struct screen *screen = &screens[s]; 624 struct screen *screen = &screens[s];
625 static unsigned char rtl_idx[] =
626 { IDX_SECONDS, IDX_MINUTES, IDX_HOURS, IDX_DAY, IDX_MONTH, IDX_YEAR };
607 627
608 viewport_set_defaults(vp, s); 628 viewport_set_defaults(vp, s);
609 screen->set_viewport(vp); 629 screen->set_viewport(vp);
@@ -653,12 +673,13 @@ bool set_time_screen(const char* title, struct tm *tm)
653 screen->putsxy(0, cursor[3][INDEX_Y], 673 screen->putsxy(0, cursor[3][INDEX_Y],
654 str(LANG_WEEKDAY_SUNDAY + tm->tm_wday)); 674 str(LANG_WEEKDAY_SUNDAY + tm->tm_wday));
655 675
676 pos = lang_is_rtl() ? rtl_idx[cursorpos] : cursorpos;
656 /* draw the selected item with drawmode set to 677 /* draw the selected item with drawmode set to
657 DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable 678 DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
658 items with drawmode DRMODE_SOLID */ 679 items with drawmode DRMODE_SOLID */
659 for(i=0; i<6; i++) 680 for(i=0; i<6; i++)
660 { 681 {
661 if (cursorpos == (int)i) 682 if (pos == (int)i)
662 vp->drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID); 683 vp->drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID);
663 684
664 screen->putsxy(cursor[i][INDEX_X], 685 screen->putsxy(cursor[i][INDEX_X],