1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** GUIX Component */ 17 /** */ 18 /** Circular Gauge Management (Circular Gauge) */ 19 /** */ 20 /**************************************************************************/ 21 22 #define GX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "gx_api.h" 28 #include "gx_circular_gauge.h" 29 #include "gx_system.h" 30 #include "gx_utility.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_circular_gauge_angle_increment_calculate PORTABLE C */ 38 /* 6.1 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function calcualtes needle angle increments for each step. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* circular_gauge Circular gauge control block */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* status Completion status */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* None */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* Application Code */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 68 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 69 /* resulting in version 6.1 */ 70 /* */ 71 /**************************************************************************/ 72 _gx_circular_gauge_angle_increment_calculate(GX_CIRCULAR_GAUGE * gauge)73UINT _gx_circular_gauge_angle_increment_calculate(GX_CIRCULAR_GAUGE *gauge) 74 { 75 GX_CIRCULAR_GAUGE_INFO *info; 76 INT delay; 77 78 /* Get gauge info. */ 79 info = &gauge -> gx_circular_gauge_info; 80 81 /* Calculate total increments. */ 82 gauge -> gx_circular_gauge_start_angle = gauge -> gx_circular_gauge_current_angle; 83 84 gauge -> gx_circular_gauge_angle_increment = GX_FIXED_VAL_MAKE(gauge -> gx_circular_gauge_target_angle - 85 gauge -> gx_circular_gauge_current_angle); 86 gauge -> gx_circular_gauge_animation_step = 0; 87 88 /* Devide total increments by total steps. */ 89 if ((gauge ->gx_widget_status & GX_STATUS_VISIBLE) && 90 gauge -> gx_circular_gauge_angle_increment && 91 info -> gx_circular_gauge_info_animation_steps > 0) 92 { 93 gauge -> gx_circular_gauge_angle_increment /= info -> gx_circular_gauge_info_animation_steps; 94 95 /* Start needle animation timer. */ 96 delay = gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay; 97 98 if (delay <= 0) 99 { 100 delay = GX_DEFAULT_CIRCULAR_GAUGE_ANIMATION_DELAY; 101 gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay = delay; 102 } 103 _gx_system_timer_start((GX_WIDGET *)gauge, GX_CIRCULAR_GAUGE_TIMER, (UINT)delay, (UINT)delay); 104 } 105 else 106 { 107 gauge -> gx_circular_gauge_current_angle = gauge -> gx_circular_gauge_target_angle; 108 109 /* Mark dirty. */ 110 if (gauge -> gx_widget_status & GX_STATUS_VISIBLE) 111 { 112 _gx_circular_gauge_needle_dirty_mark(gauge); 113 } 114 } 115 116 return GX_SUCCESS; 117 } 118 119