40 lines
1.1 KiB
C++

#pragma once
#include <Tactility/hal/keyboard/KeyboardDevice.h>
#include <Tactility/TactilityCore.h>
#include <Tca8418.h>
#include <driver/pulse_cnt.h>
#include <Tactility/Timer.h>
class TpagerKeyboard : public tt::hal::keyboard::KeyboardDevice {
private:
lv_indev_t* _Nullable kbHandle = nullptr;
lv_indev_t* _Nullable encHandle = nullptr;
pcnt_unit_handle_t encPcntUnit = nullptr;
std::shared_ptr<Tca8418> keypad;
std::unique_ptr<tt::Timer> inputTimer;
void initEncoder(void);
void processKeyboard();
public:
TpagerKeyboard(std::shared_ptr<Tca8418> tca) : keypad(std::move(tca)) {}
~TpagerKeyboard() {}
std::string getName() const final { return "T-Lora Pager Keyboard"; }
std::string getDescription() const final { return "I2C keyboard with encoder"; }
bool start(lv_display_t* display) override;
bool stop() override;
bool isAttached() const override;
lv_indev_t* _Nullable getLvglIndev() override { return kbHandle; }
int getEncoderPulses();
};
std::shared_ptr<tt::hal::keyboard::KeyboardDevice> createKeyboard();