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_widget.h" 29 #include "gx_system.h" 30 #include "gx_circular_gauge.h" 31 #include "gx_utility.h" 32 33 34 /**************************************************************************/ 35 /* */ 36 /* FUNCTION RELEASE */ 37 /* */ 38 /* _gx_circular_gauge_needle_rotate PORTABLE C */ 39 /* 6.1 */ 40 /* AUTHOR */ 41 /* */ 42 /* Kenneth Maxwell, Microsoft Corporation */ 43 /* */ 44 /* DESCRIPTION */ 45 /* */ 46 /* This function rotates the needle of the specified circular gauge. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* circular_gauge Circular gauge control block */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* status Completion status */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _gx_context_pixelmap_get Gets the pixelmap associated */ 59 /* the supplied resource ID. */ 60 /* _gx_utility_pixelmap_rotate Rotate a pixelmap. */ 61 /* */ 62 /* CALLED BY */ 63 /* */ 64 /* Application Code */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 71 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _gx_circular_gauge_needle_rotate(GX_CIRCULAR_GAUGE * gauge)75UINT _gx_circular_gauge_needle_rotate(GX_CIRCULAR_GAUGE *gauge) 76 { 77 UINT status = GX_SUCCESS; 78 GX_CIRCULAR_GAUGE_INFO *info; 79 INT xcor; 80 INT ycor; 81 82 83 /* Pick up pointer to the gauge information structure. */ 84 info = &gauge -> gx_circular_gauge_info; 85 86 if (gauge -> gx_circular_gauge_needle_source) 87 { 88 xcor = (INT)(info -> gx_circular_gauge_info_needle_xcor); 89 ycor = (INT)(info -> gx_circular_gauge_info_needle_ycor); 90 91 gauge -> gx_circular_gauge_current_needle_x = info -> gx_circular_gauge_info_needle_xpos; 92 gauge -> gx_circular_gauge_current_needle_y = info -> gx_circular_gauge_info_needle_ypos; 93 94 /* Rotate needle pixelmap. */ 95 96 status = _gx_utility_pixelmap_rotate(gauge -> gx_circular_gauge_needle_source, gauge -> gx_circular_gauge_current_angle, 97 &(gauge -> gx_circular_gauge_needle_rotated), 98 &xcor, &ycor); 99 100 if (status == GX_SUCCESS) 101 { 102 /* Calculate start position of needle pixelmap. */ 103 gauge -> gx_circular_gauge_current_needle_x = gauge -> gx_widget_size.gx_rectangle_left + info -> gx_circular_gauge_info_needle_xpos; 104 105 gauge -> gx_circular_gauge_current_needle_x -= xcor; 106 107 gauge -> gx_circular_gauge_current_needle_y = gauge -> gx_widget_size.gx_rectangle_top + info -> gx_circular_gauge_info_needle_ypos; 108 gauge -> gx_circular_gauge_current_needle_y -= ycor; 109 } 110 } 111 112 return status; 113 } 114 115 /**************************************************************************/ _gx_circular_gauge_needle_rotate_callback(VOID * gauge)116UINT _gx_circular_gauge_needle_rotate_callback(VOID *gauge) 117 { 118 return _gx_circular_gauge_needle_rotate((GX_CIRCULAR_GAUGE *)gauge); 119 } 120 121