71 lines
1.5 KiB
C
71 lines
1.5 KiB
C
|
#pragma once
|
||
|
|
||
|
#include <memory>
|
||
|
#include <functional>
|
||
|
#include "commondef.h"
|
||
|
class PinMonitor;
|
||
|
class Gpio;
|
||
|
|
||
|
class KeyMonitor
|
||
|
{
|
||
|
public:
|
||
|
#ifdef G200
|
||
|
enum class HGKey
|
||
|
{
|
||
|
Key_Enter = 69,
|
||
|
Key_Cancle = 70,
|
||
|
Key_Count = 78,
|
||
|
Key_Handle = 77,
|
||
|
Key_DoubleFeed = 68,
|
||
|
Key_Left = 86,
|
||
|
Key_Menu = 85,
|
||
|
Key_Right = 76,
|
||
|
Key_Clear = 84
|
||
|
};
|
||
|
#else
|
||
|
enum class HGKey
|
||
|
{
|
||
|
Key_Enter = 70,
|
||
|
Key_Cancle = 69,
|
||
|
Key_Count = 78,
|
||
|
Key_Menu = 76,
|
||
|
Key_Right = 77,
|
||
|
Key_Clear = 68,
|
||
|
Key_Handle = 3331,
|
||
|
Key_DoubleFeed = 3332,
|
||
|
Key_Left = 3333
|
||
|
};
|
||
|
#endif
|
||
|
enum class HGLed
|
||
|
{
|
||
|
Led_Enter_open = 0,
|
||
|
Led_Enter_close,
|
||
|
Led_Count_open,
|
||
|
Led_Count_close,
|
||
|
Led_DoubleFeed_open,
|
||
|
Led_DoubleFeed_close,
|
||
|
Led_Handle_open,
|
||
|
Led_Handle_close,
|
||
|
Led_All_open,
|
||
|
Led_All_close
|
||
|
};
|
||
|
public:
|
||
|
KeyMonitor(std::function<void(int)> keycall);
|
||
|
void setled(HGLed value);
|
||
|
std::uint8_t getledstate();
|
||
|
~KeyMonitor();
|
||
|
private:
|
||
|
void init();
|
||
|
void i2c_start();
|
||
|
void i2c_write(unsigned char cmd);
|
||
|
unsigned char i2c_read();
|
||
|
void i2c_stop();
|
||
|
void write_cmd(unsigned short cmd);
|
||
|
unsigned char read_key();
|
||
|
private:
|
||
|
std::shared_ptr<PinMonitor> m_keymonitor;
|
||
|
std::shared_ptr<Gpio> m_gpioi2c_SDA;
|
||
|
std::shared_ptr<Gpio> m_gpioi2c_SCL;
|
||
|
std::function<void(int)> m_keycall;
|
||
|
volatile std::uint8_t m_ledstate;
|
||
|
};
|