M5Unit-KEYBOARD 0.0.1 git rev:a483db1
Loading...
Searching...
No Matches
m5::unit::UnitCardKB Class Reference

Card-size 50 key QWERTY keyboard. More...

#include <unit_CardKB.hpp>

Inheritance diagram for m5::unit::UnitCardKB:
m5::unit::UnitKeyboardBitwise m5::unit::UnitKeyboard

Classes

struct  config_t
 Settings for begin. More...
 

Public Member Functions

 UnitCardKB (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual bool begin () override
 
virtual void update (const bool force=false) override
 
virtual keyboard::key_index_t toKeyIndex (const char ch) const override
 Obtains the key index corresponding to the specified character.
 
Settings for begin
config_t config ()
 Gets the configuration.
 
void config (const config_t &cfg)
 Set the configuration.
 
Hardware type
Warning
API valid only if using M5Unit-KEYBOARD firmware
uint8_t hardwareType () const
 Gets the hardware type.
 
bool readHardwareType (uint8_t &htype)
 Read the hardware type.
 
- Public Member Functions inherited from m5::unit::UnitKeyboardBitwise
 UnitKeyboardBitwise (const uint8_t addr=DEFAULT_ADDRESS)
 
virtual char getchar () const override
 Gets the input character.
 
uint8_t pressed () const
 Get the oldest pressed key.
 
virtual uint8_t released () const override
 Get the oldest released key.
 
bool startPeriodicMeasurement (const uint32_t interval)
 Start periodic measurement.
 
bool startPeriodicMeasurement ()
 Start periodic measurement using current settings.
 
bool stopPeriodicMeasurement ()
 Stop periodic measurement.
 
keyboard::key_status_bits_t nowBits () const
 Get the bits of the key being pressed.
 
keyboard::key_status_bits_t previousBits () const
 Get the bits of the previous key pressed.
 
keyboard::key_status_bits_t pressedBits () const
 Get the key bits at the moment they are pressed.
 
keyboard::key_status_bits_t releasedBits () const
 Get the key bits at the moment they are released.
 
keyboard::key_status_bits_t holdingBits () const
 Get the bits of the held key.
 
keyboard::key_status_bits_t wasHoldBits () const
 Get the bits of the key at the moment of hold.
 
keyboard::key_status_bits_t repeatingBits () const
 Get the bits of the key that the software is repeatedly pressing.
 
keyboard::key_status_bits_t modifierBits () const
 Get the bits of the modifier key being pressed.
 
bool isModifier () const
 Is any modifier keys pressed?
 
bool isShift () const
 Is the shift key pressed?
 
bool isSymbol () const
 Is the symbol key pressed?
 
bool isFunction () const
 Is the function key pressed?
 
bool isAlt () const
 Is the alt key pressed?
 
bool isControl () const
 Is the control key pressed?
 
bool isOption () const
 Is the option key pressed?
 
bool isShiftEqual () const
 Is only shift pressed among the modifier keys?
 
bool isSymbolEqual () const
 Is only symbol pressed among the modifier keys?
 
bool isFunctionEqual () const
 Is only function pressed among the modifier keys?
 
bool isAltEqual () const
 Is only alt pressed among the modifier keys?
 
bool isControlEqual () const
 Is only control pressed among the modifier keys?
 
bool isOptionEqual () const
 Is only option pressed among the modifier keys?
 
bool isPressed () const
 Is any key press?
 
bool isReleased () const
 Is all key release?
 
bool wasPressed () const
 Was any key pressed?
 
bool wasReleased () const
 Was any key released?
 
bool isHolding () const
 Is any key holding?
 
bool wasHold () const
 Was any key hold?
 
bool isRepeating () const
 Is any key repeating?
 
bool isPressed (const keyboard::key_index_t kidx) const
 Is the specified key pressed?
 
bool isReleased (const keyboard::key_index_t kidx) const
 Is the specified key released?
 
bool wasPressed (const keyboard::key_index_t kidx) const
 Was the specified key pressed?
 
bool wasReleased (const keyboard::key_index_t kidx) const
 Was the specified key released?
 
bool isHolding (const keyboard::key_index_t kidx) const
 Is the specified key holding?
 
bool wasHold (const keyboard::key_index_t kidx) const
 Was the specified key hold?
 
bool isRepeating (const keyboard::key_index_t kidx) const
 Is the specified key repeating?
 
bool isPressed (const char ch) const
 Is the specified character pressed?
 
bool isReleased (const char ch) const
 Is the specified character released?
 
bool wasPressed (const char ch) const
 Was the specified character pressed?
 
bool wasReleased (const char ch) const
 Was the specified character released?
 
bool isHolding (const char ch) const
 Is the specified character holding?
 
bool wasHold (const char ch) const
 Was the specified character hold?
 
bool isRepeating (const char ch) const
 Is the specified character repeating?
 
uint8_t firmwareVersion () const
 Gets the firmware version.
 
virtual bool readFirmwareVersion (uint8_t &ver)
 Read the firmware version.
 
uint32_t holdingThreshold () const
 Gets the holding threshold (ms)
 
uint32_t repeatingThreshold () const
 Gets the repeating threshold (ms)
 
void setHoldingThreshold (const uint32_t ms)
 Sets the holding threshold.
 
void setRepeatingThreshold (const uint32_t ms)
 Sets the repeating threshold.
 
virtual bool readMode (keyboard::Mode &mode)
 Read the mode.
 
virtual bool writeMode (const keyboard::Mode mode)
 Write the mode.
 
- Public Member Functions inherited from m5::unit::UnitKeyboard
 UnitKeyboard (const uint8_t addr=DEFAULT_ADDRESS)
 

Static Public Member Functions

static keyboard::key_index_t character_to_key_index (const char ch)
 Character to key index.
 
static uint8_t character_to_mode_bits (const char ch)
 Character to mode bits.
 

Static Public Attributes

static constexpr uint8_t NUMBER_OF_KEYS {48}
 
key index (left top to right bottom)
static constexpr keyboard::key_index_t KEY_ESC {0}
 
static constexpr keyboard::key_index_t KEY_1 {1}
 
static constexpr keyboard::key_index_t KEY_2 {2}
 
static constexpr keyboard::key_index_t KEY_3 {3}
 
static constexpr keyboard::key_index_t KEY_4 {4}
 
static constexpr keyboard::key_index_t KEY_5 {5}
 
static constexpr keyboard::key_index_t KEY_6 {6}
 
static constexpr keyboard::key_index_t KEY_7 {7}
 
static constexpr keyboard::key_index_t KEY_8 {8}
 
static constexpr keyboard::key_index_t KEY_9 {9}
 
static constexpr keyboard::key_index_t KEY_0 {10}
 
static constexpr keyboard::key_index_t KEY_BS {11}
 
static constexpr keyboard::key_index_t KEY_TAB {12}
 
static constexpr keyboard::key_index_t KEY_Q {13}
 
static constexpr keyboard::key_index_t KEY_W {14}
 
static constexpr keyboard::key_index_t KEY_E {15}
 
static constexpr keyboard::key_index_t KEY_R {16}
 
static constexpr keyboard::key_index_t KEY_T {17}
 
static constexpr keyboard::key_index_t KEY_Y {18}
 
static constexpr keyboard::key_index_t KEY_U {19}
 
static constexpr keyboard::key_index_t KEY_I {20}
 
static constexpr keyboard::key_index_t KEY_O {21}
 
static constexpr keyboard::key_index_t KEY_P {22}
 
static constexpr keyboard::key_index_t KEY_NO_KEY {23}
 
static constexpr keyboard::key_index_t KEY_LEFT {24}
 
static constexpr keyboard::key_index_t KEY_UP {25}
 
static constexpr keyboard::key_index_t KEY_A {26}
 
static constexpr keyboard::key_index_t KEY_S {27}
 
static constexpr keyboard::key_index_t KEY_D {28}
 
static constexpr keyboard::key_index_t KEY_F {29}
 
static constexpr keyboard::key_index_t KEY_G {30}
 
static constexpr keyboard::key_index_t KEY_H {31}
 
static constexpr keyboard::key_index_t KEY_J {32}
 
static constexpr keyboard::key_index_t KEY_K {33}
 
static constexpr keyboard::key_index_t KEY_L {34}
 
static constexpr keyboard::key_index_t KEY_ENTER {35}
 
static constexpr keyboard::key_index_t KEY_DOWN {36}
 
static constexpr keyboard::key_index_t KEY_RIGHT {37}
 
static constexpr keyboard::key_index_t KEY_Z {38}
 
static constexpr keyboard::key_index_t KEY_X {39}
 
static constexpr keyboard::key_index_t KEY_C {40}
 
static constexpr keyboard::key_index_t KEY_V {41}
 
static constexpr keyboard::key_index_t KEY_B {42}
 
static constexpr keyboard::key_index_t KEY_N {43}
 
static constexpr keyboard::key_index_t KEY_M {44}
 
static constexpr keyboard::key_index_t KEY_COMMA {45}
 
static constexpr keyboard::key_index_t KEY_PERIOD {46}
 
static constexpr keyboard::key_index_t KEY_SPACE {47}
 
Character code for special keys
static constexpr char SCHAR_LEFT {static_cast<char>(180)}
 
static constexpr char SCHAR_UP {static_cast<char>(181)}
 
static constexpr char SCHAR_DOWN {static_cast<char>(182)}
 
static constexpr char SCHAR_RIGHT {static_cast<char>(183)}
 

Protected Member Functions

bool update_new_firmware (const types::elapsed_time_t at)
 
void push_back (m5::container::CircularBuffer< uint8_t > *container, const uint8_t kidx, const uint8_t mod8)
 
virtual uint8_t to_mode_bits (const char ch) const override
 
- Protected Member Functions inherited from m5::unit::UnitKeyboardBitwise
bool start_periodic_measurement ()
 
bool start_periodic_measurement (const uint32_t interval)
 
bool stop_periodic_measurement ()
 
bool update_new_firmware (const types::elapsed_time_t at)
 
void push_back (m5::container::CircularBuffer< uint8_t > *container, const uint8_t kidx, const uint8_t alt)
 
keyboard::key_status_bits_t modifier_bits () const
 
virtual uint8_t scan_reg_addr () const
 
virtual uint8_t mode_reg_addr () const
 
virtual uint8_t firmware_version_reg_addr () const
 
bool permitted_mode (const uint8_t mbits) const
 
 M5_UNIT_COMPONENT_PERIODIC_MEASUREMENT_ADAPTER_HPP_BUILDER (UnitKeyboardBitwise, uint8_t)
 

Protected Attributes

uint8_t _type {}
 
config_t _cfg {}
 
- Protected Attributes inherited from m5::unit::UnitKeyboardBitwise
std::unique_ptr< m5::container::CircularBuffer< uint8_t > > _data {}
 
keyboard::key_status_bits_t _now {}
 
keyboard::key_status_bits_t _prev {}
 
keyboard::key_status_bits_t _wasPressed {}
 
keyboard::key_status_bits_t _wasReleased {}
 
keyboard::key_status_bits_t _wasHold {}
 
keyboard::key_status_bits_t _holding {}
 
keyboard::key_status_bits_t _repeating {}
 
std::vector< types::elapsed_time_t > _repeat_start_at {}
 
std::vector< types::elapsed_time_t > _hold_start_at {}
 
uint32_t _repeating_threshold {400}
 
uint32_t _holding_threshold {800}
 
uint8_t _firmware_version {}
 
keyboard::Mode _mode {keyboard::Mode::Conventional}
 

Detailed Description

Card-size 50 key QWERTY keyboard.

Warning
Note that older firmware can only detect if the key is released

Member Function Documentation

◆ begin()

bool m5::unit::UnitCardKB::begin ( )
overridevirtual

Reimplemented from m5::unit::UnitKeyboard.

◆ character_to_key_index()

key_index_t m5::unit::UnitCardKB::character_to_key_index ( const char ch)
static

Character to key index.

Return values
!=0xFF keyboard::key_index_t
==0xFF No corresponding key index exists

◆ character_to_mode_bits()

uint8_t m5::unit::UnitCardKB::character_to_mode_bits ( const char ch)
static

Character to mode bits.

Return values
==0 Not exists
!=0 Bits in corresponding mode
Note
0x01:normal 0x02:shift 0x04:symbol 0x08:function

◆ hardwareType()

uint8_t m5::unit::UnitCardKB::hardwareType ( ) const
inline

Gets the hardware type.

Warning
Valid after begin

◆ readHardwareType()

bool m5::unit::UnitCardKB::readHardwareType ( uint8_t & htype)

Read the hardware type.

Parameters
[out]htypeHardware type
Returns
True if successful

◆ to_mode_bits()

virtual uint8_t m5::unit::UnitCardKB::to_mode_bits ( const char ch) const
inlineoverrideprotectedvirtual

Reimplemented from m5::unit::UnitKeyboardBitwise.

◆ toKeyIndex()

virtual keyboard::key_index_t m5::unit::UnitCardKB::toKeyIndex ( const char ch) const
inlineoverridevirtual

Obtains the key index corresponding to the specified character.

Return values
!=0xFF key index
==0xFF No corresponding key index

Reimplemented from m5::unit::UnitKeyboardBitwise.

◆ update()

void m5::unit::UnitCardKB::update ( const bool force = false)
overridevirtual

Reimplemented from m5::unit::UnitKeyboardBitwise.