Log Touchpanel data (position + gesture!)
This commit is contained in:
parent
e65c9fa181
commit
52539a5ff1
|
@ -48,11 +48,7 @@ void DisplayApp::Process(void *instance) {
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
app->Refresh();
|
app->Refresh();
|
||||||
|
|
||||||
auto before = nrf_rtc_counter_get(portNRF_RTC_REG);
|
|
||||||
lv_task_handler();
|
lv_task_handler();
|
||||||
auto after = nrf_rtc_counter_get(portNRF_RTC_REG);
|
|
||||||
NRF_LOG_INFO("duration : %d", (after-before));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,10 +73,10 @@ void DisplayApp::Refresh() {
|
||||||
break;
|
break;
|
||||||
case States::Running:
|
case States::Running:
|
||||||
RunningState();
|
RunningState();
|
||||||
queueTimeout = 1;
|
queueTimeout = 1000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Messages msg;
|
Messages msg;
|
||||||
if (xQueueReceive(msgQueue, &msg, queueTimeout)) {
|
if (xQueueReceive(msgQueue, &msg, queueTimeout)) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
|
@ -119,7 +115,6 @@ void DisplayApp::Refresh() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
|
@ -50,13 +50,16 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||||
nrfx_twi_rx(&twi, address, touchData, 63);
|
nrfx_twi_rx(&twi, address, touchData, 63);
|
||||||
auto nbTouchPoints = touchData[2] & 0x0f;
|
auto nbTouchPoints = touchData[2] & 0x0f;
|
||||||
|
|
||||||
uint8_t i = 0;
|
// uint8_t i = 0;
|
||||||
|
// NRF_LOG_INFO("#########################")
|
||||||
|
for(int i = 0; i < 1; i++) {
|
||||||
uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4;
|
uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4;
|
||||||
if(nbTouchPoints == 0 && pointId == lastTouchId) return info;
|
if(nbTouchPoints == 0 && pointId == lastTouchId) return info;
|
||||||
|
|
||||||
// We fetch only the first touch point (the controller seems to handle only one anyway...)
|
// We fetch only the first touch point (the controller seems to handle only one anyway...)
|
||||||
info.isTouch = true;
|
info.isTouch = true;
|
||||||
|
|
||||||
|
|
||||||
auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f;
|
auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f;
|
||||||
auto xLow = touchData[touchXLowIndex + (touchStep * i)];
|
auto xLow = touchData[touchXLowIndex + (touchStep * i)];
|
||||||
uint16_t x = (xHigh << 8) | xLow;
|
uint16_t x = (xHigh << 8) | xLow;
|
||||||
|
@ -73,6 +76,32 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||||
info.x = x;
|
info.x = x;
|
||||||
info.y = y;
|
info.y = y;
|
||||||
info.action = action;
|
info.action = action;
|
||||||
|
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
||||||
|
|
||||||
|
NRF_LOG_INFO("---------------")
|
||||||
|
NRF_LOG_INFO("ID : %d", pointId);
|
||||||
|
NRF_LOG_INFO("NB : %d", nbTouchPoints);
|
||||||
|
NRF_LOG_INFO("X/Y :%d / %d", info.x, info.y);
|
||||||
|
NRF_LOG_INFO("Action : %d", action);
|
||||||
|
NRF_LOG_INFO("Finger : %d", finger);
|
||||||
|
NRF_LOG_INFO("Pressure : %d", pressure);
|
||||||
|
NRF_LOG_INFO("area : %d", area);
|
||||||
|
NRF_LOG_INFO("Touch : %s", info.isTouch?"Yes" : "No");
|
||||||
|
switch(info.gesture) {// gesture
|
||||||
|
case Gestures::None: NRF_LOG_INFO("Gesture : None"); break;
|
||||||
|
case Gestures::SlideDown: NRF_LOG_INFO("Gesture : Slide Down"); break;
|
||||||
|
case Gestures::SlideUp: NRF_LOG_INFO("Gesture : Slide Up"); break;
|
||||||
|
case Gestures::SlideLeft: NRF_LOG_INFO("Gesture : Slide Left"); break;
|
||||||
|
case Gestures::SlideRight: NRF_LOG_INFO("Gesture : Slide Right"); break;
|
||||||
|
case Gestures::SingleTap: NRF_LOG_INFO("Gesture : Single click"); break;
|
||||||
|
case Gestures::DoubleTap: NRF_LOG_INFO("Gesture : Double click"); break;
|
||||||
|
case Gestures::LongPress: NRF_LOG_INFO("Gesture : Long press"); break;
|
||||||
|
default : NRF_LOG_INFO("Unknown"); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,16 @@ namespace Pinetime {
|
||||||
namespace Drivers {
|
namespace Drivers {
|
||||||
class Cst816S {
|
class Cst816S {
|
||||||
public :
|
public :
|
||||||
|
enum class Gestures : uint8_t {
|
||||||
|
None = 0x00,
|
||||||
|
SlideDown = 0x01,
|
||||||
|
SlideUp = 0x02,
|
||||||
|
SlideLeft = 0x03,
|
||||||
|
SlideRight = 0x04,
|
||||||
|
SingleTap = 0x05,
|
||||||
|
DoubleTap = 0x0B,
|
||||||
|
LongPress = 0x0C
|
||||||
|
};
|
||||||
struct TouchInfos {
|
struct TouchInfos {
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
uint16_t y;
|
uint16_t y;
|
||||||
|
@ -13,6 +23,7 @@ namespace Pinetime {
|
||||||
uint8_t finger;
|
uint8_t finger;
|
||||||
uint8_t pressure;
|
uint8_t pressure;
|
||||||
uint8_t area;
|
uint8_t area;
|
||||||
|
Gestures gesture;
|
||||||
bool isTouch = false;
|
bool isTouch = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,6 +47,7 @@ namespace Pinetime {
|
||||||
static constexpr uint8_t touchYLowIndex = 6;
|
static constexpr uint8_t touchYLowIndex = 6;
|
||||||
static constexpr uint8_t touchIdIndex = 5;
|
static constexpr uint8_t touchIdIndex = 5;
|
||||||
static constexpr uint8_t touchStep = 6;
|
static constexpr uint8_t touchStep = 6;
|
||||||
|
static constexpr uint8_t gestureIndex = 1;
|
||||||
|
|
||||||
uint8_t touchData[63];
|
uint8_t touchData[63];
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ void SystemTask(void *) {
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
uint8_t msg;
|
uint8_t msg;
|
||||||
if (xQueueReceive(systemTaksMsgQueue, &msg, systemTaskSleeping?3600000 : 10)) {
|
if (xQueueReceive(systemTaksMsgQueue, &msg, systemTaskSleeping?3600000 : 1000)) {
|
||||||
SystemTaskMessages message = static_cast<SystemTaskMessages >(msg);
|
SystemTaskMessages message = static_cast<SystemTaskMessages >(msg);
|
||||||
switch(message) {
|
switch(message) {
|
||||||
case SystemTaskMessages::GoToRunning: systemTaskSleeping = false; break;
|
case SystemTaskMessages::GoToRunning: systemTaskSleeping = false; break;
|
||||||
|
|
Loading…
Reference in a new issue