PS_Fgen_FW  4da88f4073c1cc65ea45c3a652a2751e495e50db
Firmware for an Power Supply and Function Generator build from an ATX power supply
Loading...
Searching...
No Matches
UserInputHandler.h
Go to the documentation of this file.
1
7
8#ifndef USERINPUTHANDLER_H_
9#define USERINPUTHANDLER_H_
10
11#include "CircularBuffer.h"
12#include "../KeyPad/KeyPad.h"
14#include "UI_Lib.h"
15#include <stdbool.h>
16
17#include "../Configuration.h"
18
31
36{
37 public:
39 Keys_t Key;
40 uint8_t UsartChr;
42 #ifdef TOUCH_ENABLED
43 uint16_t TouchX;
44 uint16_t TouchY;
45 TouchTypes TouchType;
46 #endif
47
51
57 UserInputData(Keys_t key) : Key(key)
58 {
60 }
61
67 UserInputData(uint8_t usartChr) : UsartChr(usartChr)
68 {
70 }
71
81
82 #ifdef TOUCH_ENABLED
90 UserInputData(uint16_t touchX, uint16_t touchY, TouchTypes touchType) : TouchX(touchX), TouchY(touchY), TouchType(touchType)
91 {
93 }
94 #endif
95};
96
97
102{
103 private:
105
106 public:
112 inline void EnqueueKeyInput(Keys_t userKeyInput)
113 {
114 if(!_userInputRingBuffer.full())
115 {
116 UserInputData keyInput(userKeyInput);
117 _userInputRingBuffer.enqueue(&keyInput);
118 }
119 }
120
126 inline void EnqueueUsartInput(uint8_t userDataInput)
127 {
128 if(!_userInputRingBuffer.full())
129 {
130 UserInputData dataInput(userDataInput);
131 _userInputRingBuffer.enqueue(&dataInput);
132 }
133 }
134
140 inline void EnqueueOnOffButtonInput(OnOffButtons_t userButtonInput)
141 {
142 if(!_userInputRingBuffer.full())
143 {
144 UserInputData buttonInput(userButtonInput);
145 _userInputRingBuffer.enqueue(&buttonInput);
146 }
147 }
148
149 #ifdef TOUCH_ENABLED
157 inline void EnqueueTouchInput(uint16_t touchX, uint16_t touchY, TouchTypes touchType)
158 {
159 if(!_userInputRingBuffer.full())
160 {
161 UserInputData touchInput(touchX, touchY, touchType);
162 _userInputRingBuffer.enqueue(&touchInput);
163 }
164 }
165 #endif
166
171 void ProcessInputs();
172};
173
174#endif /* USERINPUTHANDLER_H_ */
Containing a class implementing a circular buffer (for queue functionality).
Containing different defines for device configuration.
Containing a function to check which key of the KeyPad is pressed.
Containing methods to handle on/off buttons.
enum OnOffButtons OnOffButtons_t
Enumeration with all available on/off buttons.
enum UserInputDataTypes UserInputDataTypes_t
Enum used to differentiate the user input types.
UserInputDataTypes
Enum used to differentiate the user input types.
Definition UserInputHandler.h:23
@ USERDATA_KEY
User data type for Keys.
Definition UserInputHandler.h:24
@ USERDATA_USART
User data type for USART input.
Definition UserInputHandler.h:25
@ USERDATA_TOUCH
User data type for touch input.
Definition UserInputHandler.h:28
@ USERDATA_ON_OFF_BUTTONS
User data type for on/off buttons.
Definition UserInputHandler.h:26
Class that is implementing a circular buffer (for queue functionality).
Definition CircularBuffer.h:22
Class that holds one user input made by keys (or encoder) or USART.
Definition UserInputHandler.h:36
uint8_t UsartChr
Character received via Usart if the DataType is USERDATA_USART.
Definition UserInputHandler.h:40
UserInputData(uint8_t usartChr)
Constructor for the UserInputData class.
Definition UserInputHandler.h:67
TouchTypes TouchType
Touch type if the DataType is USERDATA_TOUCH.
Definition UserInputHandler.h:45
uint16_t TouchY
Y touch position if the DataType is USERDATA_TOUCH.
Definition UserInputHandler.h:44
uint16_t TouchX
X touch position if the DataType is USERDATA_TOUCH.
Definition UserInputHandler.h:43
OnOffButtons_t OnOffButton
on/off button pressed by the user if the DataType is USERDATA_ON_OFF_BUTTONS
Definition UserInputHandler.h:41
Keys_t Key
Key pressed by the user if the DataType is USERDATA_KEY.
Definition UserInputHandler.h:39
UserInputDataTypes_t DataType
Type of the user input data.
Definition UserInputHandler.h:38
UserInputData(uint16_t touchX, uint16_t touchY, TouchTypes touchType)
Constructor for the UserInputData class.
Definition UserInputHandler.h:90
UserInputData()
Empty Constructor.
Definition UserInputHandler.h:49
UserInputData(Keys_t key)
Constructor for the UserInputData class.
Definition UserInputHandler.h:57
UserInputData(OnOffButtons_t button)
Constructor for the UserInputData class.
Definition UserInputHandler.h:77
Class used to enqueue and process user inputs.
Definition UserInputHandler.h:102
void EnqueueTouchInput(uint16_t touchX, uint16_t touchY, TouchTypes touchType)
Enqueue the given touch input into the circular buffer for later processing.
Definition UserInputHandler.h:157
void ProcessInputs()
Process all user inputs in the circular buffer until it is empty.
Definition UserInputHandler.cpp:13
void EnqueueOnOffButtonInput(OnOffButtons_t userButtonInput)
Enqueue the given on/off button into the circular buffer for later processing.
Definition UserInputHandler.h:140
void EnqueueUsartInput(uint8_t userDataInput)
Enqueue the given Usart character into the circular buffer for later processing.
Definition UserInputHandler.h:126
void EnqueueKeyInput(Keys_t userKeyInput)
Enqueue the given key into the circular buffer for later processing.
Definition UserInputHandler.h:112
CircularBuffer< UserInputData, USERINPUT_QUEUE_LENGTH > _userInputRingBuffer
Circular buffer holding all user inputs.
Definition UserInputHandler.h:104