GUIslice  0.16.0
Embedded GUI in C
XRingGauge.h
Go to the documentation of this file.
1 #ifndef _GUISLICE_EX_XRING_H_
2 #define _GUISLICE_EX_XRING_H_
3 
4 #include "GUIslice.h"
5 
6 
7 // =======================================================================
8 // GUIslice library extension: XRingGauge
9 // - Calvin Hass
10 // - https://www.impulseadventure.com/elec/guislice-gui.html
11 // - https://github.com/ImpulseAdventure/GUIslice
12 // =======================================================================
13 //
14 // The MIT License
15 //
16 // Copyright 2016-2020 Calvin Hass
17 //
18 // Permission is hereby granted, free of charge, to any person obtaining a copy
19 // of this software and associated documentation files (the "Software"), to deal
20 // in the Software without restriction, including without limitation the rights
21 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 // copies of the Software, and to permit persons to whom the Software is
23 // furnished to do so, subject to the following conditions:
24 //
25 // The above copyright notice and this permission notice shall be included in
26 // all copies or substantial portions of the Software.
27 //
28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 // THE SOFTWARE.
35 //
36 // =======================================================================
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif // __cplusplus
42 
43 
44 // ============================================================================
45 // Extended Element: XRingGauge
46 // - Creates display element similar to a donut-chart.
47 // - The element has an outer and inner radius to create a ring appearance.
48 // - The ring has an angular range defined by SetAngleRange, which means that
49 // the ring can be configured to cover a full circle or just a portion of
50 // a circle.
51 // - SetAngleRange defines the starting angle and direction of fill.
52 // - When drawing the ring within the angular range, it is composed of
53 // an active region (the angular region from the start to the current
54 // position value) and an inactive region (from the current value to the
55 // end of the angular range). The inactive region can be hidden (by
56 // setting it to the background color).
57 // - A text value can be drawn in the center of the ring, typically to
58 // show the current value. The color defined by SetColorBackground() is
59 // used when redrawing the text.
60 // ============================================================================
61 
62 // Define unique identifier for extended element type
63 // - Select any number above GSLC_TYPE_BASE_EXTEND
64 #define GSLC_TYPEX_RING GSLC_TYPE_BASE_EXTEND + 23
65 
66 
67 // Extended element data structures
68 // - These data structures are maintained in the gslc_tsElem
69 // structure via the pXData pointer
70 
71 #define XRING_STR_MAX 10
72 
74 typedef struct {
75  // Config
76  int16_t nValMin;
77  int16_t nValMax;
78 
79  int16_t nAngStart;
80  int16_t nAngRange;
81 
82  // Style config
83  int16_t nQuality;
84  int8_t nThickness;
85  bool bGradient;
86  uint8_t nSegGap;
90 
91  // State
92  int16_t nVal;
93  int16_t nValLast;
94  char acStrLast[XRING_STR_MAX];
95 
96  // Callbacks
97 
99 
100 
116 gslc_tsElemRef* gslc_ElemXRingGaugeCreate(gslc_tsGui* pGui, int16_t nElemId, int16_t nPage,
117  gslc_tsXRingGauge* pXData, gslc_tsRect rElem, char* pStrBuf, uint8_t nStrBufMax, int16_t nFontId);
118 
129 bool gslc_ElemXRingGaugeDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw);
130 
131 
148 void gslc_ElemXRingGaugeSetVal(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,int16_t nVal);
149 
174 void gslc_ElemXRingGaugeSetAngleRange(gslc_tsGui* pGui, gslc_tsElemRef* pElemRef, int16_t nStart, int16_t nRange, bool bClockwise);
175 
176 
188 void gslc_ElemXRingGaugeSetValRange(gslc_tsGui* pGui, gslc_tsElemRef* pElemRef, int16_t nValMin, int16_t nValMax);
189 
190 
201 void gslc_ElemXRingGaugeSetThickness(gslc_tsGui* pGui, gslc_tsElemRef* pElemRef, int8_t nThickness);
202 
217 void gslc_ElemXRingGaugeSetQuality(gslc_tsGui* pGui, gslc_tsElemRef* pElemRef, uint16_t nSegments);
218 
230 
240 
253 
254 // ============================================================================
255 
256 // ------------------------------------------------------------------------
257 // Read-only element macros
258 // ------------------------------------------------------------------------
259 
260 // Macro initializers for Read-Only Elements in Flash/PROGMEM
261 //
262 
263 
264 #ifdef __cplusplus
265 }
266 #endif // __cplusplus
267 #endif // _GUISLICE_EX_XRING_H_
268 
void gslc_ElemXRingGaugeSetQuality(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint16_t nSegments)
Sets the quality of the ring drawing by defining the number of segments that are used when rendering ...
Definition: XRingGauge.c:404
bool bGradient
Definition: XRingGauge.h:85
int16_t nValMax
Definition: XRingGauge.h:77
gslc_teRedrawType
Redraw types.
Definition: GUIslice.h:370
uint8_t nSegGap
Definition: XRingGauge.h:86
void gslc_ElemXRingGaugeSetValRange(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nValMin, int16_t nValMax)
Defines the range of values that may be passed into SetVal(), used to scale the input to SetVal()...
Definition: XRingGauge.c:324
void gslc_ElemXRingGaugeSetColorInactive(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_tsColor colInactive)
Defines the color of the inactive region to be a flat (constant) color.
Definition: XRingGauge.c:391
int16_t nValLast
Previous position value.
Definition: XRingGauge.h:93
int16_t nAngRange
Definition: XRingGauge.h:80
void gslc_ElemXRingGaugeSetColorActiveFlat(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_tsColor colActive)
Defines the color of the active region to be a flat (constant) color.
Definition: XRingGauge.c:364
int16_t nQuality
Definition: XRingGauge.h:83
void gslc_ElemXRingGaugeSetAngleRange(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nStart, int16_t nRange, bool bClockwise)
Defines the angular range of the gauge, including both the active and inactive regions.
Definition: XRingGauge.c:336
int16_t nVal
Current position value.
Definition: XRingGauge.h:92
int16_t nAngStart
Definition: XRingGauge.h:79
#define XRING_STR_MAX
Definition: XRingGauge.h:71
int8_t nThickness
Definition: XRingGauge.h:84
Rectangular region. Defines X,Y corner coordinates plus dimensions.
Definition: GUIslice.h:519
int16_t nValMin
Definition: XRingGauge.h:76
gslc_tsColor colRing1
Definition: XRingGauge.h:87
gslc_tsColor colRingRemain
Definition: XRingGauge.h:89
Extended data for XRingGauge element.
Definition: XRingGauge.h:74
Element reference structure.
Definition: GUIslice.h:578
gslc_tsColor colRing2
Definition: XRingGauge.h:88
void gslc_ElemXRingGaugeSetVal(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nVal)
Set an Ring Gauge current indicator value.
Definition: XRingGauge.c:300
gslc_tsElemRef * gslc_ElemXRingGaugeCreate(gslc_tsGui *pGui, int16_t nElemId, int16_t nPage, gslc_tsXRingGauge *pXData, gslc_tsRect rElem, char *pStrBuf, uint8_t nStrBufMax, int16_t nFontId)
Create an XRingGauge element.
Definition: XRingGauge.c:76
void gslc_ElemXRingGaugeSetColorActiveGradient(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_tsColor colStart, gslc_tsColor colEnd)
Defines the color of the active region to be a gradient using two color stops.
Definition: XRingGauge.c:377
bool gslc_ElemXRingGaugeDraw(void *pvGui, void *pvElemRef, gslc_teRedrawType eRedraw)
Draw the template element on the screen.
Definition: XRingGauge.c:144
GUI structure.
Definition: GUIslice.h:716
Color structure. Defines RGB triplet.
Definition: GUIslice.h:534
void gslc_ElemXRingGaugeSetThickness(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int8_t nThickness)
Defines the thickness of the ring arcs.
Definition: XRingGauge.c:353