GUIslice  0.16.0
Embedded GUI in C
XGlowball.h
Go to the documentation of this file.
1 #ifndef _GUISLICE_EX_XGLOWBALL_H_
2 #define _GUISLICE_EX_XGLOWBALL_H_
3 
4 #include "GUIslice.h"
5 
6 
7 // =======================================================================
8 // GUIslice library extension: XGlowball
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: Example template
46 // ============================================================================
47 
48 // Define unique identifier for extended element type
49 // - Select any number above GSLC_TYPE_BASE_EXTEND
50 #define GSLC_TYPEX_GLOW GSLC_TYPE_BASE_EXTEND + 24
51 
52 // Defines the attributes of each ring in the XGlowball gauge
53 typedef struct {
54  uint8_t nRad1; // Inner radius
55  uint8_t nRad2; // Outer radius
56  gslc_tsColor cCol; // Fill color
58 
59 // Extended element data structures
60 // - These data structures are maintained in the gslc_tsElem
61 // structure via the pXData pointer
62 
64 typedef struct {
65  // Config
66  int16_t nMidX;
67  int16_t nMidY;
69  uint8_t nNumRings;
70  // Style config
71  uint16_t nQuality;
72  int16_t nAngStart;
73  int16_t nAngEnd;
75  // State
76  int16_t nVal;
77  int16_t nValLast;
78  // Callbacks
80 
81 
96 gslc_tsElemRef* gslc_ElemXGlowballCreate(gslc_tsGui* pGui, int16_t nElemId, int16_t nPage,
97  gslc_tsXGlowball* pXData, int16_t nMidX, int16_t nMidY, gslc_tsXGlowballRing* pRings, uint8_t nNumRings);
98 
99 
110 bool gslc_ElemXGlowballDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw);
111 
112 // XGlowball draw helper routines
113 void drawXGlowballArc(gslc_tsGui* pGui, gslc_tsXGlowball* pGlowball, int16_t nMidX, int16_t nMidY, int16_t nRad1, int16_t nRad2, gslc_tsColor cArc, uint16_t nAngStart, uint16_t nAngEnd);
114 void drawXGlowballRing(gslc_tsGui* pGui, gslc_tsXGlowball* pGlowball, int16_t nMidX, int16_t nMidY, int16_t nVal, uint16_t nAngStart, uint16_t nAngEnd, bool bErase);
115 void drawXGlowball(gslc_tsGui* pGui, gslc_tsXGlowball* pGlowball, int16_t nMidX, int16_t nMidY, int16_t nVal, uint16_t nAngStart, uint16_t nAngEnd);
116 
117 void gslc_ElemXGlowballSetAngles(gslc_tsGui* pGui, gslc_tsElemRef* pElemRef, int16_t nAngStart, int16_t nAngEnd);
118 void gslc_ElemXGlowballSetVal(gslc_tsGui* pGui, gslc_tsElemRef* pElemRef, int16_t nVal);
119 void gslc_ElemXGlowballSetQuality(gslc_tsGui* pGui, gslc_tsElemRef* pElemRef, uint16_t nQuality);
121 
122 // ============================================================================
123 
124 // ------------------------------------------------------------------------
125 // Read-only element macros
126 // ------------------------------------------------------------------------
127 
128 // Macro initializers for Read-Only Elements in Flash/PROGMEM
129 //
130 
131 
132 #ifdef __cplusplus
133 }
134 #endif // __cplusplus
135 #endif // _GUISLICE_EX_XGLOWBALL_H_
136 
void drawXGlowball(gslc_tsGui *pGui, gslc_tsXGlowball *pGlowball, int16_t nMidX, int16_t nMidY, int16_t nVal, uint16_t nAngStart, uint16_t nAngEnd)
Definition: XGlowball.c:197
int16_t nMidX
Gauge midpoint X coord.
Definition: XGlowball.h:66
bool gslc_ElemXGlowballDraw(void *pvGui, void *pvElemRef, gslc_teRedrawType eRedraw)
Draw the XGlowball element on the screen.
Definition: XGlowball.c:291
uint8_t nRad2
Definition: XGlowball.h:55
int16_t nVal
Current value.
Definition: XGlowball.h:76
int16_t nAngStart
Starting angle (0..510 degrees)
Definition: XGlowball.h:72
gslc_teRedrawType
Redraw types.
Definition: GUIslice.h:370
int16_t nAngEnd
Ending angle (0..510 degrees)
Definition: XGlowball.h:73
gslc_tsColor cCol
Definition: XGlowball.h:56
gslc_tsColor colBg
Background color (for redraw)
Definition: XGlowball.h:74
int16_t nValLast
Previous value.
Definition: XGlowball.h:77
Extended data for Slider element.
Definition: XGlowball.h:64
uint16_t nQuality
Rendering quality (number of segments / rotation)
Definition: XGlowball.h:71
uint8_t nNumRings
Number of rings in definition.
Definition: XGlowball.h:69
int16_t nMidY
Gauge midpoint Y coord.
Definition: XGlowball.h:67
void drawXGlowballRing(gslc_tsGui *pGui, gslc_tsXGlowball *pGlowball, int16_t nMidX, int16_t nMidY, int16_t nVal, uint16_t nAngStart, uint16_t nAngEnd, bool bErase)
Definition: XGlowball.c:176
gslc_tsXGlowballRing * pRings
Ring definition array.
Definition: XGlowball.h:68
Element reference structure.
Definition: GUIslice.h:578
void gslc_ElemXGlowballSetColorBack(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_tsColor colBg)
Definition: XGlowball.c:269
void drawXGlowballArc(gslc_tsGui *pGui, gslc_tsXGlowball *pGlowball, int16_t nMidX, int16_t nMidY, int16_t nRad1, int16_t nRad2, gslc_tsColor cArc, uint16_t nAngStart, uint16_t nAngEnd)
Definition: XGlowball.c:147
void gslc_ElemXGlowballSetVal(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nVal)
Definition: XGlowball.c:214
void gslc_ElemXGlowballSetQuality(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint16_t nQuality)
Definition: XGlowball.c:251
Definition: XGlowball.h:53
uint8_t nRad1
Definition: XGlowball.h:54
GUI structure.
Definition: GUIslice.h:716
Color structure. Defines RGB triplet.
Definition: GUIslice.h:534
void gslc_ElemXGlowballSetAngles(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nAngStart, int16_t nAngEnd)
Definition: XGlowball.c:232
gslc_tsElemRef * gslc_ElemXGlowballCreate(gslc_tsGui *pGui, int16_t nElemId, int16_t nPage, gslc_tsXGlowball *pXData, int16_t nMidX, int16_t nMidY, gslc_tsXGlowballRing *pRings, uint8_t nNumRings)
Create a XGlowball element.
Definition: XGlowball.c:76