UI_Lib  a1366e08a59cc549a65fa26081e6409aa12f26d5
This is a user interface library for graphical LCDs. It offers many different controls and indicators that can be nested depending on the element types.
Loading...
Searching...
No Matches
NumericControl.h
Go to the documentation of this file.
1
5
6#ifndef NUMERICCONTROL_H_
7#define NUMERICCONTROL_H_
8
10#include "VirtualKeys.h"
11
16template <class T>
18{
19 private:
21
24
30 T coerceValue(T value);
31
39 uint8_t extractDigit(T number, int8_t position);
40
42 void(*_onValueChanged)(void* controlContext);
43
45
46 public:
48
63 NumericControl(T* valuePointer, const char* baseUnit, T minValue, T maxValue, int numFractionalDigits, void* controlContext = NULL, void(*onValueChanged)(void* controlContext) = NULL, VirtualKeys* virtualKeys = NULL, uint16_t locX = 0, uint16_t locY = 0, uint8_t maxStringBufferLength = DEFAULT_NUMERIC_INDICATOR_STRING_LENGTH);
64
68 virtual void Draw(bool redraw) override;
69
76 virtual bool KeyInput(Keys_t key) override;
77
85 virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType) override;
86
91 bool KeyKilo();
92
97 bool KeyMilli();
98
103 bool KeyMinus();
104
109 bool KeyX1();
110
115 bool KeyNumeric(Keys_t key);
116
121 bool ValueUp();
122
127 bool ValueDown();
128
133 bool CursorLeft();
134
139 bool CursorRight();
140
145 void ToggleEditMode();
146
150 virtual void RecalculateDimensions() override;
151};
152
153#endif /* NUMERICCONTROL_H_ */
enum Keys Keys_t
Available input keys.
Containing a class for a numeric indicator that is only showing a numeric variable value.
#define DEFAULT_NUMERIC_INDICATOR_STRING_LENGTH
Default max string length for a numeric indicator.
Definition NumericIndicator.h:11
TouchTypes
Available touch types.
Definition TouchTypes.h:13
Containing a class for a virtual keyboard.
bool KeyMilli()
Milli key is used to change the prefix to milli.
Definition NumericControl.cpp:178
T _minValue
Minimum value that can be handled by this numeric control.
Definition NumericControl.h:20
bool CursorLeft()
Left key is used to move the cursor position left.
Definition NumericControl.cpp:268
VirtualKeys * _virtualKeys
Pointer to a VirtualKeys UIElement.
Definition NumericControl.h:44
bool ValueDown()
Down key is used to decrement the digit at the current cursor position.
Definition NumericControl.cpp:254
NumericControl(T *valuePointer, const char *baseUnit, T minValue, T maxValue, int numFractionalDigits, void *controlContext=NULL, void(*onValueChanged)(void *controlContext)=NULL, VirtualKeys *virtualKeys=NULL, uint16_t locX=0, uint16_t locY=0, uint8_t maxStringBufferLength=DEFAULT_NUMERIC_INDICATOR_STRING_LENGTH)
Constructor of the NumericControl.
Definition NumericControl.cpp:11
virtual bool KeyInput(Keys_t key) override
Definition NumericControl.cpp:97
bool ValueUp()
Up key is used to increment the digit at the current cursor position.
Definition NumericControl.cpp:240
virtual void Draw(bool redraw) override
Method used for drawing of the NumericControl.
Definition NumericControl.cpp:23
virtual void RecalculateDimensions() override
Recalculate the Height and Width of the UIElement.
Definition NumericControl.cpp:302
bool KeyNumeric(Keys_t key)
Numeric keys (KEY0 .
Definition NumericControl.cpp:219
bool _lastDrawnEditMode
The EditMode that was last drawn.
Definition NumericControl.h:22
bool KeyMinus()
Minus key is used to toggle the sign of the controlled value.
Definition NumericControl.cpp:206
int8_t _lastDrawnCurrentDigitPosition
The CurrentDigitPosition that was last drawn.
Definition NumericControl.h:23
uint8_t extractDigit(T number, int8_t position)
Extract the digit at the requested position from the number.
Definition NumericControl.cpp:88
void(* _onValueChanged)(void *controlContext)
Function pointer for _onValueChanged event.
Definition NumericControl.h:42
T coerceValue(T value)
Limit the value to be between _minValue and _maxValue.
Definition NumericControl.cpp:80
bool KeyKilo()
Kilo key is used to change the prefix to kilo.
Definition NumericControl.cpp:164
void ToggleEditMode()
Toggle the control between display and edit mode.
Definition NumericControl.cpp:296
void * _controlContext
Context pointer that is returned with the _onValueChanged function pointer.
Definition NumericControl.h:41
bool CursorRight()
Right key is used to move the cursor position right.
Definition NumericControl.cpp:282
bool KeyX1()
X1 key is used to change the prefix to none.
Definition NumericControl.cpp:192
virtual bool TouchInput(uint16_t x, uint16_t y, TouchTypes touchType) override
Process a touch input at the given point (x, y)
Definition NumericControl.cpp:137
int8_t CurrentDigitPosition
Position of the currently controlled digit.
Definition NumericControl.h:47
NumericIndicator(T *valuePointer, const char *baseUnit, T maxValue, unsigned char numFractionalDigits, uint16_t locX=0, uint16_t locY=0, uint8_t maxStringBufferLength=DEFAULT_NUMERIC_INDICATOR_STRING_LENGTH)
Constructor of the NumericIndicator.
Definition NumericIndicator.cpp:69
Class for a control that can be used to emulate key presses via touch inputs.
Definition VirtualKeys.h:18