eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_gauge.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #ifndef __D4D_GAUGE_H
47 #define __D4D_GAUGE_H
48 
50 
51 /******************************************************************************
52 * D4D GAUGE setting constants
53 *
54 */
60 #ifndef D4D_GAUGE_HUB_RADIUS
61  #define D4D_GAUGE_HUB_RADIUS 3
62 #endif
63 
66 #ifndef D4D_COLOR_GAUG_HUB
67  #define D4D_COLOR_GAUG_HUB D4D_COLOR_DARK_RED
68 #endif
69 
72 #ifndef D4D_COLOR_GAUG_POINTER
73  #define D4D_COLOR_GAUG_POINTER D4D_COLOR_DARK_BLUE
74 #endif
75 
76 //********************* Gauge flags for its specific flags *****************
87 #define D4D_GAUGE_F_REDRAW_TEXT (0x01 << D4D_OBJECT_F_OBJECT_SHIFT)
88 #define D4D_GAUGE_F_HUB (0x02 << D4D_OBJECT_F_OBJECT_SHIFT)
89 #define D4D_GAUGE_F_THICK_POINTER (0x04 << D4D_OBJECT_F_OBJECT_SHIFT)
90 
91 
95 #ifndef D4D_GAUGE_F_DEFAULT
96  #define D4D_GAUGE_F_DEFAULT (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_TOUCHENABLE | D4D_GAUGE_F_REDRAW_TEXT | D4D_GAUGE_F_HUB)
97 #endif
98 
101 #ifndef D4D_GAUGE_TXT_PRTY_DEFAULT
102  #define D4D_GAUGE_TXT_PRTY_DEFAULT (D4D_ALIGN_H_CENTER_MASK | D4D_ALIGN_V_CENTER_MASK)
103 #endif
104 
107 #ifndef D4D_GAUGE_FNT_PRTY_DEFAULT
108  #define D4D_GAUGE_FNT_PRTY_DEFAULT ( 0 )
109 #endif
110 
112 /******************************************************************************
113 * D4D GAUGE setting public types
114 *
115 */
119 /**************************************************************************/
126 typedef void (*D4D_GAUGE_ON_CHANGE)(D4D_OBJECT* pThis);
127 
128 
133 
134 
136 typedef struct
137 {
143 
146 /******************************************************************************
147 * Private Types
148 ******************************************************************************/
149 
150 // gauge runtime data (always in RAM)
151 
152 typedef struct
153 {
154  D4D_GAUGE_VALUE value; // current value
155  D4D_GAUGE_VALUE valueLast; // last pointer value drawn
156  D4D_TREND trend; // trend of pointer move (D4D_CLOCK_WISE or D4D_ANTI_CLOCK_WISE)
157  D4D_GAUGE_LIMITS limits; // gauge runtime configuration
159 
160 // gauge configuration (in ROM by default)
161 
162 typedef struct
163 {
164  D4D_STRING textBuff; // gauge text
165  D4D_POINT txtOff; // text coordinates as offset from scrPos
166  D4D_POINT hubOff; // hub coordinates as offset from scrPos
167  D4D_COOR pointerLen; // lentgth of the pointer line
168  const D4D_BMP* pBmpBkgd; // gauge background bitmap
169 
171 
173 
174 } D4D_GAUGE;
175 
176 /******************************************************************************
177 * Macros
178 ******************************************************************************/
179 
180 // getting the GAUGE structure from general OBJECT
181 #define D4D_GET_GAUGE(pObj) ((D4D_GAUGE*)((pObj)->pParam))
182 
183 /******************************************************************************
184 * D4D GAUGE setting public macros
185 *
186 */
190 /**************************************************************************/
219 #define _D4D_DECLARE_GAUGE(type, name, text, x, y, cx, cy, radius, pMargin, pRelations, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
220  static D4D_GAUGE_DATA name##_data = {0, 1, D4D_CLOCK_WISE, {0, 100, 0, 0x7F } }; \
221  static D4D_STR_PROPERTIES name##_strPrties = { D4D_GAUGE_FNT_PRTY_DEFAULT, D4D_GAUGE_TXT_PRTY_DEFAULT}; \
222  static type D4D_GAUGE name##_params = \
223  { \
224  { text, D4D_TEXT_LEN(text), fontId, &name##_strPrties, D4D_OBJECT_MAX_TEXT_LEN(text), 0}, /* pText */ \
225  { tx, ty }, /* txtOff */ \
226  { kx, ky }, /* hubOff */ \
227  plen, /* pointerLen */ \
228  pBmp, /* pBmpBkgd */ \
229  onvalch, /* OnValueChanged */ \
230  &(name##_data) /* RAM-based data */ \
231  }; \
232  \
233  D4D_DECLARE_OBJECT(type, name, x, y, cx, cy, radius, pMargin, pRelations, pOnUsrMsg, &d4d_gaugeSysFunc, &(name##_params), flags, pUser, pScheme)
234 
235 
236 /**************************************************************************/
262 #define D4D_DECLARE_GAUGE(name, text, x, y, cx, cy, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
263  _D4D_DECLARE_GAUGE(D4D_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
264 
265 /**************************************************************************/
287 #define D4D_DECLARE_STD_GAUGE(name, text, x, y, cx, cy, tx, ty, kx, ky, plen, pBmp, fontId, onvalch) \
288  D4D_DECLARE_GAUGE(name, text, x, y, cx, cy, tx, ty, kx, ky, plen, (D4D_GAUGE_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
289 
290 // Rounded gauge definition
291 /**************************************************************************/
318 #define D4D_DECLARE_RGAUGE(name, text, x, y, cx, cy, radius, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
319  _D4D_DECLARE_GAUGE(D4D_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
320 
321 /**************************************************************************/
344 #define D4D_DECLARE_STD_RGAUGE(name, text, x, y, cx, cy, radius, tx, ty, kx, ky, plen, pBmp, fontId, onvalch) \
345  D4D_DECLARE_RGAUGE(name, text, x, y, cx, cy, radius, tx, ty, kx, ky, plen, (D4D_GAUGE_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
346 
347 
348 // IN RAM instantions macros
349 /**************************************************************************/
352 #define D4D_DECLARE_GAUGE_INRAM(name, text, x, y, cx, cy, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
353  _D4D_DECLARE_GAUGE(D4D_NO_CONST, name, text, x, y, cx, cy, 0, NULL, NULL, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
354 
355 /**************************************************************************/
358 #define D4D_DECLARE_STD_GAUGE_INRAM(name, text, x, y, cx, cy, tx, ty, kx, ky, plen, pBmp, fontId, onvalch) \
359  D4D_DECLARE_GAUGE_INRAM(name, text, x, y, cx, cy, tx, ty, kx, ky, plen, (D4D_GAUGE_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
360 
361 // Rounded gauge definition
362 /**************************************************************************/
365 #define D4D_DECLARE_RGAUGE_INRAM(name, text, x, y, cx, cy, radius, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg) \
366  _D4D_DECLARE_GAUGE(D4D_NO_CONST, name, text, x, y, cx, cy, radius, NULL, NULL, tx, ty, kx, ky, plen, flags, pBmp, pScheme, fontId, pUser, onvalch, pOnUsrMsg)
367 
368 /**************************************************************************/
371 #define D4D_DECLARE_STD_RGAUGE_INRAM(name, text, x, y, cx, cy, radius, tx, ty, kx, ky, plen, pBmp, fontId, onvalch) \
372  D4D_DECLARE_RGAUGE_INRAM(name, text, x, y, cx, cy, radius, tx, ty, kx, ky, plen, (D4D_GAUGE_F_DEFAULT), pBmp, NULL, fontId, NULL, onvalch, NULL)
373 
375 /******************************************************************************
376 * Global variables
377 ******************************************************************************/
378 
379 
380 /******************************************************************************
381 * Global functions
382 ******************************************************************************/
383 
384 /*********************************************************
385 *
386 * global functions
387 *
388 *********************************************************/
389 
392 
393 void D4D_GaugSetLimits(D4D_OBJECT_PTR pThis, const D4D_GAUGE_LIMITS* pLimits);
395 
396 void D4D_GaugSetDir(D4D_OBJECT_PTR pThis, D4D_TREND direction);
398 
399 
400 // Obsolete functions, replaced by any general
401 #define D4D_GaugeSetText D4D_SetText
402 
403 
404 
405 
406 #endif /* __D4D_GAUGE_H */
407 
408 
409 
410 
Type definition of eGUI point structure.
Definition: d4d_types.h:223
Byte D4D_GAUGE_ANGLE
The gauge angle variable, is used to set up limits of gauge angle &lt;0-FF == 0° - 359°&gt;.
Definition: d4d_gauge.h:132
void D4D_GaugSetDir(D4D_OBJECT_PTR pThis, D4D_TREND trend)
The function set the trend/direction of gauge.
Definition: d4d_gauge.c:325
The string type. This structure contains all properties about string in eGUI.
Definition: d4d_string.h:100
D4D_GAUGE_ON_CHANGE OnValueChanged
Definition: d4d_gauge.h:170
The gauge limits structure that defines input value range and for this range specify the final angles...
Definition: d4d_gauge.h:136
D4D_GAUGE_DATA * pData
Definition: d4d_gauge.h:172
D4D_GAUGE_VALUE valueLast
Definition: d4d_gauge.h:155
D4D_GAUGE_VALUE value
Definition: d4d_gauge.h:154
D4D_GAUGE_ANGLE angleMin
line angle from 0x00 to 0xFF
Definition: d4d_gauge.h:140
D4D_TREND
Type definition of eGUI trend type.
Definition: d4d_types.h:316
D4D_GAUGE_VALUE D4D_GaugGetValue(D4D_OBJECT_PTR pThis)
The function gets the current value of gauge.
Definition: d4d_gauge.c:260
D4D_GAUGE_VALUE valueMin
minimal value (corresponds to angleMin)
Definition: d4d_gauge.h:138
const D4D_OBJECT_SYS_FUNCTION d4d_gaugeSysFunc
Definition: d4d_gauge.c:55
Byte D4D_COOR
Type definition of eGUI coordination variables.
Definition: d4d_types.h:219
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
void D4D_GaugSetLimits(D4D_OBJECT_PTR pThis, const D4D_GAUGE_LIMITS *pLimits)
The function sets the new limits values of gauge.
Definition: d4d_gauge.c:274
D4D_TREND trend
Definition: d4d_gauge.h:156
D4D_POINT hubOff
Definition: d4d_gauge.h:166
D4D_GAUGE_LIMITS limits
Definition: d4d_gauge.h:157
D4D_BMP eGUI main image structure.
Definition: d4d_bmp.h:100
void D4D_GaugSetValue(D4D_OBJECT_PTR pThis, D4D_GAUGE_VALUE value)
The function sets the new value of gauge.
Definition: d4d_gauge.c:234
D4D_GAUGE_VALUE valueMax
maximal value (corresponds to angleMax)
Definition: d4d_gauge.h:139
The object main structure type definition.
Definition: d4d_object.h:167
signed char sByte
Type definition of sByte (signed 8-bit).
Definition: d4d_types.h:155
The object system function needed for each object - this is part of D4D_OBJECT main structure...
Definition: d4d_object.h:134
D4D_COOR pointerLen
Definition: d4d_gauge.h:167
sByte D4D_GAUGE_VALUE
The gauge value variable, is used to hadle inputs of gauga functions API.
Definition: d4d_gauge.h:130
const D4D_BMP * pBmpBkgd
Definition: d4d_gauge.h:168
D4D_POINT txtOff
Definition: d4d_gauge.h:165
D4D_STRING textBuff
Definition: d4d_gauge.h:164
D4D_GAUGE_ANGLE angleMax
line angle from 0x00 to 0xFF
Definition: d4d_gauge.h:141
void D4D_GaugGetLimits(D4D_OBJECT_PTR pThis, D4D_GAUGE_LIMITS *pLimits)
The function gets the values of gauge limit structure.
Definition: d4d_gauge.c:312
D4D_TREND D4D_GaugGetDir(D4D_OBJECT_PTR pThis)
The function gets the trend/direction of gauge object.
Definition: d4d_gauge.c:348
void(* D4D_GAUGE_ON_CHANGE)(D4D_OBJECT *pThis)
Type definition of gauge on change callback function.
Definition: d4d_gauge.h:126