summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/alarmclock.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/apps/plugins/alarmclock.c b/apps/plugins/alarmclock.c
index c8653dcd64..a691b61822 100644
--- a/apps/plugins/alarmclock.c
+++ b/apps/plugins/alarmclock.c
@@ -41,9 +41,23 @@ int rem_seconds(void) {
41 -(rb->get_time()->tm_sec)); 41 -(rb->get_time()->tm_sec));
42} 42}
43 43
44void draw(void) { 44void draw_centered_string(struct screen * display, char * string) {
45 int w, h;
46 display->getstringsize(string, &w, &h);
47
48 if (w > display->lcdwidth || h > display->lcdheight) {
49 rb->splash(0, string);
50 } else {
51 display->putsxy((display->lcdwidth - w) / 2,
52 (display->lcdheight - h) / 2,
53 string);
54 display->update();
55 }
56}
57
58void draw(struct screen * display) {
45 char info[128]; 59 char info[128];
46 rb->lcd_clear_display(); 60 display->clear_display();
47 61
48 int secs = rem_seconds(); 62 int secs = rem_seconds();
49 63
@@ -61,16 +75,7 @@ void draw(void) {
61 alarm[0], 75 alarm[0],
62 alarm[1]); 76 alarm[1]);
63 } 77 }
64 78 draw_centered_string(display, info);
65 int w, h;
66 rb->lcd_getstringsize(info, &w, &h);
67
68 if (w > LCD_WIDTH || h > LCD_HEIGHT)
69 rb->splash(0, info);
70 else {
71 rb->lcd_putsxy((LCD_WIDTH - w) / 2, (LCD_HEIGHT - h) / 2, info);
72 rb->lcd_update();
73 }
74} 79}
75 80
76bool can_play(void) { 81bool can_play(void) {
@@ -100,6 +105,7 @@ void play(void) {
100enum plugin_status plugin_start(const void* parameter) 105enum plugin_status plugin_start(const void* parameter)
101{ 106{
102 int button; 107 int button;
108 int i;
103 (void)parameter; 109 (void)parameter;
104 110
105 if (!can_play()) { 111 if (!can_play()) {
@@ -115,7 +121,9 @@ enum plugin_status plugin_start(const void* parameter)
115 if (button == PLA_QUIT) 121 if (button == PLA_QUIT)
116 quit = true; 122 quit = true;
117 123
118 draw(); 124 FOR_NB_SCREENS(i) {
125 draw(rb->screens[i]);
126 }
119 if (waiting) { 127 if (waiting) {
120 if (rem_seconds() <= 0) { 128 if (rem_seconds() <= 0) {
121 quit = done = true; 129 quit = done = true;