MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_circular_gauge.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
24 /*******************************************************************************
25  Module for Microchip Graphics Library - Legato User Interface Library
26 
27  Company:
28  Microchip Technology Inc.
29 
30  File Name:
31  legato_widget_circular_gauge.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements circular gauge drawing widget functions.
38 *******************************************************************************/
45 #ifndef LEGATO_WIDGET_CIRCULAR_GAUGE_H
46 #define LEGATO_WIDGET_CIRCULAR_GAUGE_H
47 
49 
50 #if LE_CIRCULARGAUGE_WIDGET_ENABLED == 1
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
60 
61 
62 // *****************************************************************************
63 // *****************************************************************************
64 // Section: Data Types and Constants
65 // *****************************************************************************
66 // *****************************************************************************
67 
68 typedef struct leCircularGaugeWidget leCircularGaugeWidget;
69 
70 
71 // *****************************************************************************
72 /* Function Pointer:
73  leCircularGaugeWidget_ValueChangedEvent
74 
75  Summary:
76  Value changed event function callback type
77 */
82 typedef void (* leCircularGaugeWidget_ValueChangedEvent)(leCircularGaugeWidget*,
83  int32_t value);
84 
85 
86 /* internal use only */
91 #define LE_CIRCULARGAUGEWIDGET_VTABLE(THIS_TYPE) \
92  LE_WIDGET_VTABLE(THIS_TYPE) \
93  \
94  uint32_t (*getRadius)(const THIS_TYPE* _this); \
95  leResult (*setRadius)(THIS_TYPE* _this, uint32_t rad); \
96  int32_t (*getStartAngle)(const THIS_TYPE* _this); \
97  leResult (*setStartAngle)(THIS_TYPE* _this, int32_t ang); \
98  int32_t (*getCenterAngle)(const THIS_TYPE* _this); \
99  leResult (*setCenterAngle)(THIS_TYPE* _this, int32_t ang); \
100  uint32_t (*getValue)(const THIS_TYPE* _this); \
101  leResult (*setValue)(THIS_TYPE* _this, uint32_t val); \
102  \
103  int32_t (*addArc)(THIS_TYPE* _this, uint32_t startAngle, uint32_t endAngle, int32_t offset, const leScheme* schm, uint32_t thk); \
104  leResult (*deleteArc)(THIS_TYPE* _this, uint32_t idx); \
105  leResult (*deleteAllArcs)(THIS_TYPE* _this); \
106  uint32_t (*arcCount)(const THIS_TYPE* _this); \
107  leBool (*getArcEnabled)(const THIS_TYPE* _this, uint32_t idx); \
108  leResult (*setArcEnabled)(THIS_TYPE* _this, uint32_t idx, leBool b); \
109  uint32_t (*getArcStartAngle)(const THIS_TYPE* _this, uint32_t idx); \
110  leResult (*setArcStartAngle)(THIS_TYPE* _this, uint32_t idx, uint32_t val); \
111  uint32_t (*getArcEndAngle)(const THIS_TYPE* _this, uint32_t idx); \
112  leResult (*setArcEndAngle)(THIS_TYPE* _this, uint32_t idx, uint32_t val); \
113  int32_t (*getArcOffset)(const THIS_TYPE* _this, uint32_t idx); \
114  leResult (*setArcOffset)(THIS_TYPE* _this, uint32_t idx, int32_t offs); \
115  const leScheme* (*getArcScheme)(const THIS_TYPE* _this, uint32_t idx); \
116  leResult (*setArcScheme)(THIS_TYPE* _this, uint32_t idx, const leScheme* schm); \
117  uint32_t (*getArcThickness)(const THIS_TYPE* _this, uint32_t idx); \
118  leResult (*setArcThickness)(THIS_TYPE* _this, uint32_t idx, uint32_t thk); \
119  \
120  int32_t (*addTickRange)(THIS_TYPE* _this, uint32_t startAngle, uint32_t endAngle, int32_t offset, const leScheme* schm, uint32_t thk, uint32_t div); \
121  leResult (*deleteTickRange)(THIS_TYPE* _this, uint32_t idx); \
122  leResult (*deleteAllTickRanges)(THIS_TYPE* _this); \
123  uint32_t (*tickRangeCount)(const THIS_TYPE* _this); \
124  leBool (*getTickRangeEnabled)(const THIS_TYPE* _this, uint32_t idx); \
125  leResult (*setTickRangeEnabled)(THIS_TYPE* _this, uint32_t idx, leBool b); \
126  uint32_t (*getTickRangeStartAngle)(const THIS_TYPE* _this, uint32_t idx); \
127  leResult (*setTickRangeStartAngle)(THIS_TYPE* _this, uint32_t idx, uint32_t val); \
128  uint32_t (*getTickRangeEndAngle)(const THIS_TYPE* _this, uint32_t idx); \
129  leResult (*setTickRangeEndAngle)(THIS_TYPE* _this, uint32_t idx, uint32_t val); \
130  int32_t (*getTickRangeOffset)(const THIS_TYPE* _this, uint32_t idx); \
131  leResult (*setTickRangeOffset)(THIS_TYPE* _this, uint32_t idx, int32_t offs); \
132  const leScheme* (*getTickRangeScheme)(const THIS_TYPE* _this, uint32_t idx); \
133  leResult (*setTickRangeScheme)(THIS_TYPE* _this, uint32_t idx, const leScheme* schm); \
134  uint32_t (*getTickRangeThickness)(const THIS_TYPE* _this, uint32_t idx); \
135  leResult (*setTickRangeThickness)(THIS_TYPE* _this, uint32_t idx, uint32_t thk); \
136  uint32_t (*getTickRangeDivisions)(const THIS_TYPE* _this, uint32_t idx); \
137  leResult (*setTickRangeDivisions)(THIS_TYPE* _this, uint32_t idx, uint32_t div); \
138  \
139  int32_t (*addLabelRange)(THIS_TYPE* _this, uint32_t startVal, uint32_t endVal, int32_t offset, const leScheme* schm, const leFont* fnt, uint32_t div); \
140  leResult (*deleteLabelRange)(THIS_TYPE* _this, uint32_t idx); \
141  leResult (*deleteAllLabelRanges)(THIS_TYPE* _this); \
142  uint32_t (*labelRangeCount)(const THIS_TYPE* _this); \
143  leBool (*getLabelRangeEnabled)(const THIS_TYPE* _this, uint32_t idx); \
144  leResult (*setLabelRangeEnabled)(THIS_TYPE* _this, uint32_t idx, leBool b); \
145  uint32_t (*getLabelRangeStartAngle)(const THIS_TYPE* _this, uint32_t idx); \
146  leResult (*setLabelRangeStartAngle)(THIS_TYPE* _this, uint32_t idx, uint32_t val); \
147  uint32_t (*getLabelRangeEndAngle)(const THIS_TYPE* _this, uint32_t idx); \
148  leResult (*setLabelRangeEndAngle)(THIS_TYPE* _this, uint32_t idx, uint32_t val); \
149  int32_t (*getLabelRangeOffset)(const THIS_TYPE* _this, uint32_t idx); \
150  leResult (*setLabelRangeOffset)(THIS_TYPE* _this, uint32_t idx, int32_t offs); \
151  const leScheme* (*getLabelRangeScheme)(const THIS_TYPE* _this, uint32_t idx); \
152  leResult (*setLabelRangeScheme)(THIS_TYPE* _this, uint32_t idx, const leScheme* schm); \
153  const leFont* (*getLabelRangeFont)(const THIS_TYPE* _this, uint32_t idx); \
154  leResult (*setLabelRangeFont)(THIS_TYPE* _this, uint32_t idx, const leFont* font); \
155  uint32_t (*getLabelRangeDivisions)(const THIS_TYPE* _this, uint32_t idx); \
156  leResult (*setLabelRangeDivisions)(THIS_TYPE* _this, uint32_t idx, uint32_t div); \
157  \
158  leBool (*getHandVisible)(const THIS_TYPE* _this); \
159  leResult (*setHandVisible)(THIS_TYPE* _this, leBool vis); \
160  uint32_t (*getHandRadius)(const THIS_TYPE* _this); \
161  leResult (*setHandRadius)(THIS_TYPE* _this, uint32_t rad); \
162  leBool (*getCenterCircleVisible)(const THIS_TYPE* _this); \
163  leResult (*setCenterCircleVisible)(THIS_TYPE* _this, leBool vis); \
164  uint32_t (*getCenterCircleRadius)(const THIS_TYPE* _this); \
165  leResult (*setCenterCircleRadius)(THIS_TYPE* _this, uint32_t rad); \
166  uint32_t (*getCenterCircleThickness)(const THIS_TYPE* _this); \
167  leResult (*setCenterCircleThickness)(THIS_TYPE* _this, uint32_t thk); \
168  leResult (*setValueChangedEventCallback)(THIS_TYPE* _this, leCircularGaugeWidget_ValueChangedEvent cb); \
169 
170 typedef struct leCircularGaugeWidgetVTable
171 {
172  LE_CIRCULARGAUGEWIDGET_VTABLE(leCircularGaugeWidget)
173 } leCircularGaugeWidgetVTable;
174 
180 // *****************************************************************************
181 /* Structure:
182  leCircularGaugeWidget
183 
184  Summary:
185  Implementation of a circular gauge widget.
186 
187  Description:
188  A circular gauge widget draws a circular gauge of the specified properties
189  inside the widget bounds. All coordinates are expressed in local widget space.
190 
191  Remarks:
192  None.
193 */
200 typedef struct leCircularGaugeWidget
201 {
202  leWidget widget; // base widget header
203 
204  const leCircularGaugeWidgetVTable* fn;
205 
206  //Widget properties
207  uint32_t value;
208  uint32_t radius; // the radius of the circular gauge
209  int32_t startAngle; //the start angle of the arc
210  int32_t centerAngle; //the center/span angle of the outer arc
211 
212  //hand properties
213  leBool handVisible;
214  uint32_t handRadius;
215  leBool centerCircleVisible;
216  uint32_t centerCircleRadius;
217  uint32_t centerCircleThickness;
218 
219  //Advanced config arrays
220  leArray arcsArray; //ArcsArray list
221  leArray ticksArray; //ArcsArray list
222  leArray labelsArray; //ArcsArray list
223 
224  leCircularGaugeWidget_ValueChangedEvent cb; //value changed event callback
225 } leCircularGaugeWidget;
226 
227 // *****************************************************************************
228 /* Structure:
229  leCircularGaugeArc
230 
231  Summary:
232  Internal structure for the arcs in the circular gauge widget
233 
234  Description:
235  Contains state values for a circular gauge arc
236 
237  Remarks:
238  None.
239 */
245 typedef struct leCircularGaugeArc
246 {
247  leBool enabled;
248  uint32_t startAngle;
249  uint32_t endAngle;
250  int32_t offset;
251  const leScheme* scheme;
252  uint32_t thickness;
253 } leCircularGaugeArc;
254 
255 // *****************************************************************************
256 /* Structure:
257  leCircularGaugeTickRange
258 
259  Summary:
260  Tick range for a circular gauge
261 
262  Description:
263  Contains properties of a circular gauge tick range
264 
265  Remarks:
266  None.
267 */
273 typedef struct leCircularGaugeTickRange
274 {
275  leBool enabled;
276  uint32_t startAngle;
277  uint32_t endAngle;
278  int32_t offset;
279  const leScheme* scheme;
280  uint32_t thickness;
281  uint32_t divisions;
282 } leCircularGaugeTickRange;
283 
284 // *****************************************************************************
285 /* Structure:
286  typedef struct leCircularGaugeLabel
287 
288  Summary:
289  Contains state values for a circular gauge label range
290 
291  Description:
292  Contains properties of the labels in the gauge
293 
294  Remarks:
295  None.
296 */
302 typedef struct leCircularGaugeLabelRange
303 {
304  leBool enabled;
305  uint32_t startAngle;
306  uint32_t endAngle;
307  int32_t offset;
308  const leScheme* scheme;
309  const leFont* font;
310  uint32_t divisions;
311 } leCircularGaugeLabelRange;
312 
313 // *****************************************************************************
314 // *****************************************************************************
315 // Section: Routines
316 // *****************************************************************************
317 // *****************************************************************************
318 
330 leCircularGaugeWidget* leCircularGaugeWidget_New(void);
331 
342 void leCircularGaugeWidget_Constructor(leCircularGaugeWidget* gauge);
343 
344 #ifdef _DOXYGEN_
345 #define THIS_TYPE struct leWidget
346 
347 // *****************************************************************************
358 virtual uint32_t getRadius(const leCircularGaugeWidget* _this);
359 
360 
361 // *****************************************************************************
362 /* Virtual Member Function:
363  leResult setRadius(leCircularGaugeWidget* _this,
364  uint32_t rad)
365 
366  Summary:
367  Sets the radius
368 
369  Description:
370  Sets the radius
371 
372  Parameters:
373  leCircularGaugeWidget* _this - The gauge to operate on
374  uint32_t rad - the radius value
375 
376  Remarks:
377  Usage - _this->fn->setRadius(_this, rad);
378 
379  Returns:
380  leResult - the result of the operation
381 */
395 virtual leResult setRadius(leCircularGaugeWidget* _this,
396  uint32_t rad);
397 
398 // *****************************************************************************
409 virtual int32_t getStartAngle(const leCircularGaugeWidget* _this);
410 
411 
412 // *****************************************************************************
426 virtual leResult setStartAngle(leCircularGaugeWidget* _this,
427  int32_t ang);
428 
429 // *****************************************************************************
440 virtual int32_t getCenterAngle(const leCircularGaugeWidget* _this);
441 
442 
443 // *****************************************************************************
457 virtual leResult setCenterAngle(leCircularGaugeWidget* _this,
458  int32_t ang);
459 
460 
461 
462 // *****************************************************************************
473 virtual leBool getHandVisible(const leCircularGaugeWidget* _this);
474 
475 // *****************************************************************************
489 virtual leResult setTickLabelsVisible(leCircularGaugeWidget* _this,
490  leBool vis);
491 
492 // *****************************************************************************
503 virtual leBool getHandVisible(const leCircularGaugeWidget* _this);
504 
505 // *****************************************************************************
519 virtual leResult setHandVisible(leCircularGaugeWidget* _this,
520  leBool vis);
521 
522 // *****************************************************************************
533 virtual uint32_t getHandRadius(const leCircularGaugeWidget* _this);
534 
535 // *****************************************************************************
549 virtual leResult setHandRadius(leCircularGaugeWidget* _this,
550  uint32_t rad);
551 
552 
553 // *****************************************************************************
564 virtual leBool getCenterCircleVisible(const leCircularGaugeWidget* _this);
565 
566 
567 // *****************************************************************************
581 virtual leResult setCenterCircleVisible(leCircularGaugeWidget* _this,
582  leBool vis);
583 
584 // *****************************************************************************
595 virtual uint32_t getCenterCircleRadius(const leCircularGaugeWidget* _this);
596 
597 
598 // *****************************************************************************
612 virtual leResult setCenterCircleRadius(leCircularGaugeWidget* _this,
613  uint32_t rad);
614 
615 
616 // *****************************************************************************
627 virtual uint32_t getCenterCircleThickness(const leCircularGaugeWidget* _this);
628 
629 
630 // *****************************************************************************
644 virtual leResult setCenterCircleThickness(leCircularGaugeWidget* _this,
645  uint32_t rad);
646 
660 virtual leResult setValueChangedEventCallback(leCircularGaugeWidget* _this,
661  leCircularGaugeWidget_ValueChangedEvent cb);
662 
663 #undef THIS_TYPE
664 #endif
665 
666 #ifdef __cplusplus
667 }
668 #endif
669 
670 #endif // LE_CIRCULARGAUGE_WIDGET_ENABLED
671 #endif /* LEGATO_WIDGET_CIRCULAR_GAUGE_H */
Common macros and definitions used by Legato.
virtual leResult setCenterAngle(THIS_TYPE *_this, int32_t angle)
Set center angle of an arc.
This struct represents a font object.
Definition: legato_font.h:156
virtual int32_t getCenterAngle(const leArcWidget *_this)
Get thickness of an arc.
leResult
This enum represents function call results.
Definition: legato_common.h:123
Dynamic string functions and definitions.
virtual leResult setStartAngle(leArcWidget *_this, int32_t angle)
Set start angle of an arc.
virtual uint32_t getRadius(const leArcWidget *_this)
Get radius of an arc.
This struct represents a array.
Definition: legato_array.h:64
Used to define a widget.
Definition: legato_widget.h:624
virtual leResult setRadius(leArcWidget *_this, uint32_t rad)
Set radius of an arc.
Legato widget definitions.
An array implementation for storing pointers.
leBool
This enum represents booleans.
Definition: legato_common.h:146
virtual int32_t getStartAngle(const leArcWidget *_this)
Get start angle of the arc.
Definition: scheme.py:1
Definition: legato_scheme.h:154
Schemes support various properties that make it possible to customize the color of widgets...
Definition: widget.py:1