11NumericControl<T>::NumericControl(T* valuePointer,
const char* baseUnit, T minValue, T maxValue,
int numFractionalDigits,
void* controlContext,
void(*onValueChanged)(
void* controlContext),
VirtualKeys* virtualKeys, uint16_t locX, uint16_t locY, uint8_t maxStringBufferLength) :
NumericIndicator<T>(valuePointer, baseUnit, maxValue, numFractionalDigits, locX, locY, maxStringBufferLength)
49 uint16_t character_width, character_space_width, dot_width, minus_width;
50 UiManager.Gfx->getTextBounds(
"0", 0, 0,
nullptr,
nullptr, &character_width,
nullptr);
51 UiManager.Gfx->getTextBounds(
"00", 0, 0,
nullptr,
nullptr, &character_space_width,
nullptr);
52 character_space_width -= 2* character_width;
53 UiManager.Gfx->getTextBounds(
".", 0, 0,
nullptr,
nullptr, &dot_width,
nullptr);
54 UiManager.Gfx->getTextBounds(
"-", 0, 0,
nullptr,
nullptr, &minus_width,
nullptr);
55 dot_width += 2 * character_space_width;
58 uint16_t cursorXpos = this->
LocX + minus_width + 2 + character_space_width +
UiManager.ElementMargin +
UiManager.ElementPadding + cursorDigitIndex * (character_width + character_space_width) + (CurrentDigitPosition < this->
_unitPrefixPower ? dot_width : 0) - 1;
90 float divisor = pow(10, position);
91 uint32_t truncated = uint32_t((abs(number) / divisor) + 0.1f);
92 return truncated % 10;
146 if(touchWasOnEditIcon)
226 if(keyNum < 0 || keyNum > 9) {
return false; }
@ KEY6
Number 6 key.
Definition Keys.h:24
@ KEY2
Number 2 key.
Definition Keys.h:20
@ KEYOK
OK (Enter) key.
Definition Keys.h:36
@ KEY4
Number 4 key.
Definition Keys.h:22
@ KEY5
Number 5 key.
Definition Keys.h:23
@ KEYDOWN
Down arrow key.
Definition Keys.h:35
@ KEYMINUS
Minus (negate) key.
Definition Keys.h:31
@ KEY9
Number 9 key.
Definition Keys.h:27
@ KEY8
Number 8 key.
Definition Keys.h:26
@ KEYUP
Up arrow key.
Definition Keys.h:34
@ KEYLEFT
Left arrow key.
Definition Keys.h:32
@ KEY3
Number 3 key.
Definition Keys.h:21
@ KEY1
Number 1 key.
Definition Keys.h:19
@ KEYMILLI
Milli (/1000) key.
Definition Keys.h:29
@ KEY0
Number 0 key.
Definition Keys.h:18
@ KEYRIGHT
Right arrow key.
Definition Keys.h:33
@ KEY7
Number 7 key.
Definition Keys.h:25
@ KEYX1
x1 (*1) key
Definition Keys.h:30
@ KEYKILO
Kilo (*1000) key.
Definition Keys.h:28
enum Keys Keys_t
Available input keys.
uint8_t Keys_GetKeyNumInt(Keys_t key)
Get a number from the key for all numeric keys (KEY0 .
Definition Keys.cpp:7
Containing a class for a numeric control that is showing a numeric variable value and offers the poss...
TouchTypes
Available touch types.
Definition TouchTypes.h:13
@ TOUCH_LONG
Long touch.
Definition TouchTypes.h:15
@ TOUCH_NORMAL
Normal touch.
Definition TouchTypes.h:14
Containing icons for the UI_Lib.
#define icon_pencil_height
Height of the pencil icon.
Definition UI_Icons.h:24
#define icon_pencil_width
Width of the pencil icon.
Definition UI_Icons.h:23
Containing a class that is used to handle the drawing and key handling of all UI_Elements.
UI_Manager UiManager
Access object for the singleton instance of the UI_Manager.
Definition UI_Manager.cpp:7
@ UI_CONTROL
Control elements are used to show informations and offer the possibility to change some values.
Definition UIElementType.h:16
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
virtual void RecalculateDimensions() override
Recalculate the Height and Width of the UIElement.
Definition NumericIndicator.cpp:124
T _maxValue
Maximum value that can be shown by this numeric indicator.
Definition NumericIndicator.h:37
uint8_t _numFractionalDigits
Number of fractional digits that are shown by this indicator.
Definition NumericIndicator.h:38
uint8_t _numDigits
Number of digits calculated from the maxValue (_numFractionalDigits + numNonFractionalDigits).
Definition NumericIndicator.h:39
virtual void Draw(bool redraw) override
Method used for drawing of the NumericIndicator.
Definition NumericIndicator.cpp:81
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
T * _valuePointer
Pointer to the numeric variable that is shown by this indicator.
Definition NumericIndicator.h:35
int8_t _unitPrefixPower
Current display prefix power (m = -3, k = 3, M = 6)
Definition NumericIndicator.h:42
T _lastValueDraw
Last drawn numeric value.
Definition NumericIndicator.h:36
bool _lastDrawnVisible
The Visible value that was last drawn.
Definition UIElement.h:26
bool IsInEditMode
Is the UIElement in edit mode?
Definition UIElement.h:35
UIElementType Type
Element type (control, indicator, container)
Definition UIElement.h:29
bool HitTest(uint16_t x, uint16_t y)
Check if the given point (x, y) is inside this UIElement.
Definition UIElement.h:109
uint16_t Height
Drawing height of the UIElement.
Definition UIElement.h:33
uint16_t LocY
Y Location of the upper left corner of the UIElement.
Definition UIElement.h:31
bool Visible
The UIElement is only drawn if the visibility is set to true.
Definition UIElement.h:34
uint16_t Width
Drawing width of the UIElement.
Definition UIElement.h:32
uint16_t LocX
X Location of the upper left corner of the UIElement.
Definition UIElement.h:30
Class for a control that can be used to emulate key presses via touch inputs.
Definition VirtualKeys.h:18