1 #include "demo_guix_smart_watch.h"
2
3 /* Define screen properties. */
4 static SCREEN_INFO screen_info_list[] = {
5 {(GX_WIDGET*)&message_screen, GX_PIXELMAP_ID_ICON_BELL, 0, GX_TRUE},
6 {(GX_WIDGET*)&music_screen, GX_PIXELMAP_ID_ICON_NOTE, 0, GX_TRUE},
7 {(GX_WIDGET*)&SanDiego_weather_screen, GX_PIXELMAP_ID_ICON_LOCATION, GX_STRING_ID_SAN_DIEGO, GX_FALSE},
8 {(GX_WIDGET*)&LosAngeles_weather_screen, GX_PIXELMAP_ID_ICON_LOCATION, GX_STRING_ID_LOS_ANGELES, GX_FALSE},
9 {(GX_WIDGET*)&SanFrancisco_weather_screen, GX_PIXELMAP_ID_ICON_LOCATION, GX_STRING_ID_SAN_FRANCISCO, GX_FALSE},
10 {(GX_WIDGET*)&yoga_screen, 0, GX_STRING_ID_YOGA, GX_TRUE},
11 {(GX_WIDGET*)&ekg_screen, 0, GX_STRING_ID_EKG, GX_TRUE},
12 {(GX_WIDGET*)&fitness_screen, 0, GX_STRING_ID_FITNESS, GX_FALSE},
13 {(GX_WIDGET*)&calories_screen, 0, GX_STRING_ID_CALORIES, GX_TRUE},
14 {(GX_WIDGET*)&run_screen, 0, GX_STRING_ID_RUN, GX_TRUE},
15 {(GX_WIDGET*)&stand_screen, 0, GX_STRING_ID_STAND, GX_TRUE},
16 {GX_NULL, 0, 0, 0}
17 };
18
19 /******************************************************************************************/
20 /* Update title bar clock. */
21 /******************************************************************************************/
update_title_clock(SCREEN_TEMPLATE_CONTROL_BLOCK * template)22 static VOID update_title_clock(SCREEN_TEMPLATE_CONTROL_BLOCK *template)
23 {
24 screen_clock_update(&template->screen_template_hour, &template->screen_template_minute, &template->screen_template_second);
25 }
26
27 /******************************************************************************************/
28 /* Initialize screen properties. */
29 /******************************************************************************************/
screens_initialize()30 VOID screens_initialize()
31 {
32 SCREEN_INFO* info = screen_info_list;
33 SCREEN_TEMPLATE_CONTROL_BLOCK* screen;
34
35 while (info->screen)
36 {
37 screen = (SCREEN_TEMPLATE_CONTROL_BLOCK*)info->screen;
38
39 /* Set title text. */
40 gx_prompt_text_id_set(&screen->screen_template_title, info->title_text_id);
41
42 /* Set title icon. */
43 if (info->title_icon_id)
44 {
45 gx_icon_pixelmap_set(&screen->screen_template_icon, info->title_icon_id, info->title_icon_id);
46 }
47 else
48 {
49 gx_widget_detach(&screen->screen_template_icon);
50 }
51
52 /* Set transparency style. */
53 if (!info->title_transparency)
54 {
55 gx_widget_style_remove(&screen->screen_template_title_bar, GX_STYLE_TRANSPARENT);
56 }
57
58 info++;
59 }
60
61 fitness_screen_initialize();
62 watch_screen_initialize();
63 }
64
65 /******************************************************************************************/
66 /* Override the default event processing of "screen_template" to handle signals from my */
67 /* child widgets. */
68 /******************************************************************************************/
screen_template_event_process(GX_WINDOW * window,GX_EVENT * event_ptr)69 UINT screen_template_event_process(GX_WINDOW *window, GX_EVENT* event_ptr)
70 {
71 switch (event_ptr->gx_event_type)
72 {
73 case GX_EVENT_SHOW:
74
75 clear_screen_clock_record();
76
77 /* Update title bar clock. */
78 update_title_clock((SCREEN_TEMPLATE_CONTROL_BLOCK *)window);
79
80 /* Start a timer to update title bar clock. */
81 gx_system_timer_start(window, SCREEN_CLOCK_TIMER_ID, GX_TICKS_SECOND, GX_TICKS_SECOND);
82
83 return gx_window_event_process(window, event_ptr);
84
85 case GX_EVENT_HIDE:
86
87 /* Stop clock update timer. */
88 gx_system_timer_stop(window, SCREEN_CLOCK_TIMER_ID);
89
90 return gx_window_event_process(window, event_ptr);
91
92 case GX_EVENT_TIMER:
93 if (event_ptr->gx_event_payload.gx_event_timer_id == SCREEN_CLOCK_TIMER_ID)
94 {
95 /* Update title bar clock. */
96 update_title_clock((SCREEN_TEMPLATE_CONTROL_BLOCK *)window);
97 }
98 break;
99
100 default:
101 return gx_window_event_process(window, event_ptr);
102 }
103
104 return 0;
105 }