b6158d81cd3cf647179e9540e7d4a0cd98340a33
[oswald.git] / ui / oswald_screens.c
1 #include "oswald.h"
2 #include "oswald_watch_faces.h"
3 #include "Fonts.h"
4 #include "LcdDisplay.h"
5
6 #include "oswald_screens.h"
7
8 void idle_handle_user_buttons(watch_button button)
9 {
10 }
11 void idle_handle_events(u16t event, void *data)
12 {
13         switch (event) {
14                 case EVENT_ONE_SEC_TIMER:
15                 case EVENT_SCREEN_VISIBLE:
16                         DrawLcdDigitalClock();
17                         break;
18                 case EVENT_USER_BUTTONS:
19                         dbg_out("button event %d\n", *(int *)data);
20                         break;
21                 default:
22                         break;
23         };
24 }
25
26 void draw_accel_screen(void)
27 {
28         lcd_clear_display();
29         SetFont(MetaWatch16);
30         WriteLcdString(2, 2, "X:");
31         WriteLcdString(20, 2, "123");
32         WriteLcdString(2, 18, "Z:");
33         WriteLcdString(20, 18, "123");
34         WriteLcdString(2, 34, "Y:");
35         WriteLcdString(20, 34, "123");
36 }
37 void accel_handle_events(u16t event, void *data)
38 {
39         switch (event) {
40                 case EVENT_SCREEN_VISIBLE:
41                         draw_accel_screen();
42                         break;
43                 case EVENT_USER_BUTTONS:
44                         dbg_out("button event %d\n", *(int *)data);
45                         break;
46                 default:
47                         break;
48         };
49 }
50
51 void draw_datetime_setup_screen(void)
52 {
53         lcd_clear_display();
54         SetFont(MetaWatch16);
55         WriteLcdString(2, 2, "Date / Time");
56         WriteLcdString(2, 18, "Setting");
57         WriteLcdString(2, 34, "22:39");
58         WriteLcdString(2, 50, "07.08.2012");
59 }
60 void datetime_setup_events(u16t event, void *data)
61 {
62         switch (event) {
63                 case EVENT_SCREEN_VISIBLE:
64                         draw_datetime_setup_screen();
65                         break;
66                 case EVENT_USER_BUTTONS:
67                         dbg_out("button event %d\n", *(int *)data);
68                         break;
69                 default:
70                         break;
71         };
72 }
73
74 static u8t test_menu_pos = 0;
75
76 void draw_menu_test_screen(void)
77 {
78         lcd_clear_display();
79         SetFont(MetaWatch16);
80         WriteLcdString(2, 2, "Menu");
81         SetFont(MetaWatch7);
82         WriteLcdString(2, 20, "Item 1");
83         WriteLcdString(2, 29, "Item 2");
84         WriteLcdString(2, 38, "Item 3");
85         WriteLcdString(2, 47, "Item 4");
86         WriteLcdString(2, 56, "Item 5");
87
88         WriteLcdString(50, 20+(9*test_menu_pos), "*");
89 }
90
91 static void handle_menu_user_buttons(watch_button button)
92 {
93         switch (button) {
94                 case BUTTON_A:
95                         test_menu_pos--;
96                         test_menu_pos%=5;
97                         break;
98                 case BUTTON_B:
99                         test_menu_pos++;
100                         test_menu_pos%=5;
101                         break;
102                 default:
103                         break;
104         }
105         draw_menu_test_screen();
106 }
107
108 void test_menu_handle_events(u16t event, void *data)
109 {
110         switch (event) {
111                 case EVENT_USER_BUTTONS:
112                         dbg_out("button event %d\n", *(int *)data);
113                         handle_menu_user_buttons(*(watch_button *)data);
114                         break;
115                 case EVENT_SCREEN_VISIBLE:
116                         test_menu_pos = 0;
117                         draw_menu_test_screen();
118                         break;
119                 default:
120                         break;
121         };
122 }
123