1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* Copyright (c) 2026-present Eclipse ThreadX contributors |
4 |
|
|
* |
5 |
|
|
* This program and the accompanying materials are made available under the |
6 |
|
|
* terms of the MIT License which is available at |
7 |
|
|
* https://opensource.org/licenses/MIT. |
8 |
|
|
* |
9 |
|
|
* SPDX-License-Identifier: MIT |
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 |
|
|
/**************************************************************************/ |
64 |
|
|
|
65 |
|
1658 |
UINT _gx_circular_gauge_angle_increment_calculate(GX_CIRCULAR_GAUGE *gauge) |
66 |
|
|
{ |
67 |
|
|
GX_CIRCULAR_GAUGE_INFO *info; |
68 |
|
|
INT delay; |
69 |
|
|
|
70 |
|
|
/* Get gauge info. */ |
71 |
|
1658 |
info = &gauge -> gx_circular_gauge_info; |
72 |
|
|
|
73 |
|
|
/* Calculate total increments. */ |
74 |
|
1658 |
gauge -> gx_circular_gauge_start_angle = gauge -> gx_circular_gauge_current_angle; |
75 |
|
|
|
76 |
|
1658 |
gauge -> gx_circular_gauge_angle_increment = GX_FIXED_VAL_MAKE(gauge -> gx_circular_gauge_target_angle - |
77 |
|
|
gauge -> gx_circular_gauge_current_angle); |
78 |
|
1658 |
gauge -> gx_circular_gauge_animation_step = 0; |
79 |
|
|
|
80 |
|
|
/* Devide total increments by total steps. */ |
81 |
✓✓ |
1658 |
if ((gauge ->gx_widget_status & GX_STATUS_VISIBLE) && |
82 |
✓✓ |
1648 |
gauge -> gx_circular_gauge_angle_increment && |
83 |
✓✓ |
1607 |
info -> gx_circular_gauge_info_animation_steps > 0) |
84 |
|
|
{ |
85 |
|
27 |
gauge -> gx_circular_gauge_angle_increment /= info -> gx_circular_gauge_info_animation_steps; |
86 |
|
|
|
87 |
|
|
/* Start needle animation timer. */ |
88 |
|
27 |
delay = gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay; |
89 |
|
|
|
90 |
✓✓ |
27 |
if (delay <= 0) |
91 |
|
|
{ |
92 |
|
1 |
delay = GX_DEFAULT_CIRCULAR_GAUGE_ANIMATION_DELAY; |
93 |
|
1 |
gauge -> gx_circular_gauge_info.gx_circular_gauge_info_animation_delay = delay; |
94 |
|
|
} |
95 |
|
27 |
_gx_system_timer_start((GX_WIDGET *)gauge, GX_CIRCULAR_GAUGE_TIMER, (UINT)delay, (UINT)delay); |
96 |
|
|
} |
97 |
|
|
else |
98 |
|
|
{ |
99 |
|
1631 |
gauge -> gx_circular_gauge_current_angle = gauge -> gx_circular_gauge_target_angle; |
100 |
|
|
|
101 |
|
|
/* Mark dirty. */ |
102 |
✓✓ |
1631 |
if (gauge -> gx_widget_status & GX_STATUS_VISIBLE) |
103 |
|
|
{ |
104 |
|
1621 |
_gx_circular_gauge_needle_dirty_mark(gauge); |
105 |
|
|
} |
106 |
|
|
} |
107 |
|
|
|
108 |
|
1658 |
return GX_SUCCESS; |
109 |
|
|
} |
110 |
|
|
|