mFrame
載入中...
搜尋中...
無符合項目
GpioButton.h
查看本檔案說明文件.
1
7#ifndef MFRAME_DC19082F_5FB1_4E3C_BBC8_C76487FFFC72
8#define MFRAME_DC19082F_5FB1_4E3C_BBC8_C76487FFFC72
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15#include "./../../hal/digital/GeneralInput.h"
16#include "./../lang/Object.h"
17#include "./../lang/Updatable.h"
18#include "./../util/ElapsedTimer.h"
19
20//----------------------------------------------------------------------------------------
21
22/* ***************************************************************************************
23 * Namespace
24 */
25namespace ufm::hw {
26 class GpioButton;
27} // namespace ufm::hw
28
29/* ***************************************************************************************
30 * Class/Interface/Struct/Enum
31 */
32
92 /* *************************************************************************************
93 * Class/Interface/Struct/Enum
94 */
95 public:
100 struct Event;
101 /* *************************************************************************************
102 * Variable
103 */
104 private:
107 Event* vEvent;
108 uint32 vDebounceMillicroseconds;
109 bool vLastRead = false;
110 bool vLastState = false;
111 bool vInverted = false;
112
113 /* *************************************************************************************
114 * Abstract Method
115 */
116
117 /* *************************************************************************************
118 * Construct Method
119 */
120 public:
139 uint32 debounceMillicroseconds = 5000,
140 bool inverted = false);
141
150 virtual ~GpioButton(void) override;
151
152 /* *************************************************************************************
153 * Operator Method
154 */
155
156 /* *************************************************************************************
157 * Override - ufm::lang::Updatable
158 */
159 public:
189 virtual void update(void) override;
190
191 /* *************************************************************************************
192 * Public Method
193 */
194 public:
223
258 GpioButton& setInverted(bool inverted);
259
260 /* *************************************************************************************
261 * Protected Method
262 */
263
264 /* *************************************************************************************
265 * Private Method
266 */
267
268 /* *************************************************************************************
269 * Static Variable
270 */
271
272 /* *************************************************************************************
273 * Static Method
274 */
275};
276
328 /* *************************************************************************************
329 * Method
330 */
331
355 virtual void onPressed(void) abstract;
356
380 virtual void onReleased(void) abstract;
381};
382
383/* ***************************************************************************************
384 * End of file
385 */
386
387#endif /* MFRAME_DC19082F_5FB1_4E3C_BBC8_C76487FFFC72 */
GPIO 按鈕控制類別
Definition GpioButton.h:91
virtual void update(void) override
更新按鈕狀態
GpioButton & setInverted(bool inverted)
設定按鈕邏輯反相
GpioButton & setEvent(Event *event)
設定事件處理器
GpioButton(hal::digital::GeneralInput &pin, uint32 debounceMillicroseconds=5000, bool inverted=false)
建構 GPIO 按鈕物件
virtual ~GpioButton(void) override
解構 GPIO 按鈕物件
物件基底類別
Definition Object.h:63
經過時間計時器,提供高精度的時間測量功能。
Definition ElapsedTimer.h:145
Definition Ammeter.h:22
[Interface] GPIO輸入控制介面。
Definition GeneralInput.h:39
按鈕事件處理介面
Definition GpioButton.h:327
virtual void onPressed(void) override
按鈕按下事件回調
virtual void onReleased(void) override
按鈕釋放事件回調
[Interface] 定義可更新的物件介面
Definition Updatable.h:38