M5Unit-KEYBOARD 0.0.1 git rev:a483db1
Loading...
Searching...
No Matches
unit_FacesQWERTY.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
3 *
4 * SPDX-License-Identifier: MIT
5 */
10#ifndef M5_UNIT_KEYBOARD_UNIT_FACES_QWERTY_HPP
11#define M5_UNIT_KEYBOARD_UNIT_FACES_QWERTY_HPP
12
13#include "unit_Keyboard.hpp"
14
15namespace m5 {
16namespace unit {
17
22namespace faces {
25constexpr uint8_t TYPE_QWERTY{0x01};
27} // namespace faces
28
34class UnitFacesQWERTY : public UnitKeyboardBitwise {
35 M5_UNIT_COMPONENT_HPP_BUILDER(UnitFacesQWERTY, 0x08);
36
37public:
38 static constexpr uint8_t NUMBER_OF_KEYS{35};
39
42 static constexpr keyboard::key_index_t KEY_Q{0};
43 static constexpr keyboard::key_index_t KEY_W{1};
44 static constexpr keyboard::key_index_t KEY_E{2};
45 static constexpr keyboard::key_index_t KEY_R{3};
46 static constexpr keyboard::key_index_t KEY_T{4};
47 static constexpr keyboard::key_index_t KEY_Y{5};
48 static constexpr keyboard::key_index_t KEY_U{6};
49 static constexpr keyboard::key_index_t KEY_I{7};
50 static constexpr keyboard::key_index_t KEY_O{8};
51 static constexpr keyboard::key_index_t KEY_P{9};
52 static constexpr keyboard::key_index_t KEY_A{10};
53 static constexpr keyboard::key_index_t KEY_S{11};
54 static constexpr keyboard::key_index_t KEY_D{12};
55 static constexpr keyboard::key_index_t KEY_F{13};
56 static constexpr keyboard::key_index_t KEY_G{14};
57 static constexpr keyboard::key_index_t KEY_H{15};
58 static constexpr keyboard::key_index_t KEY_J{16};
59 static constexpr keyboard::key_index_t KEY_K{17};
60 static constexpr keyboard::key_index_t KEY_L{18};
61 static constexpr keyboard::key_index_t KEY_BS{19};
62 static constexpr keyboard::key_index_t KEY_NO_KEY_ALT{20};
63 static constexpr keyboard::key_index_t KEY_Z{21};
64 static constexpr keyboard::key_index_t KEY_X{22};
65 static constexpr keyboard::key_index_t KEY_C{23};
66 static constexpr keyboard::key_index_t KEY_V{24};
67 static constexpr keyboard::key_index_t KEY_B{25};
68 static constexpr keyboard::key_index_t KEY_N{26};
69 static constexpr keyboard::key_index_t KEY_M{27};
70 static constexpr keyboard::key_index_t KEY_DOLLAR{28};
71 static constexpr keyboard::key_index_t KEY_ENTER{29};
72 static constexpr keyboard::key_index_t KEY_NO_KEY_SHIFT{30};
73 static constexpr keyboard::key_index_t KEY_0{31};
74 static constexpr keyboard::key_index_t KEY_SPACE{32};
75 static constexpr keyboard::key_index_t KEY_NO_KEY_SYM{33};
76 static constexpr keyboard::key_index_t KEY_NO_KEY_FN{34};
78
81 static constexpr char SCHAR_NOMARK_G{static_cast<char>(180)};
82 static constexpr char SCHAR_NOMARK_H{static_cast<char>(181)};
83 static constexpr char SCHAR_NOMARK_J{static_cast<char>(182)};
84 static constexpr char SCHAR_UP{static_cast<char>(183)};
85 static constexpr char SCHAR_INS{static_cast<char>(184)};
86 static constexpr char SCHAR_HOME{static_cast<char>(187)};
87 static constexpr char SCHAR_END{static_cast<char>(188)};
88 static constexpr char SCHAR_PAGE_UP{static_cast<char>(189)};
89 static constexpr char SCHAR_PAGE_DOWN{static_cast<char>(190)};
90 static constexpr char SCHAR_LEFT{static_cast<char>(191)};
91 static constexpr char SCHAR_DOWN{static_cast<char>(192)};
92 static constexpr char SCHAR_RIGHT{static_cast<char>(193)};
93 static constexpr char SCHAR_SPEAKER{static_cast<char>(194)};
95
100 struct config_t {
102 bool start_periodic{true};
104 bool trigger_irq{true};
107
108 keyboard::Mode mode{keyboard::Mode::Conventional};
110 uint32_t interval{10};
112 uint32_t repeating_threshold{400};
114 uint32_t holding_threshold{800};
116 };
117
118 explicit UnitFacesQWERTY(const uint8_t addr = DEFAULT_ADDRESS) : UnitKeyboardBitwise(addr)
119 {
120 _repeat_start_at.resize(NUMBER_OF_KEYS);
121 _hold_start_at.resize(NUMBER_OF_KEYS);
122 }
124 virtual bool begin() override;
126 virtual void update(const bool force = false) override;
127
130
132 {
133 return _cfg;
134 }
136 inline void config(const config_t& cfg)
137 {
138 _cfg = cfg;
139 }
141
143 inline virtual keyboard::key_index_t toKeyIndex(const char ch) const override
144 {
145 return character_to_key_index(ch);
146 }
147
153 static keyboard::key_index_t character_to_key_index(const char ch);
160 static uint8_t character_to_mode_bits(const char ch);
161
165
169 uint8_t facesType() const
170 {
171 return _type;
172 }
178 bool readFacesType(uint8_t& ftype);
180
181#if defined(DOXYGEN_PROCESS)
184 uint8_t released() const;
185#endif
186
187protected:
188 bool update_new_firmware(const types::elapsed_time_t at);
189 void push_back(m5::container::CircularBuffer<uint8_t>* container, const uint8_t kidx, const uint8_t mod8);
190
191 inline virtual uint8_t to_mode_bits(const char ch) const override
192 {
193 return character_to_mode_bits(ch);
194 }
195
196protected:
197 bool _handle_irq{};
198 uint8_t _type{};
199 config_t _cfg{};
200};
201
203namespace faces {
204namespace command {
205constexpr uint8_t CMD_FACES_TYPE_REG{0xFC};
206} // namespace command
207} // namespace faces
209} // namespace unit
210} // namespace m5
211#endif
QWERTY is a full-featured keyboard panel adapted to FACE_BOTTOM.
config_t config()
Gets the configuration.
Definition unit_FacesQWERTY.hpp:131
static keyboard::key_index_t character_to_key_index(const char ch)
Character to key index.
Definition unit_FacesQWERTY.cpp:232
virtual void update(const bool force=false) override
Definition unit_FacesQWERTY.cpp:315
uint8_t facesType() const
Gets the Faces type.
Definition unit_FacesQWERTY.hpp:169
virtual bool begin() override
Definition unit_FacesQWERTY.cpp:267
uint8_t released() const
Gets the released key character code if updated.
static uint8_t character_to_mode_bits(const char ch)
Character to mode bits.
Definition unit_FacesQWERTY.cpp:248
virtual keyboard::key_index_t toKeyIndex(const char ch) const override
Obtains the key index corresponding to the specified character.
Definition unit_FacesQWERTY.hpp:143
bool readFacesType(uint8_t &ftype)
Read the faces type.
Definition unit_FacesQWERTY.cpp:423
void config(const config_t &cfg)
Set the configuration.
Definition unit_FacesQWERTY.hpp:136
Class supporting keyboard state acquisition by key press bits.
For Faces.
Top level namespace of M5stack.
Unit-related namespace.
Settings for begin.
Definition unit_FacesQWERTY.hpp:100
uint32_t holding_threshold
Threshold for key holding (ms)
Definition unit_FacesQWERTY.hpp:114
uint32_t interval
Periodic interval.
Definition unit_FacesQWERTY.hpp:110
uint32_t repeating_threshold
Threshold for key repeating (ms)
Definition unit_FacesQWERTY.hpp:112
bool start_periodic
Start periodic measurement on begin?
Definition unit_FacesQWERTY.hpp:102
keyboard::Mode mode
Definition unit_FacesQWERTY.hpp:108
bool trigger_irq
Triggering an interrupt to update? (interval setting is ignored)
Definition unit_FacesQWERTY.hpp:104
constexpr uint8_t TYPE_QWERTY
SKU:A003.
Definition unit_FacesQWERTY.hpp:25
Base class for units.
uint8_t key_index_t
Key index (Not character)
Definition unit_Keyboard.hpp:24
Mode
Operation mode for M5Unit-KEYBOARD firmware.
Definition unit_Keyboard.hpp:50