2020-01-03 10:32:31 -05:00
|
|
|
#pragma once
|
|
|
|
|
2020-07-19 14:30:44 -04:00
|
|
|
#include "TwiMaster.h"
|
2020-01-03 10:32:31 -05:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
|
|
|
class Cst816S {
|
|
|
|
public :
|
2020-02-12 13:57:04 -05:00
|
|
|
enum class Gestures : uint8_t {
|
2020-07-19 14:30:44 -04:00
|
|
|
None = 0x00,
|
|
|
|
SlideDown = 0x01,
|
|
|
|
SlideUp = 0x02,
|
|
|
|
SlideLeft = 0x03,
|
|
|
|
SlideRight = 0x04,
|
|
|
|
SingleTap = 0x05,
|
|
|
|
DoubleTap = 0x0B,
|
|
|
|
LongPress = 0x0C
|
2020-02-12 13:57:04 -05:00
|
|
|
};
|
2020-01-03 10:32:31 -05:00
|
|
|
struct TouchInfos {
|
2020-10-27 14:46:51 -04:00
|
|
|
uint16_t x = 0;
|
|
|
|
uint16_t y = 0;
|
|
|
|
uint8_t action = 0;
|
|
|
|
uint8_t finger = 0;
|
|
|
|
uint8_t pressure = 0;
|
|
|
|
uint8_t area = 0;
|
|
|
|
Gestures gesture = Gestures::None;
|
2020-01-03 10:32:31 -05:00
|
|
|
bool isTouch = false;
|
|
|
|
};
|
|
|
|
|
2020-07-19 14:30:44 -04:00
|
|
|
Cst816S(TwiMaster& twiMaster, uint8_t twiAddress);
|
2020-03-08 16:38:11 -04:00
|
|
|
Cst816S(const Cst816S&) = delete;
|
|
|
|
Cst816S& operator=(const Cst816S&) = delete;
|
|
|
|
Cst816S(Cst816S&&) = delete;
|
|
|
|
Cst816S& operator=(Cst816S&&) = delete;
|
|
|
|
|
2020-01-03 10:32:31 -05:00
|
|
|
void Init();
|
|
|
|
TouchInfos GetTouchInfo();
|
2020-01-17 16:16:45 -05:00
|
|
|
void Sleep();
|
|
|
|
void Wakeup();
|
2020-01-03 10:32:31 -05:00
|
|
|
private:
|
|
|
|
static constexpr uint8_t pinIrq = 28;
|
|
|
|
static constexpr uint8_t pinReset = 10;
|
|
|
|
static constexpr uint8_t lastTouchId = 0x0f;
|
|
|
|
static constexpr uint8_t touchPointNumIndex = 2;
|
|
|
|
static constexpr uint8_t touchMiscIndex = 8;
|
|
|
|
static constexpr uint8_t touchXYIndex = 7;
|
|
|
|
static constexpr uint8_t touchEventIndex = 3;
|
|
|
|
static constexpr uint8_t touchXHighIndex = 3;
|
|
|
|
static constexpr uint8_t touchXLowIndex = 4;
|
|
|
|
static constexpr uint8_t touchYHighIndex = 5;
|
|
|
|
static constexpr uint8_t touchYLowIndex = 6;
|
|
|
|
static constexpr uint8_t touchIdIndex = 5;
|
|
|
|
static constexpr uint8_t touchStep = 6;
|
2020-02-12 13:57:04 -05:00
|
|
|
static constexpr uint8_t gestureIndex = 1;
|
2020-01-03 10:32:31 -05:00
|
|
|
|
|
|
|
uint8_t touchData[63];
|
2020-07-19 14:30:44 -04:00
|
|
|
TwiMaster& twiMaster;
|
|
|
|
uint8_t twiAddress;
|
2020-01-03 10:32:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2020-07-19 14:30:44 -04:00
|
|
|
}
|