1 /* This is a small demo of the high-performance GUIX graphics framework. */
2
3 #include "demo_guix_car_infotainment.h"
4
5 /* Define local variables. */
6 static int call_duration_minute = 0;
7 static int call_duration_second = 0;
8
9 /******************************************************************************************/
10 /* Start recording call duration. */
11 /******************************************************************************************/
call_duration_start()12 static void call_duration_start()
13 {
14 call_duration_second = 0;
15 call_duration_minute = 0;
16 gx_numeric_prompt_value_set(&phone_screen.phone_screen_second, call_duration_second);
17 gx_numeric_prompt_value_set(&phone_screen.phone_screen_minute, call_duration_minute);
18 gx_system_timer_start(&phone_screen, TIMER_ID_CALL_DURATION, GX_TICKS_SECOND, GX_TICKS_SECOND);
19 }
20
21 /******************************************************************************************/
22 /* Update call duration. */
23 /******************************************************************************************/
call_duration_update()24 static void call_duration_update()
25 {
26 GX_RESOURCE_ID color_id;
27
28 call_duration_second++;
29
30 if (call_duration_second & 0x1)
31 {
32 color_id = GX_COLOR_ID_WHITE;
33 }
34 else
35 {
36 color_id = GX_COLOR_ID_GRAY;
37 }
38
39 gx_prompt_text_color_set(&phone_screen.phone_screen_second_colon, color_id, color_id, color_id);
40
41 gx_numeric_prompt_value_set(&phone_screen.phone_screen_second, call_duration_second);
42
43 if (call_duration_second == 60)
44 {
45 call_duration_second = 0;
46 call_duration_minute++;
47 gx_numeric_prompt_value_set(&phone_screen.phone_screen_minute, call_duration_minute);
48 }
49 }
50
51 /******************************************************************************************/
52 /* Stop recording call duration. */
53 /******************************************************************************************/
call_duration_end()54 static void call_duration_end()
55 {
56 gx_system_timer_stop(&phone_screen, TIMER_ID_CALL_DURATION);
57 }
58
59 /******************************************************************************************/
60 /* Override the default event processing of "phone_screen" to handle signals from my */
61 /* child widgets. */
62 /******************************************************************************************/
phone_screen_event_process(GX_WINDOW * window,GX_EVENT * event_ptr)63 UINT phone_screen_event_process(GX_WINDOW *window, GX_EVENT *event_ptr)
64 {
65 switch (event_ptr->gx_event_type)
66 {
67 case GX_EVENT_SHOW:
68 gx_widget_style_remove(&phone_screen.phone_screen_end_call_btn, GX_STYLE_BUTTON_PUSHED);
69 call_duration_start();
70 volume_screen_base_event_process(window, event_ptr);
71 break;
72
73 case GX_SIGNAL(ID_BTN_END_CALL, GX_EVENT_TOGGLE_ON):
74 call_duration_end();
75 break;
76
77 case GX_EVENT_TIMER:
78 if (event_ptr->gx_event_payload.gx_event_timer_id == TIMER_ID_CALL_DURATION)
79 {
80 call_duration_update();
81 }
82 else
83 {
84 volume_screen_base_event_process(window, event_ptr);
85 }
86 break;
87
88 default:
89 return volume_screen_base_event_process(window, event_ptr);
90 }
91
92 return 0;
93 }
94
95