1 /* This is a small demo of the high-performance GUIX graphics framework. */
2
3 #include "demo_guix_car_infotainment.h"
4
5 /* Define macros. */
6 #define RADIAL_PROGRESS_ANIMATION_TOTAL_STEPS 10
7 #define MAX_PROGRESS_VAL -360
8
9 /* Define local variables. */
10 static int radial_progress_animation_step = 0;
11 static int play_seconds = 30;
12
13 /******************************************************************************************/
14 /* Play music. */
15 /******************************************************************************************/
music_play_start()16 VOID music_play_start()
17 {
18 radial_progress_animation_step = 0;
19 gx_system_timer_start(&audio_screen, TIMER_ID_RADIAL_PROGRESS_ANIMATION, GX_TICKS_SECOND, GX_TICKS_SECOND);
20 }
21
22 /******************************************************************************************/
23 /* Stop music play. */
24 /******************************************************************************************/
music_play_stop()25 VOID music_play_stop()
26 {
27 gx_system_timer_stop(&audio_screen, 0);
28 }
29
30 /******************************************************************************************/
31 /* Update music play progress. */
32 /******************************************************************************************/
music_play_update()33 VOID music_play_update()
34 {
35 GX_RADIAL_PROGRESS_BAR *bar = &audio_screen.audio_screen_radial_progress_bar;
36 GX_VALUE val = bar->gx_radial_progress_bar_info.gx_radial_progress_bar_info_current_val;
37 if (val - 10 < MAX_PROGRESS_VAL)
38 {
39 val = 0;
40 play_seconds = 0;
41 }
42 else
43 {
44 val -= 3;
45
46 play_seconds++;
47 }
48
49 gx_numeric_prompt_value_set(&audio_screen.audio_screen_minute, play_seconds / 60);
50 gx_numeric_prompt_value_set(&audio_screen.audio_screen_second, play_seconds % 60);
51 gx_radial_progress_bar_value_set(bar, val);
52 }
53
54 /******************************************************************************************/
55 /* Start animation to slide in music information window. */
56 /******************************************************************************************/
slide_in_music_info_win()57 VOID slide_in_music_info_win()
58 {
59 GX_EVENT my_event;
60
61 memset(&my_event, 0, sizeof(GX_EVENT));
62 my_event.gx_event_target = (GX_WIDGET*)&audio_screen;
63 my_event.gx_event_type = USER_EVENT_SLIDE_IN_MUSIC_INFO_WIN;
64
65 gx_system_event_send(&my_event);
66 }
67
68 /******************************************************************************************/
69 /* Play next music. */
70 /******************************************************************************************/
music_next()71 VOID music_next()
72 {
73 slide_in_music_info_win();
74
75 /* Reset music play progress. */
76 play_seconds = 0;
77 gx_numeric_prompt_value_set(&audio_screen.audio_screen_minute, 0);
78 gx_numeric_prompt_value_set(&audio_screen.audio_screen_second, 0);
79 gx_radial_progress_bar_value_set(&audio_screen.audio_screen_radial_progress_bar, 0);
80 }
81
82 /******************************************************************************************/
83 /* Override the default event processing of "audio_screen" to handle signals from my */
84 /* child widgets. */
85 /******************************************************************************************/
audio_screen_event_process(GX_WINDOW * window,GX_EVENT * event_ptr)86 UINT audio_screen_event_process(GX_WINDOW *window, GX_EVENT *event_ptr)
87 {
88 switch (event_ptr->gx_event_type)
89 {
90 case GX_EVENT_SHOW:
91 /* Slide music informatin window. */
92 slide_in_music_info_win();
93
94 volume_screen_base_event_process(window, event_ptr);
95 break;
96
97 case GX_SIGNAL(ID_PLAY_BTN, GX_EVENT_TOGGLE_ON):
98 /* Play. */
99 music_play_start();
100 break;
101
102 case GX_SIGNAL(ID_PLAY_BTN, GX_EVENT_TOGGLE_OFF):
103 /* Pause. */
104 music_play_stop();
105 break;
106
107 case GX_SIGNAL(ID_PREVIOUS, GX_EVENT_CLICKED):
108 case GX_SIGNAL(ID_NEXT, GX_EVENT_CLICKED):
109 /* Next. */
110 music_next();
111 break;
112
113 case GX_EVENT_TIMER:
114 if (event_ptr->gx_event_payload.gx_event_timer_id == TIMER_ID_RADIAL_PROGRESS_ANIMATION)
115 {
116 /* Update music play progress. */
117 music_play_update();
118 }
119 else
120 {
121 volume_screen_base_event_process(window, event_ptr);
122 }
123 break;
124
125 default:
126 return volume_screen_base_event_process(window, event_ptr);
127 }
128
129 return 0;
130 }