GUIslice  0.16.0
Embedded GUI in C
XGraph.h
Go to the documentation of this file.
1 #ifndef _GUISLICE_EX_XGRAPH_H_
2 #define _GUISLICE_EX_XGRAPH_H_
3 
4 #include "GUIslice.h"
5 
6 
7 // =======================================================================
8 // GUIslice library extension: Graph control
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: Graph
46 // ============================================================================
47 
48 // Define unique identifier for extended element type
49 // - Select any number above GSLC_TYPE_BASE_EXTEND
50 #define GSLC_TYPEX_GRAPH GSLC_TYPE_BASE_EXTEND + 5
51 
52 
54 typedef enum {
59 
60 // Extended element data structures
61 // - These data structures are maintained in the gslc_tsElem
62 // structure via the pXData pointer
63 
65 typedef struct {
66  // Config
67  int16_t* pBuf;
68  uint8_t nMargin;
70  gslc_teXGraphStyle eStyle;
71 
72  uint16_t nBufMax;
73  bool bScrollEn;
74  uint16_t nScrollPos;
75 
76  uint16_t nWndHeight;
77  uint16_t nWndWidth;
78  int16_t nPlotValMax;
79  int16_t nPlotValMin;
80  uint16_t nPlotIndMax;
81 
82  // Current status
83  uint16_t nBufCnt;
84  uint16_t nPlotIndStart;
85 
87 
88 
89 
106 gslc_tsElemRef* gslc_ElemXGraphCreate(gslc_tsGui* pGui,int16_t nElemId,int16_t nPage,
107  gslc_tsXGraph* pXData,gslc_tsRect rElem,int16_t nFontId,int16_t* pBuf,
108  uint16_t nBufRows,gslc_tsColor colGraph);
109 
121  gslc_teXGraphStyle eStyle,uint8_t nMargin);
122 
134  int16_t nYMin,int16_t nYMax);
135 
146 bool gslc_ElemXGraphDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw);
147 
156 void gslc_ElemXGraphAdd(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,int16_t nVal);
157 
158 
170 void gslc_ElemXGraphScrollSet(gslc_tsGui* pGui,gslc_tsElemRef* pElemRef,uint8_t nScrollPos,uint8_t nScrollMax);
171 
172 
173 // ============================================================================
174 
175 // ------------------------------------------------------------------------
176 // Read-only element macros
177 // ------------------------------------------------------------------------
178 
179 // Macro initializers for Read-Only Elements in Flash/PROGMEM
180 //
181 
182 #ifdef __cplusplus
183 }
184 #endif // __cplusplus
185 #endif // _GUISLICE_EX_XGRAPH_H_
186 
gslc_teXGraphStyle
Gauge drawing style.
Definition: XGraph.h:54
Dot.
Definition: XGraph.h:55
Filled.
Definition: XGraph.h:57
uint16_t nScrollPos
Current scrollbar position.
Definition: XGraph.h:74
gslc_teRedrawType
Redraw types.
Definition: GUIslice.h:370
uint16_t nWndHeight
Visible window height.
Definition: XGraph.h:76
uint16_t nPlotIndStart
First row of current window.
Definition: XGraph.h:84
gslc_teXGraphStyle eStyle
Style of the graph.
Definition: XGraph.h:70
void gslc_ElemXGraphSetRange(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nYMin, int16_t nYMax)
Set the graph's drawing range.
Definition: XGraph.c:176
Line.
Definition: XGraph.h:56
bool gslc_ElemXGraphDraw(void *pvGui, void *pvElemRef, gslc_teRedrawType eRedraw)
Draw a Graph element on the screen.
Definition: XGraph.c:243
uint8_t nMargin
Margin for graph area within element rect.
Definition: XGraph.h:68
Rectangular region. Defines X,Y corner coordinates plus dimensions.
Definition: GUIslice.h:519
void gslc_ElemXGraphScrollSet(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint8_t nScrollPos, uint8_t nScrollMax)
Set the graph scroll position (nScrollPos) as a fraction of nScrollMax.
Definition: XGraph.c:195
gslc_tsElemRef * gslc_ElemXGraphCreate(gslc_tsGui *pGui, int16_t nElemId, int16_t nPage, gslc_tsXGraph *pXData, gslc_tsRect rElem, int16_t nFontId, int16_t *pBuf, uint16_t nBufRows, gslc_tsColor colGraph)
Create a Graph Element.
Definition: XGraph.c:70
uint16_t nWndWidth
Visible window width.
Definition: XGraph.h:77
uint16_t nPlotIndMax
Number of data points to show in window.
Definition: XGraph.h:80
uint16_t nBufMax
Maximum number of points in buffer.
Definition: XGraph.h:72
bool bScrollEn
Enable for scrollbar.
Definition: XGraph.h:73
Element reference structure.
Definition: GUIslice.h:578
void gslc_ElemXGraphSetStyle(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, gslc_teXGraphStyle eStyle, uint8_t nMargin)
Set the graph's additional drawing characteristics.
Definition: XGraph.c:155
int16_t * pBuf
Ptr to the data buffer (circular buffer))
Definition: XGraph.h:67
int16_t nPlotValMax
Visible window maximum value.
Definition: XGraph.h:78
void gslc_ElemXGraphAdd(gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nVal)
Add a value to the graph at the latest position.
Definition: XGraph.c:224
GUI structure.
Definition: GUIslice.h:716
Color structure. Defines RGB triplet.
Definition: GUIslice.h:534
int16_t nPlotValMin
Visible window minimum value.
Definition: XGraph.h:79
gslc_tsColor colGraph
Color of the graph.
Definition: XGraph.h:69
Extended data for Graph element.
Definition: XGraph.h:65
uint16_t nBufCnt
Number of points in buffer.
Definition: XGraph.h:83