M5Unit-KEYBOARD 0.1.0 git rev:b58d024
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
122 explicit UnitFacesQWERTY(const uint8_t addr = DEFAULT_ADDRESS) : UnitKeyboardBitwise(addr)
123 {
124 }
126 virtual bool begin() override;
128 virtual void update(const bool force = false) override;
129
132
133 inline config_t config() const
134 {
135 return _cfg;
136 }
141 inline void config(const config_t& cfg)
142 {
143 _cfg = cfg;
144 }
146
148 inline virtual keyboard::key_index_t toKeyIndex(const char ch) const override
149 {
150 return character_to_key_index(ch);
151 }
152
159 static keyboard::key_index_t character_to_key_index(const char ch);
167 static uint8_t character_to_mode_bits(const char ch);
168
172
176 uint8_t facesType() const
177 {
178 return _type;
179 }
185 bool readFacesType(uint8_t& ftype);
187
188#if defined(DOXYGEN_PROCESS)
191 uint8_t released() const;
192#endif
193
194protected:
195 bool update_new_firmware(const types::elapsed_time_t at);
196 void push_back(m5::container::CircularBuffer<uint8_t>* container, const uint8_t kidx, const uint8_t mod8);
197
198 inline virtual uint8_t to_mode_bits(const char ch) const override
199 {
200 return character_to_mode_bits(ch);
201 }
202
203protected:
204 bool _handle_irq{};
205 uint8_t _type{};
206 config_t _cfg{};
207};
208
210namespace faces {
211namespace command {
212constexpr uint8_t CMD_FACES_TYPE_REG{0xFC};
213} // namespace command
214} // namespace faces
216} // namespace unit
217} // namespace m5
218#endif
UnitFacesQWERTY(const uint8_t addr=DEFAULT_ADDRESS)
Constructor.
Definition unit_FacesQWERTY.hpp:122
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:176
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:148
config_t config() const
Gets the configuration.
Definition unit_FacesQWERTY.hpp:133
bool readFacesType(uint8_t &ftype)
Read the faces type.
Definition unit_FacesQWERTY.cpp:413
void config(const config_t &cfg)
Set the configuration.
Definition unit_FacesQWERTY.hpp:141
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:26
Mode
Operation mode for M5Unit-KEYBOARD firmware.
Definition unit_Keyboard.hpp:58