Fix most issues
This commit is contained in:
parent
0d24d2b81e
commit
2a3e126390
12 changed files with 40 additions and 63 deletions
|
@ -226,9 +226,7 @@ void DisplayApp::Refresh() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (touchMode == TouchModes::Polling) {
|
|
||||||
currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY());
|
currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY());
|
||||||
}
|
|
||||||
|
|
||||||
if (nextApp != Apps::None) {
|
if (nextApp != Apps::None) {
|
||||||
LoadApp(nextApp, nextDirection);
|
LoadApp(nextApp, nextDirection);
|
||||||
|
@ -367,6 +365,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
break;
|
break;
|
||||||
case Apps::Metronome:
|
case Apps::Metronome:
|
||||||
currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
|
currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
|
||||||
|
ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::None);
|
||||||
break;
|
break;
|
||||||
case Apps::Motion:
|
case Apps::Motion:
|
||||||
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
|
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
|
||||||
|
@ -397,10 +396,8 @@ void DisplayApp::PushMessage(Messages msg) {
|
||||||
TouchEvents DisplayApp::GetGesture() {
|
TouchEvents DisplayApp::GetGesture() {
|
||||||
auto gesture = touchHandler.GestureGet();
|
auto gesture = touchHandler.GestureGet();
|
||||||
switch (gesture) {
|
switch (gesture) {
|
||||||
/*
|
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
|
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
|
||||||
return TouchEvents::Tap;
|
return TouchEvents::Tap;
|
||||||
*/
|
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::LongPress:
|
case Pinetime::Drivers::Cst816S::Gestures::LongPress:
|
||||||
return TouchEvents::LongTap;
|
return TouchEvents::LongTap;
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
|
case Pinetime::Drivers::Cst816S::Gestures::DoubleTap:
|
||||||
|
@ -445,10 +442,6 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
|
|
||||||
touchMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
|
void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
|
||||||
if(systemTask != nullptr)
|
if(systemTask != nullptr)
|
||||||
systemTask->PushMessage(message);
|
systemTask->PushMessage(message);
|
||||||
|
|
|
@ -43,7 +43,6 @@ namespace Pinetime {
|
||||||
public:
|
public:
|
||||||
enum class States { Idle, Running };
|
enum class States { Idle, Running };
|
||||||
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
|
enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
|
||||||
enum class TouchModes { Gestures, Polling };
|
|
||||||
|
|
||||||
DisplayApp(Drivers::St7789& lcd,
|
DisplayApp(Drivers::St7789& lcd,
|
||||||
Components::LittleVgl& lvgl,
|
Components::LittleVgl& lvgl,
|
||||||
|
@ -65,7 +64,6 @@ namespace Pinetime {
|
||||||
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
void StartApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
||||||
|
|
||||||
void SetFullRefresh(FullRefreshDirections direction);
|
void SetFullRefresh(FullRefreshDirections direction);
|
||||||
void SetTouchMode(TouchModes mode);
|
|
||||||
|
|
||||||
void Register(Pinetime::System::SystemTask* systemTask);
|
void Register(Pinetime::System::SystemTask* systemTask);
|
||||||
|
|
||||||
|
@ -104,8 +102,6 @@ namespace Pinetime {
|
||||||
FullRefreshDirections returnDirection = FullRefreshDirections::None;
|
FullRefreshDirections returnDirection = FullRefreshDirections::None;
|
||||||
TouchEvents returnTouchEvent = TouchEvents::None;
|
TouchEvents returnTouchEvent = TouchEvents::None;
|
||||||
|
|
||||||
TouchModes touchMode = TouchModes::Gestures;
|
|
||||||
|
|
||||||
TouchEvents GetGesture();
|
TouchEvents GetGesture();
|
||||||
void RunningState();
|
void RunningState();
|
||||||
void IdleState();
|
void IdleState();
|
||||||
|
|
|
@ -166,7 +166,7 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
|
||||||
lv_disp_flush_ready(&disp_drv);
|
lv_disp_flush_ready(&disp_drv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LittleVgl::SetNewTapEvent(uint16_t x, uint16_t y, bool contact) {
|
void LittleVgl::SetNewTouchPoint(uint16_t x, uint16_t y, bool contact) {
|
||||||
tap_x = x;
|
tap_x = x;
|
||||||
tap_y = y;
|
tap_y = y;
|
||||||
tapped = contact;
|
tapped = contact;
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Pinetime {
|
||||||
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
|
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
|
||||||
bool GetTouchPadInfo(lv_indev_data_t* ptr);
|
bool GetTouchPadInfo(lv_indev_data_t* ptr);
|
||||||
void SetFullRefresh(FullRefreshDirections direction);
|
void SetFullRefresh(FullRefreshDirections direction);
|
||||||
void SetNewTapEvent(uint16_t x, uint16_t y, bool contact);
|
void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitDisplay();
|
void InitDisplay();
|
||||||
|
|
|
@ -5,13 +5,10 @@
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
|
||||||
std::fill(b, b + bufferSize, selectColor);
|
std::fill(b, b + bufferSize, selectColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
InfiniPaint::~InfiniPaint() {
|
InfiniPaint::~InfiniPaint() {
|
||||||
// Reset the touchmode
|
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ Metronome::~Metronome() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Metronome::Refresh() {
|
bool Metronome::Refresh() {
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} {
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
|
||||||
|
|
||||||
background = lv_obj_create(lv_scr_act(), nullptr);
|
background = lv_obj_create(lv_scr_act(), nullptr);
|
||||||
lv_obj_set_size(background, LV_HOR_RES + 1, LV_VER_RES);
|
lv_obj_set_size(background, LV_HOR_RES + 1, LV_VER_RES);
|
||||||
lv_obj_set_pos(background, -1, 0);
|
lv_obj_set_pos(background, -1, 0);
|
||||||
|
@ -32,8 +30,6 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li
|
||||||
}
|
}
|
||||||
|
|
||||||
Paddle::~Paddle() {
|
Paddle::~Paddle() {
|
||||||
// Reset the touchmode
|
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ namespace Pinetime {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return false if the event hasn't been handled by the app, true if it has been handled */
|
/** @return false if the event hasn't been handled by the app, true if it has been handled */
|
||||||
|
// Returning true will cancel lvgl tap
|
||||||
virtual bool OnTouchEvent(TouchEvents event) {
|
virtual bool OnTouchEvent(TouchEvents event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,32 +56,24 @@ Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||||
Cst816S::TouchInfos info;
|
Cst816S::TouchInfos info;
|
||||||
|
|
||||||
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
|
auto ret = twiMaster.Read(twiAddress, 0, touchData, sizeof(touchData));
|
||||||
if (ret != TwiMaster::ErrorCodes::NoError)
|
if (ret != TwiMaster::ErrorCodes::NoError) {
|
||||||
return {};
|
info.isValid = false;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
auto nbTouchPoints = touchData[2] & 0x0f;
|
auto nbTouchPoints = touchData[2] & 0x0f;
|
||||||
|
|
||||||
uint8_t i = 0;
|
auto xHigh = touchData[touchXHighIndex] & 0x0f;
|
||||||
|
auto xLow = touchData[touchXLowIndex];
|
||||||
uint8_t pointId = (touchData[touchIdIndex + (touchStep * i)]) >> 4;
|
|
||||||
if (nbTouchPoints == 0 && pointId == lastTouchId)
|
|
||||||
return info;
|
|
||||||
|
|
||||||
info.isTouch = true;
|
|
||||||
|
|
||||||
auto xHigh = touchData[touchXHighIndex + (touchStep * i)] & 0x0f;
|
|
||||||
auto xLow = touchData[touchXLowIndex + (touchStep * i)];
|
|
||||||
uint16_t x = (xHigh << 8) | xLow;
|
uint16_t x = (xHigh << 8) | xLow;
|
||||||
|
|
||||||
auto yHigh = touchData[touchYHighIndex + (touchStep * i)] & 0x0f;
|
auto yHigh = touchData[touchYHighIndex] & 0x0f;
|
||||||
auto yLow = touchData[touchYLowIndex + (touchStep * i)];
|
auto yLow = touchData[touchYLowIndex];
|
||||||
uint16_t y = (yHigh << 8) | yLow;
|
uint16_t y = (yHigh << 8) | yLow;
|
||||||
|
|
||||||
auto action = touchData[touchEventIndex + (touchStep * i)] >> 6; /* 0 = Down, 1 = Up, 2 = contact*/
|
|
||||||
|
|
||||||
info.x = x;
|
info.x = x;
|
||||||
info.y = y;
|
info.y = y;
|
||||||
info.finger = nbTouchPoints;
|
info.touching = (nbTouchPoints > 0);
|
||||||
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
info.gesture = static_cast<Gestures>(touchData[gestureIndex]);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
|
|
@ -19,12 +19,9 @@ namespace Pinetime {
|
||||||
struct TouchInfos {
|
struct TouchInfos {
|
||||||
uint16_t x = 0;
|
uint16_t x = 0;
|
||||||
uint16_t y = 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;
|
Gestures gesture = Gestures::None;
|
||||||
bool isTouch = false;
|
bool touching = false;
|
||||||
|
bool isValid = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
Cst816S(TwiMaster& twiMaster, uint8_t twiAddress);
|
Cst816S(TwiMaster& twiMaster, uint8_t twiAddress);
|
||||||
|
@ -41,20 +38,21 @@ namespace Pinetime {
|
||||||
private:
|
private:
|
||||||
static constexpr uint8_t pinIrq = 28;
|
static constexpr uint8_t pinIrq = 28;
|
||||||
static constexpr uint8_t pinReset = 10;
|
static constexpr uint8_t pinReset = 10;
|
||||||
static constexpr uint8_t lastTouchId = 0x0f;
|
|
||||||
|
// Unused/Unavailable commented out
|
||||||
|
static constexpr uint8_t gestureIndex = 1;
|
||||||
static constexpr uint8_t touchPointNumIndex = 2;
|
static constexpr uint8_t touchPointNumIndex = 2;
|
||||||
static constexpr uint8_t touchMiscIndex = 8;
|
//static constexpr uint8_t touchEventIndex = 3;
|
||||||
static constexpr uint8_t touchXYIndex = 7;
|
|
||||||
static constexpr uint8_t touchEventIndex = 3;
|
|
||||||
static constexpr uint8_t touchXHighIndex = 3;
|
static constexpr uint8_t touchXHighIndex = 3;
|
||||||
static constexpr uint8_t touchXLowIndex = 4;
|
static constexpr uint8_t touchXLowIndex = 4;
|
||||||
|
//static constexpr uint8_t touchIdIndex = 5;
|
||||||
static constexpr uint8_t touchYHighIndex = 5;
|
static constexpr uint8_t touchYHighIndex = 5;
|
||||||
static constexpr uint8_t touchYLowIndex = 6;
|
static constexpr uint8_t touchYLowIndex = 6;
|
||||||
static constexpr uint8_t touchIdIndex = 5;
|
//static constexpr uint8_t touchStep = 6;
|
||||||
static constexpr uint8_t touchStep = 6;
|
//static constexpr uint8_t touchXYIndex = 7;
|
||||||
static constexpr uint8_t gestureIndex = 1;
|
//static constexpr uint8_t touchMiscIndex = 8;
|
||||||
|
|
||||||
uint8_t touchData[10];
|
uint8_t touchData[7];
|
||||||
TwiMaster& twiMaster;
|
TwiMaster& twiMaster;
|
||||||
uint8_t twiAddress;
|
uint8_t twiAddress;
|
||||||
};
|
};
|
||||||
|
|
|
@ -231,7 +231,7 @@ void SystemTask::Work() {
|
||||||
twiMaster.Wakeup();
|
twiMaster.Wakeup();
|
||||||
auto touchInfo = touchPanel.GetTouchInfo();
|
auto touchInfo = touchPanel.GetTouchInfo();
|
||||||
twiMaster.Sleep();
|
twiMaster.Sleep();
|
||||||
if (touchInfo.isTouch and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
|
if (touchInfo.isValid and ((touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::DoubleTap and
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or
|
||||||
(touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
|
(touchInfo.gesture == Pinetime::Drivers::Cst816S::Gestures::SingleTap and
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl&
|
||||||
|
|
||||||
void TouchHandler::CancelTap() {
|
void TouchHandler::CancelTap() {
|
||||||
isCancelled = true;
|
isCancelled = true;
|
||||||
lvgl.SetNewTapEvent(-1, -1, false);
|
lvgl.SetNewTouchPoint(-1, -1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() {
|
Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() {
|
||||||
|
@ -19,7 +19,7 @@ Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TouchHandler::Start() {
|
void TouchHandler::Start() {
|
||||||
if (pdPASS != xTaskCreate(TouchHandler::Process, "Touch", 80, this, 0, &taskHandle)) {
|
if (pdPASS != xTaskCreate(TouchHandler::Process, "Touch", 100, this, 0, &taskHandle)) {
|
||||||
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,9 @@ void TouchHandler::Work() {
|
||||||
} else {
|
} else {
|
||||||
x = info.x;
|
x = info.x;
|
||||||
y = info.y;
|
y = info.y;
|
||||||
if (info.finger == 0) {
|
if (info.touching) {
|
||||||
lvgl.SetNewTapEvent(info.x, info.y, false);
|
|
||||||
prevGesture = Pinetime::Drivers::Cst816S::Gestures::None;
|
|
||||||
isCancelled = false;
|
|
||||||
} else if (info.finger == 1) {
|
|
||||||
if (!isCancelled) {
|
if (!isCancelled) {
|
||||||
lvgl.SetNewTapEvent(info.x, info.y, true);
|
lvgl.SetNewTouchPoint(info.x, info.y, true);
|
||||||
}
|
}
|
||||||
if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
|
if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
|
||||||
if (prevGesture != info.gesture) {
|
if (prevGesture != info.gesture) {
|
||||||
|
@ -53,6 +49,14 @@ void TouchHandler::Work() {
|
||||||
gesture = info.gesture;
|
gesture = info.gesture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (isCancelled) {
|
||||||
|
lvgl.SetNewTouchPoint(-1, -1, false);
|
||||||
|
isCancelled = false;
|
||||||
|
} else {
|
||||||
|
lvgl.SetNewTouchPoint(info.x, info.y, false);
|
||||||
|
}
|
||||||
|
prevGesture = Pinetime::Drivers::Cst816S::Gestures::None;
|
||||||
}
|
}
|
||||||
systemTask->OnTouchEvent();
|
systemTask->OnTouchEvent();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue