1 /* This is a small demo of the high-performance GUIX graphics framework. */ 2 3 #include "demo_guix_washing_machine.h" 4 5 #define MIN_TEMPERATURE 30 6 #define MAX_TEMPERATURE 90 7 8 /******************************************************************************************/ 9 /* Implement radial slider animation callback function. */ 10 /******************************************************************************************/ temperature_slider_animation_callback(GX_RADIAL_SLIDER * slider)11VOID temperature_slider_animation_callback(GX_RADIAL_SLIDER* slider) 12 { 13 INT temperature; 14 GX_RADIAL_SLIDER_INFO* info = &temperature_window.temperature_window_temperature_slider.gx_radial_slider_info; 15 16 /* Convert angle value to temperature value. */ 17 temperature = (info->gx_radial_slider_info_current_angle - info->gx_radial_slider_info_min_angle) * 18 (MAX_TEMPERATURE - MIN_TEMPERATURE) / 19 (info->gx_radial_slider_info_max_angle - info->gx_radial_slider_info_min_angle); 20 21 temperature = MAX_TEMPERATURE - temperature; 22 23 gx_numeric_prompt_value_set(&temperature_window.temperature_window_temperature_value, temperature); 24 gx_numeric_prompt_value_set(&main_screen.main_screen_temperature_value, temperature); 25 } 26 27 /******************************************************************************************/ 28 /* Override the default event processing of "temperature_window" to handle signals from */ 29 /* my child widgets. */ 30 /******************************************************************************************/ temperature_window_event_process(GX_WINDOW * window,GX_EVENT * event_ptr)31UINT temperature_window_event_process(GX_WINDOW* window, GX_EVENT* event_ptr) 32 { 33 34 switch (event_ptr->gx_event_type) 35 { 36 case GX_EVENT_SHOW: 37 { 38 gx_window_event_process(window, event_ptr); 39 GX_RADIAL_SLIDER *slider = &temperature_window.temperature_window_temperature_slider; 40 GX_RADIAL_SLIDER_INFO *info = &slider->gx_radial_slider_info; 41 INT angle = info->gx_radial_slider_info_current_angle; 42 43 /* Set temperature slider angle to max. */ 44 gx_radial_slider_angle_set(slider, info->gx_radial_slider_info_max_angle); 45 46 /* Start animation to move temperature slider angle from max to current temperature value. */ 47 gx_radial_slider_animation_start(&temperature_window.temperature_window_temperature_slider, angle); 48 } 49 break; 50 51 case GX_SIGNAL(ID_TEMPERATURE_SLIDER, GX_EVENT_SLIDER_VALUE): 52 53 /* Update temperature value. */ 54 temperature_slider_animation_callback(&temperature_window.temperature_window_temperature_slider); 55 break; 56 57 default: 58 return gx_window_event_process(window, event_ptr); 59 } 60 61 return 0; 62 } 63 64 /******************************************************************************************/ 65 /* Define custom temperature window draw function. */ 66 /******************************************************************************************/ temperature_window_draw(GX_WINDOW * window)67VOID temperature_window_draw(GX_WINDOW* window) 68 { 69 /* Draw window background. */ 70 gx_window_background_draw(window); 71 72 if (main_screen.main_screen_btn_play.gx_widget_style & GX_STYLE_BUTTON_PUSHED) 73 { 74 /* Draw animation wave in the center. */ 75 animation_wave_draw(window); 76 } 77 78 /* Draw child widgets. */ 79 gx_widget_children_draw(window); 80 }