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 /** System Management (System) */ 19 /** */ 20 /**************************************************************************/ 21 22 #define GX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "gx_api.h" 28 #include "gx_system.h" 29 30 /**************************************************************************/ 31 /* */ 32 /* FUNCTION RELEASE */ 33 /* */ 34 /* _gx_system_pen_speed_update PORTABLE C */ 35 /* 6.1 */ 36 /* AUTHOR */ 37 /* */ 38 /* Kenneth Maxwell, Microsoft Corporation */ 39 /* */ 40 /* DESCRIPTION */ 41 /* */ 42 /* This service sends the specified event for processing. */ 43 /* */ 44 /* INPUT */ 45 /* */ 46 /* event Pointer to event */ 47 /* */ 48 /* OUTPUT */ 49 /* */ 50 /* status Completion status */ 51 /* */ 52 /* CALLS */ 53 /* */ 54 /* GX_ABS Compute the absolute value */ 55 /* tx_queue_send Send message through ThreadX */ 56 /* queue */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* _gx_system_event_fold Fold GUIX system events */ 61 /* _gx_system_event_send Send GUIX system event */ 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 /**************************************************************************/ _gx_system_pen_speed_update(GX_POINT * current)72VOID _gx_system_pen_speed_update(GX_POINT *current) 73 { 74 ULONG current_clock; 75 76 #ifdef GX_THREADX_BINDING 77 current_clock = tx_time_get(); 78 #else 79 current_clock = GX_SYSTEM_TIME_GET; 80 #endif 81 82 _gx_system_clock_delta = (LONG)(current_clock - _gx_system_last_clock); 83 84 if (_gx_system_clock_delta > 0) 85 { 86 if (_gx_system_clock_delta < (LONG)_gx_system_pen_configuration.gx_pen_configuration_max_pen_speed_ticks) 87 { 88 _gx_system_pen_speed_x = GX_FIXED_VAL_MAKE(current -> gx_point_x - _gx_system_last_pen_point.gx_point_x); 89 _gx_system_pen_speed_x /= _gx_system_clock_delta; 90 _gx_system_pen_speed_y = GX_FIXED_VAL_MAKE(current -> gx_point_y - _gx_system_last_pen_point.gx_point_y); 91 _gx_system_pen_speed_y /= _gx_system_clock_delta; 92 } 93 else 94 { 95 _gx_system_pen_speed_x = _gx_system_pen_speed_y = 0; 96 } 97 _gx_system_last_clock = current_clock; 98 _gx_system_last_pen_point = *current; 99 } 100 } 101 102