... | ... |
@@ -2,7 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 |
2 | 2 |
|
3 | 3 |
bin_PROGRAMS = oswald-gui |
4 | 4 |
|
5 |
-oswald_gui_SOURCES = oswald-ui.c LcdDisplay.c Fonts.c oswald_main.c oswald_watch_faces.c oswald_strings.c oswald_screens.c |
|
5 |
+oswald_gui_SOURCES = oswald-ui.c LcdDisplay.c Fonts.c oswald_main.c oswald_watch_faces.c oswald_strings.c oswald_screens.c \ |
|
6 |
+embedvm.c |
|
6 | 7 |
oswald_gui_CFLAGS = -g $(GTK_CFLAGS) |
7 | 8 |
oswald_gui_LDADD = $(GTK_LIBS) |
8 | 9 |
|
... | ... |
@@ -254,7 +254,11 @@ gboolean one_second_tmo_handler (gpointer userdata) |
254 | 254 |
gboolean app_idle_handler (gpointer user_data) |
255 | 255 |
{ |
256 | 256 |
g_print("i"); |
257 |
- return TRUE; |
|
257 |
+ if (OswaldState.pending_idle) { |
|
258 |
+ // call Oswald's idle function |
|
259 |
+ return TRUE; |
|
260 |
+ }; |
|
261 |
+ return FALSE; |
|
258 | 262 |
} |
259 | 263 |
|
260 | 264 |
int main(int argc , char ** argv) |
... | ... |
@@ -67,18 +67,13 @@ typedef enum { |
67 | 67 |
typedef struct { |
68 | 68 |
u16t event_mask; // the event the screen wants to receive |
69 | 69 |
void (*event_func)(u16t event, void *data); // callback for events |
70 |
-// void (*button_func)(watch_button button); // handles button presses |
|
71 |
-// void (*screendraw_func)(void); // callback for screen update |
|
72 |
-// void *user_data; |
|
70 |
+ void *user_data; |
|
73 | 71 |
} watch_screen; |
74 | 72 |
|
75 | 73 |
typedef struct { |
76 | 74 |
screen_number screen_id; |
77 |
- // void (*draw_watchface_func)(boolean show_seconds); |
|
78 |
- boolean idle_show_seconds; |
|
79 | 75 |
watch_screen *screen; // the current screen |
80 |
- // void (*user_button_func)(watch_button button); |
|
81 |
- // void (*user_screendraw_func)(void); |
|
76 |
+ boolean pending_idle; |
|
82 | 77 |
} watch_state; |
83 | 78 |
|
84 | 79 |
#endif |
... | ... |
@@ -1,10 +1,9 @@ |
1 | 1 |
#include "oswald.h" |
2 | 2 |
#include "oswald_watch_faces.h" |
3 | 3 |
#include "oswald_screens.h" |
4 |
-#if 0 |
|
5 |
-#include "Fonts.h" |
|
6 |
-#include "LcdDisplay.h" |
|
7 |
-#endif |
|
4 |
+ |
|
5 |
+#include "embedvm.h" |
|
6 |
+ |
|
8 | 7 |
#include "oswald_main.h" |
9 | 8 |
|
10 | 9 |
/* |
... | ... |
@@ -99,7 +98,7 @@ void oswald_handle_button_press(watch_button button) |
99 | 98 |
|
100 | 99 |
void oswald_init(void) |
101 | 100 |
{ |
102 |
- OswaldScreens[IDLE_SCREEN].event_mask = EVENT_ONE_SEC_TIMER; |
|
101 |
+ OswaldScreens[IDLE_SCREEN].event_mask = EVENT_USER_BUTTONS | EVENT_ONE_SEC_TIMER; |
|
103 | 102 |
OswaldScreens[IDLE_SCREEN].event_func = idle_handle_events; |
104 | 103 |
|
105 | 104 |
OswaldScreens[ACCEL_DISPLAY_SCREEN].event_mask = EVENT_USER_BUTTONS; |
... | ... |
@@ -114,7 +113,6 @@ void oswald_init(void) |
114 | 113 |
|
115 | 114 |
OswaldState.screen_id = IDLE_SCREEN; |
116 | 115 |
OswaldState.screen = &OswaldScreens[OswaldState.screen_id]; |
117 |
- OswaldState.idle_show_seconds = FALSE; |
|
118 | 116 |
|
119 | 117 |
if (OswaldState.screen->event_func != NULL) |
120 | 118 |
OswaldState.screen->event_func(EVENT_SCREEN_VISIBLE, NULL); |
... | ... |
@@ -9,9 +9,14 @@ extern watch_screen OswaldScreens[]; |
9 | 9 |
|
10 | 10 |
/* gets triggered by OS timer function */ |
11 | 11 |
void oswald_one_second_tick(); |
12 |
+ |
|
13 |
+/* sets internal 'RTC' time */ |
|
12 | 14 |
void oswald_set_time(u8t hour, u8t minute, u8t second); |
13 | 15 |
|
14 | 16 |
void oswald_handle_button_press(watch_button button); |
17 |
+void oswald_handle_accel_event(u8t x, u8t y, u8t z); |
|
18 |
+void oswald_handle_ambientlight_event(u8t light_level); |
|
19 |
+void oswald_handle_idle_event(void); |
|
15 | 20 |
void oswald_init(void); |
16 | 21 |
|
17 | 22 |
#endif |
... | ... |
@@ -5,24 +5,58 @@ |
5 | 5 |
|
6 | 6 |
#include "oswald_screens.h" |
7 | 7 |
|
8 |
+typedef struct { |
|
9 |
+ void (*screendraw_func)(boolean shoq_seconds); |
|
10 |
+ boolean show_seconds; |
|
11 |
+ boolean analogue; |
|
12 |
+} idle_data_t; |
|
13 |
+static idle_data_t idle_screen = { |
|
14 |
+ DrawLcdDigitalClock, |
|
15 |
+ FALSE, |
|
16 |
+ FALSE, |
|
17 |
+}; |
|
18 |
+ |
|
8 | 19 |
void idle_handle_user_buttons(watch_button button) |
9 | 20 |
{ |
21 |
+ switch (button) { |
|
22 |
+ case BUTTON_D: |
|
23 |
+ if (idle_screen.show_seconds) |
|
24 |
+ idle_screen.show_seconds = FALSE; |
|
25 |
+ else |
|
26 |
+ idle_screen.show_seconds = TRUE; |
|
27 |
+ break; |
|
28 |
+ case BUTTON_E: |
|
29 |
+ if (idle_screen.analogue == TRUE) { |
|
30 |
+ idle_screen.analogue = FALSE; |
|
31 |
+ idle_screen.screendraw_func = DrawLcdDigitalClock; |
|
32 |
+ } else { |
|
33 |
+ idle_screen.analogue = TRUE; |
|
34 |
+ idle_screen.screendraw_func = DrawLcdAnaClock; |
|
35 |
+ }; |
|
36 |
+ break; |
|
37 |
+ default: |
|
38 |
+ break; |
|
39 |
+ }; |
|
40 |
+ idle_screen.screendraw_func(idle_screen.show_seconds); |
|
10 | 41 |
} |
42 |
+ |
|
11 | 43 |
void idle_handle_events(u16t event, void *data) |
12 | 44 |
{ |
13 | 45 |
switch (event) { |
14 | 46 |
case EVENT_ONE_SEC_TIMER: |
15 | 47 |
case EVENT_SCREEN_VISIBLE: |
16 |
- DrawLcdDigitalClock(); |
|
48 |
+ idle_screen.screendraw_func(idle_screen.show_seconds); |
|
17 | 49 |
break; |
18 | 50 |
case EVENT_USER_BUTTONS: |
19 | 51 |
dbg_out("button event %d\n", *(int *)data); |
52 |
+ idle_handle_user_buttons(*(watch_button *)data); |
|
20 | 53 |
break; |
21 | 54 |
default: |
22 | 55 |
break; |
23 | 56 |
}; |
24 | 57 |
} |
25 | 58 |
|
59 |
+ |
|
26 | 60 |
void draw_accel_screen(void) |
27 | 61 |
{ |
28 | 62 |
lcd_clear_display(); |
... | ... |
@@ -34,6 +68,7 @@ void draw_accel_screen(void) |
34 | 68 |
WriteLcdString(2, 34, "Y:"); |
35 | 69 |
WriteLcdString(20, 34, "123"); |
36 | 70 |
} |
71 |
+ |
|
37 | 72 |
void accel_handle_events(u16t event, void *data) |
38 | 73 |
{ |
39 | 74 |
switch (event) { |
... | ... |
@@ -48,6 +83,7 @@ void accel_handle_events(u16t event, void *data) |
48 | 83 |
}; |
49 | 84 |
} |
50 | 85 |
|
86 |
+ |
|
51 | 87 |
void draw_datetime_setup_screen(void) |
52 | 88 |
{ |
53 | 89 |
lcd_clear_display(); |
... | ... |
@@ -57,6 +93,7 @@ void draw_datetime_setup_screen(void) |
57 | 93 |
WriteLcdString(2, 34, "22:39"); |
58 | 94 |
WriteLcdString(2, 50, "07.08.2012"); |
59 | 95 |
} |
96 |
+ |
|
60 | 97 |
void datetime_setup_events(u16t event, void *data) |
61 | 98 |
{ |
62 | 99 |
switch (event) { |
... | ... |
@@ -71,7 +108,11 @@ void datetime_setup_events(u16t event, void *data) |
71 | 108 |
}; |
72 | 109 |
} |
73 | 110 |
|
74 |
-static u8t test_menu_pos = 0; |
|
111 |
+ |
|
112 |
+typedef struct { |
|
113 |
+ u8t menu_pos; |
|
114 |
+} test_menu_t; |
|
115 |
+static test_menu_t test_menu = { 0 }; |
|
75 | 116 |
|
76 | 117 |
void draw_menu_test_screen(void) |
77 | 118 |
{ |
... | ... |
@@ -85,19 +126,19 @@ void draw_menu_test_screen(void) |
85 | 126 |
WriteLcdString(2, 47, "Item 4"); |
86 | 127 |
WriteLcdString(2, 56, "Item 5"); |
87 | 128 |
|
88 |
- WriteLcdString(50, 20+(9*test_menu_pos), "*"); |
|
129 |
+ WriteLcdString(50, 20+(9*test_menu.menu_pos), "*"); |
|
89 | 130 |
} |
90 | 131 |
|
91 | 132 |
static void handle_menu_user_buttons(watch_button button) |
92 | 133 |
{ |
93 | 134 |
switch (button) { |
94 | 135 |
case BUTTON_A: |
95 |
- test_menu_pos--; |
|
96 |
- test_menu_pos%=5; |
|
136 |
+ test_menu.menu_pos--; |
|
137 |
+ test_menu.menu_pos%=5; |
|
97 | 138 |
break; |
98 | 139 |
case BUTTON_B: |
99 |
- test_menu_pos++; |
|
100 |
- test_menu_pos%=5; |
|
140 |
+ test_menu.menu_pos++; |
|
141 |
+ test_menu.menu_pos%=5; |
|
101 | 142 |
break; |
102 | 143 |
default: |
103 | 144 |
break; |
... | ... |
@@ -113,7 +154,7 @@ void test_menu_handle_events(u16t event, void *data) |
113 | 154 |
handle_menu_user_buttons(*(watch_button *)data); |
114 | 155 |
break; |
115 | 156 |
case EVENT_SCREEN_VISIBLE: |
116 |
- test_menu_pos = 0; |
|
157 |
+ test_menu.menu_pos = 0; |
|
117 | 158 |
draw_menu_test_screen(); |
118 | 159 |
break; |
119 | 160 |
default: |
... | ... |
@@ -1,16 +1,13 @@ |
1 | 1 |
#ifndef _OSWALD_SCREENS_H |
2 | 2 |
#define _OSWALD_SCREENS_H |
3 | 3 |
|
4 |
-void idle_handle_user_buttons(watch_button button); |
|
4 |
+ |
|
5 | 5 |
void idle_handle_events(u16t event, void *data); |
6 | 6 |
|
7 |
-void draw_accel_screen(void); |
|
8 | 7 |
void accel_handle_events(u16t event, void *data); |
9 | 8 |
|
10 |
-void draw_datetime_setup_screen(void); |
|
11 | 9 |
void datetime_setup_events(u16t event, void *data); |
12 | 10 |
|
13 |
-void draw_menu_test_screen(void); |
|
14 | 11 |
void test_menu_handle_events(u16t event, void *data); |
15 | 12 |
|
16 | 13 |
#endif |
... | ... |
@@ -8,7 +8,7 @@ |
8 | 8 |
|
9 | 9 |
#include "oswald_watch_faces.h" |
10 | 10 |
|
11 |
-void DrawLcdAnaClock(void) |
|
11 |
+void DrawLcdAnaClock(boolean show_seconds) |
|
12 | 12 |
{ |
13 | 13 |
unsigned char *bbuf; |
14 | 14 |
char daystr[5]; |
... | ... |
@@ -52,7 +52,7 @@ void DrawLcdAnaClock(void) |
52 | 52 |
tmp = 48 + (40. * sin(((2. * M_PI) / 60.) * (double)minute)); |
53 | 53 |
y = tmp; |
54 | 54 |
DrawLcdLineBresenhamWW(48, 48, x, y, 2); |
55 |
- if (OswaldState.idle_show_seconds) { |
|
55 |
+ if (show_seconds) { |
|
56 | 56 |
// Seconds |
57 | 57 |
tmp = 48. + (40. * cos(((2. * M_PI) / 60.) * (double)seconds)); |
58 | 58 |
x = tmp; |
... | ... |
@@ -65,7 +65,7 @@ void DrawLcdAnaClock(void) |
65 | 65 |
// mw_buf_print(mwbuf, 74, 45, daystr, 0, MW_WHITE, MW_BLACK); |
66 | 66 |
} |
67 | 67 |
|
68 |
-void DrawLcdDigitalClock(void) |
|
68 |
+void DrawLcdDigitalClock(boolean show_seconds) |
|
69 | 69 |
{ |
70 | 70 |
gint gRow = 3; |
71 | 71 |
gint gColumn = 4; |
... | ... |
@@ -79,7 +79,7 @@ void DrawLcdDigitalClock(void) |
79 | 79 |
gRow += WriteLcdCharacter(gRow, gColumn, TIME_CHARACTER_COLON_INDEX); |
80 | 80 |
gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.minute / 10)); |
81 | 81 |
gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.minute % 10)); |
82 |
- if (OswaldState.idle_show_seconds) { |
|
82 |
+ if (show_seconds) { |
|
83 | 83 |
gRow += WriteLcdCharacter(gRow, gColumn, TIME_CHARACTER_COLON_INDEX); |
84 | 84 |
gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.second / 10)); |
85 | 85 |
gRow += WriteLcdCharacter(gRow, gColumn, (OswaldClk.second % 10)); |