New touch handler, with issues
This commit is contained in:
parent
57b3397078
commit
fe64176e7b
|
@ -495,6 +495,8 @@ list(APPEND SOURCE_FILES
|
||||||
components/heartrate/Biquad.cpp
|
components/heartrate/Biquad.cpp
|
||||||
components/heartrate/Ptagc.cpp
|
components/heartrate/Ptagc.cpp
|
||||||
components/heartrate/HeartRateController.cpp
|
components/heartrate/HeartRateController.cpp
|
||||||
|
|
||||||
|
touchhandler/TouchHandler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND RECOVERY_SOURCE_FILES
|
list(APPEND RECOVERY_SOURCE_FILES
|
||||||
|
@ -552,6 +554,7 @@ list(APPEND RECOVERY_SOURCE_FILES
|
||||||
components/heartrate/Ptagc.cpp
|
components/heartrate/Ptagc.cpp
|
||||||
components/motor/MotorController.cpp
|
components/motor/MotorController.cpp
|
||||||
components/fs/FS.cpp
|
components/fs/FS.cpp
|
||||||
|
touchhandler/TouchHandler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND RECOVERYLOADER_SOURCE_FILES
|
list(APPEND RECOVERYLOADER_SOURCE_FILES
|
||||||
|
@ -660,6 +663,7 @@ set(INCLUDE_FILES
|
||||||
components/heartrate/Ptagc.h
|
components/heartrate/Ptagc.h
|
||||||
components/heartrate/HeartRateController.h
|
components/heartrate/HeartRateController.h
|
||||||
components/motor/MotorController.h
|
components/motor/MotorController.h
|
||||||
|
touchhandler/TouchHandler.h
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
|
|
@ -66,7 +66,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
Pinetime::Controllers::TimerController& timerController)
|
Pinetime::Controllers::TimerController& timerController,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler)
|
||||||
: lcd {lcd},
|
: lcd {lcd},
|
||||||
lvgl {lvgl},
|
lvgl {lvgl},
|
||||||
touchPanel {touchPanel},
|
touchPanel {touchPanel},
|
||||||
|
@ -79,7 +80,8 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
|
||||||
settingsController {settingsController},
|
settingsController {settingsController},
|
||||||
motorController {motorController},
|
motorController {motorController},
|
||||||
motionController {motionController},
|
motionController {motionController},
|
||||||
timerController {timerController} {
|
timerController {timerController},
|
||||||
|
touchHandler {touchHandler} {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::Start() {
|
void DisplayApp::Start() {
|
||||||
|
@ -176,10 +178,28 @@ void DisplayApp::Refresh() {
|
||||||
LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down);
|
LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::TouchEvent: {
|
case Messages::ButtonPushed:
|
||||||
if (state != States::Running)
|
if (currentApp == Apps::Clock) {
|
||||||
|
PushMessageToSystemTask(System::Messages::GoToSleep);
|
||||||
|
} else {
|
||||||
|
if (!currentScreen->OnButtonPushed()) {
|
||||||
|
LoadApp(returnToApp, returnDirection);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
auto gesture = OnTouchEvent();
|
|
||||||
|
case Messages::BleFirmwareUpdateStarted:
|
||||||
|
LoadApp(Apps::FirmwareUpdate, DisplayApp::FullRefreshDirections::Down);
|
||||||
|
break;
|
||||||
|
case Messages::UpdateDateTime:
|
||||||
|
// Added to remove warning
|
||||||
|
// What should happen here?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto gesture = GetGesture();
|
||||||
|
if (gesture != TouchEvents::None) {
|
||||||
if (!currentScreen->OnTouchEvent(gesture)) {
|
if (!currentScreen->OnTouchEvent(gesture)) {
|
||||||
if (currentApp == Apps::Clock) {
|
if (currentApp == Apps::Clock) {
|
||||||
switch (gesture) {
|
switch (gesture) {
|
||||||
|
@ -201,41 +221,19 @@ void DisplayApp::Refresh() {
|
||||||
} else if (returnTouchEvent == gesture) {
|
} else if (returnTouchEvent == gesture) {
|
||||||
LoadApp(returnToApp, returnDirection);
|
LoadApp(returnToApp, returnDirection);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case Messages::ButtonPushed:
|
|
||||||
if (currentApp == Apps::Clock) {
|
|
||||||
PushMessageToSystemTask(System::Messages::GoToSleep);
|
|
||||||
} else {
|
} else {
|
||||||
if (!currentScreen->OnButtonPushed()) {
|
touchHandler.CancelTap();
|
||||||
LoadApp(returnToApp, returnDirection);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case Messages::BleFirmwareUpdateStarted:
|
if (touchMode == TouchModes::Polling) {
|
||||||
LoadApp(Apps::FirmwareUpdate, DisplayApp::FullRefreshDirections::Down);
|
currentScreen->OnTouchEvent(touchHandler.GetX(), touchHandler.GetY());
|
||||||
break;
|
|
||||||
case Messages::UpdateDateTime:
|
|
||||||
// Added to remove warning
|
|
||||||
// What should happen here?
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextApp != Apps::None) {
|
if (nextApp != Apps::None) {
|
||||||
LoadApp(nextApp, nextDirection);
|
LoadApp(nextApp, nextDirection);
|
||||||
nextApp = Apps::None;
|
nextApp = Apps::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != States::Idle && touchMode == TouchModes::Polling) {
|
|
||||||
auto info = touchPanel.GetTouchInfo();
|
|
||||||
if (info.action == 2) { // 2 = contact
|
|
||||||
if (!currentScreen->OnTouchEvent(info.x, info.y)) {
|
|
||||||
lvgl.SetNewTapEvent(info.x, info.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::RunningState() {
|
void DisplayApp::RunningState() {
|
||||||
|
@ -257,6 +255,7 @@ void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) {
|
void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) {
|
||||||
|
touchHandler.CancelTap();
|
||||||
currentScreen.reset(nullptr);
|
currentScreen.reset(nullptr);
|
||||||
SetFullRefresh(direction);
|
SetFullRefresh(direction);
|
||||||
|
|
||||||
|
@ -395,15 +394,13 @@ void DisplayApp::PushMessage(Messages msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchEvents DisplayApp::OnTouchEvent() {
|
TouchEvents DisplayApp::GetGesture() {
|
||||||
auto info = touchPanel.GetTouchInfo();
|
auto gesture = touchHandler.GestureGet();
|
||||||
if (info.isTouch) {
|
switch (gesture) {
|
||||||
switch (info.gesture) {
|
/*
|
||||||
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
|
case Pinetime::Drivers::Cst816S::Gestures::SingleTap:
|
||||||
if (touchMode == TouchModes::Gestures) {
|
|
||||||
lvgl.SetNewTapEvent(info.x, info.y);
|
|
||||||
}
|
|
||||||
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:
|
||||||
|
@ -420,7 +417,6 @@ TouchEvents DisplayApp::OnTouchEvent() {
|
||||||
default:
|
default:
|
||||||
return TouchEvents::None;
|
return TouchEvents::None;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return TouchEvents::None;
|
return TouchEvents::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
#include "displayapp/screens/Screen.h"
|
#include "displayapp/screens/Screen.h"
|
||||||
#include "components/timer/TimerController.h"
|
#include "components/timer/TimerController.h"
|
||||||
|
#include "touchhandler/TouchHandler.h"
|
||||||
#include "Messages.h"
|
#include "Messages.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
@ -31,6 +32,7 @@ namespace Pinetime {
|
||||||
class NotificationManager;
|
class NotificationManager;
|
||||||
class HeartRateController;
|
class HeartRateController;
|
||||||
class MotionController;
|
class MotionController;
|
||||||
|
class TouchHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace System {
|
namespace System {
|
||||||
|
@ -55,7 +57,8 @@ namespace Pinetime {
|
||||||
Controllers::Settings& settingsController,
|
Controllers::Settings& settingsController,
|
||||||
Pinetime::Controllers::MotorController& motorController,
|
Pinetime::Controllers::MotorController& motorController,
|
||||||
Pinetime::Controllers::MotionController& motionController,
|
Pinetime::Controllers::MotionController& motionController,
|
||||||
Pinetime::Controllers::TimerController& timerController);
|
Pinetime::Controllers::TimerController& timerController,
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler);
|
||||||
void Start();
|
void Start();
|
||||||
void PushMessage(Display::Messages msg);
|
void PushMessage(Display::Messages msg);
|
||||||
|
|
||||||
|
@ -81,6 +84,7 @@ namespace Pinetime {
|
||||||
Pinetime::Controllers::MotorController& motorController;
|
Pinetime::Controllers::MotorController& motorController;
|
||||||
Pinetime::Controllers::MotionController& motionController;
|
Pinetime::Controllers::MotionController& motionController;
|
||||||
Pinetime::Controllers::TimerController& timerController;
|
Pinetime::Controllers::TimerController& timerController;
|
||||||
|
Pinetime::Controllers::TouchHandler& touchHandler;
|
||||||
|
|
||||||
Pinetime::Controllers::FirmwareValidator validator;
|
Pinetime::Controllers::FirmwareValidator validator;
|
||||||
Controllers::BrightnessController brightnessController;
|
Controllers::BrightnessController brightnessController;
|
||||||
|
@ -102,7 +106,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
TouchModes touchMode = TouchModes::Gestures;
|
TouchModes touchMode = TouchModes::Gestures;
|
||||||
|
|
||||||
TouchEvents OnTouchEvent();
|
TouchEvents GetGesture();
|
||||||
void RunningState();
|
void RunningState();
|
||||||
void IdleState();
|
void IdleState();
|
||||||
static void Process(void* instance);
|
static void Process(void* instance);
|
||||||
|
|
|
@ -166,18 +166,17 @@ 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) {
|
void LittleVgl::SetNewTapEvent(uint16_t x, uint16_t y, bool contact) {
|
||||||
tap_x = x;
|
tap_x = x;
|
||||||
tap_y = y;
|
tap_y = y;
|
||||||
tapped = true;
|
tapped = contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) {
|
||||||
if (tapped) {
|
|
||||||
ptr->point.x = tap_x;
|
ptr->point.x = tap_x;
|
||||||
ptr->point.y = tap_y;
|
ptr->point.y = tap_y;
|
||||||
|
if (tapped) {
|
||||||
ptr->state = LV_INDEV_STATE_PR;
|
ptr->state = LV_INDEV_STATE_PR;
|
||||||
tapped = false;
|
|
||||||
} else {
|
} else {
|
||||||
ptr->state = LV_INDEV_STATE_REL;
|
ptr->state = LV_INDEV_STATE_REL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
void SetNewTapEvent(uint16_t x, uint16_t y, bool contact);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitDisplay();
|
void InitDisplay();
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace Pinetime {
|
||||||
UpdateDateTime,
|
UpdateDateTime,
|
||||||
UpdateBleConnection,
|
UpdateBleConnection,
|
||||||
UpdateBatteryLevel,
|
UpdateBatteryLevel,
|
||||||
TouchEvent,
|
|
||||||
ButtonPushed,
|
ButtonPushed,
|
||||||
NewNotification,
|
NewNotification,
|
||||||
TimerDone,
|
TimerDone,
|
||||||
|
|
|
@ -66,10 +66,10 @@ bool FirmwareValidation::Refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
if (object == buttonValidate && event == LV_EVENT_PRESSED) {
|
if (object == buttonValidate && event == LV_EVENT_CLICKED) {
|
||||||
validator.Validate();
|
validator.Validate();
|
||||||
running = false;
|
running = false;
|
||||||
} else if (object == buttonReset && event == LV_EVENT_PRESSED) {
|
} else if (object == buttonReset && event == LV_EVENT_CLICKED) {
|
||||||
validator.Reset();
|
validator.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ bool List::Refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_RELEASED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
for (int i = 0; i < MAXLISTITEMS; i++) {
|
for (int i = 0; i < MAXLISTITEMS; i++) {
|
||||||
if (apps[i] != Apps::None && object == itemApps[i]) {
|
if (apps[i] != Apps::None && object == itemApps[i]) {
|
||||||
app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up);
|
app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up);
|
||||||
|
|
|
@ -83,12 +83,9 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
|
||||||
lv_obj_set_height(playPause, 39);
|
lv_obj_set_height(playPause, 39);
|
||||||
playPauseLabel = lv_label_create(playPause, nullptr);
|
playPauseLabel = lv_label_create(playPause, nullptr);
|
||||||
lv_label_set_text(playPauseLabel, Symbols::play);
|
lv_label_set_text(playPauseLabel, Symbols::play);
|
||||||
|
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Polling);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Metronome::~Metronome() {
|
Metronome::~Metronome() {
|
||||||
app->SetTouchMode(DisplayApp::TouchModes::Gestures);
|
|
||||||
systemTask.PushMessage(System::Messages::EnableSleeping);
|
systemTask.PushMessage(System::Messages::EnableSleeping);
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ bool StopWatch::Refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
|
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
|
||||||
if (event != LV_EVENT_PRESSED) {
|
if (event != LV_EVENT_CLICKED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentState == States::Init) {
|
if (currentState == States::Init) {
|
||||||
|
@ -174,7 +174,7 @@ void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
|
void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
|
||||||
if (event != LV_EVENT_PRESSED) {
|
if (event != LV_EVENT_CLICKED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If running, then this button is used to save laps
|
// If running, then this button is used to save laps
|
||||||
|
|
|
@ -210,7 +210,7 @@ bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
TaskStatus_t tasksStatus[7];
|
TaskStatus_t tasksStatus[10];
|
||||||
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
|
lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL);
|
||||||
lv_table_set_col_cnt(infoTask, 3);
|
lv_table_set_col_cnt(infoTask, 3);
|
||||||
lv_table_set_row_cnt(infoTask, 8);
|
lv_table_set_row_cnt(infoTask, 8);
|
||||||
|
@ -223,9 +223,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
|
||||||
lv_table_set_cell_value(infoTask, 0, 2, "Free");
|
lv_table_set_cell_value(infoTask, 0, 2, "Free");
|
||||||
lv_table_set_col_width(infoTask, 2, 90);
|
lv_table_set_col_width(infoTask, 2, 90);
|
||||||
|
|
||||||
auto nb = uxTaskGetSystemState(tasksStatus, 7, nullptr);
|
auto nb = uxTaskGetSystemState(tasksStatus, sizeof(tasksStatus) / sizeof(tasksStatus[0]), nullptr);
|
||||||
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
std::sort(tasksStatus, tasksStatus + nb, sortById);
|
||||||
for (uint8_t i = 0; i < nb; i++) {
|
for (uint8_t i = 0; i < nb && i < 7; i++) {
|
||||||
|
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
|
lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str());
|
||||||
lv_table_set_cell_value(infoTask, i + 1, 1, tasksStatus[i].pcTaskName);
|
lv_table_set_cell_value(infoTask, i + 1, 1, tasksStatus[i].pcTaskName);
|
||||||
|
|
|
@ -12,9 +12,7 @@ namespace {
|
||||||
|
|
||||||
static void event_handler(lv_obj_t* obj, lv_event_t event) {
|
static void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||||
Tile* screen = static_cast<Tile*>(obj->user_data);
|
Tile* screen = static_cast<Tile*>(obj->user_data);
|
||||||
uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data();
|
screen->OnObjectEvent(obj, event);
|
||||||
uint32_t eventData = *eventDataPtr;
|
|
||||||
screen->OnObjectEvent(obj, event, eventData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,9 +122,9 @@ bool Tile::Refresh() {
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) {
|
void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
|
app->StartApp(apps[lv_btnmatrix_get_active_btn(obj)], DisplayApp::FullRefreshDirections::Up);
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Pinetime {
|
||||||
|
|
||||||
bool Refresh() override;
|
bool Refresh() override;
|
||||||
void UpdateScreen();
|
void UpdateScreen();
|
||||||
void OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId);
|
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Pinetime::Controllers::Battery& batteryController;
|
Pinetime::Controllers::Battery& batteryController;
|
||||||
|
|
|
@ -125,12 +125,12 @@ void QuickSettings::UpdateScreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
if (object == btn2 && event == LV_EVENT_PRESSED) {
|
if (object == btn2 && event == LV_EVENT_CLICKED) {
|
||||||
|
|
||||||
running = false;
|
running = false;
|
||||||
app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None);
|
app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None);
|
||||||
|
|
||||||
} else if (object == btn1 && event == LV_EVENT_PRESSED) {
|
} else if (object == btn1 && event == LV_EVENT_CLICKED) {
|
||||||
|
|
||||||
brightness.Step();
|
brightness.Step();
|
||||||
lv_label_set_text_static(btn1_lvl, brightness.GetIcon());
|
lv_label_set_text_static(btn1_lvl, brightness.GetIcon());
|
||||||
|
@ -147,7 +147,7 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
|
||||||
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
|
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (object == btn4 && event == LV_EVENT_PRESSED) {
|
} else if (object == btn4 && event == LV_EVENT_CLICKED) {
|
||||||
running = false;
|
running = false;
|
||||||
settingsController.SetSettingsMenu(0);
|
settingsController.SetSettingsMenu(0);
|
||||||
app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up);
|
app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up);
|
||||||
|
|
|
@ -85,7 +85,7 @@ bool SettingDisplay::Refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
|
||||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
if (event == LV_EVENT_CLICKED) {
|
||||||
for (int i = 0; i < optionsTotal; i++) {
|
for (int i = 0; i < optionsTotal; i++) {
|
||||||
if (object == cbOption[i]) {
|
if (object == cbOption[i]) {
|
||||||
lv_checkbox_set_checked(cbOption[i], true);
|
lv_checkbox_set_checked(cbOption[i], true);
|
||||||
|
|
|
@ -40,6 +40,16 @@ void Cst816S::Init() {
|
||||||
*/
|
*/
|
||||||
static constexpr uint8_t motionMask = 0b00000101;
|
static constexpr uint8_t motionMask = 0b00000101;
|
||||||
twiMaster.Write(twiAddress, 0xEC, &motionMask, 1);
|
twiMaster.Write(twiAddress, 0xEC, &motionMask, 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
[7] EnTest - Interrupt pin to test, enable automatic periodic issued after a low pulse.
|
||||||
|
[6] EnTouch - When a touch is detected, a periodic pulsed Low.
|
||||||
|
[5] EnChange - Upon detecting a touch state changes, pulsed Low.
|
||||||
|
[4] EnMotion - When the detected gesture is pulsed Low.
|
||||||
|
[0] OnceWLP - Press gesture only issue a pulse signal is low.
|
||||||
|
*/
|
||||||
|
static constexpr uint8_t irqCtl = 0b01110000;
|
||||||
|
twiMaster.Write(twiAddress, 0xFA, &irqCtl, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
Cst816S::TouchInfos Cst816S::GetTouchInfo() {
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -43,6 +43,7 @@
|
||||||
#include "drivers/TwiMaster.h"
|
#include "drivers/TwiMaster.h"
|
||||||
#include "drivers/Cst816s.h"
|
#include "drivers/Cst816s.h"
|
||||||
#include "systemtask/SystemTask.h"
|
#include "systemtask/SystemTask.h"
|
||||||
|
#include "touchhandler/TouchHandler.h"
|
||||||
|
|
||||||
#if NRF_LOG_ENABLED
|
#if NRF_LOG_ENABLED
|
||||||
#include "logging/NrfLogger.h"
|
#include "logging/NrfLogger.h"
|
||||||
|
@ -118,6 +119,7 @@ Pinetime::Drivers::WatchdogView watchdogView(watchdog);
|
||||||
Pinetime::Controllers::NotificationManager notificationManager;
|
Pinetime::Controllers::NotificationManager notificationManager;
|
||||||
Pinetime::Controllers::MotionController motionController;
|
Pinetime::Controllers::MotionController motionController;
|
||||||
Pinetime::Controllers::TimerController timerController;
|
Pinetime::Controllers::TimerController timerController;
|
||||||
|
Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl);
|
||||||
|
|
||||||
Pinetime::Controllers::FS fs {spiNorFlash};
|
Pinetime::Controllers::FS fs {spiNorFlash};
|
||||||
Pinetime::Controllers::Settings settingsController {fs};
|
Pinetime::Controllers::Settings settingsController {fs};
|
||||||
|
@ -136,7 +138,8 @@ Pinetime::Applications::DisplayApp displayApp(lcd,
|
||||||
settingsController,
|
settingsController,
|
||||||
motorController,
|
motorController,
|
||||||
motionController,
|
motionController,
|
||||||
timerController);
|
timerController,
|
||||||
|
touchHandler);
|
||||||
|
|
||||||
Pinetime::System::SystemTask systemTask(spi,
|
Pinetime::System::SystemTask systemTask(spi,
|
||||||
lcd,
|
lcd,
|
||||||
|
@ -162,7 +165,7 @@ Pinetime::System::SystemTask systemTask(spi,
|
||||||
|
|
||||||
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
||||||
if (pin == pinTouchIrq) {
|
if (pin == pinTouchIrq) {
|
||||||
systemTask.OnTouchEvent();
|
touchHandler.WakeUp();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +312,10 @@ int main(void) {
|
||||||
lvgl.Init();
|
lvgl.Init();
|
||||||
|
|
||||||
systemTask.Start();
|
systemTask.Start();
|
||||||
|
|
||||||
|
touchHandler.Register(&systemTask);
|
||||||
|
touchHandler.Start();
|
||||||
|
|
||||||
nimble_port_init();
|
nimble_port_init();
|
||||||
|
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|
|
@ -397,7 +397,6 @@ void SystemTask::OnTouchEvent() {
|
||||||
return;
|
return;
|
||||||
if (!isSleeping) {
|
if (!isSleeping) {
|
||||||
PushMessage(Messages::OnTouchEvent);
|
PushMessage(Messages::OnTouchEvent);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
|
|
||||||
} else if (!isWakingUp) {
|
} else if (!isWakingUp) {
|
||||||
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or
|
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||||
|
|
70
src/touchhandler/TouchHandler.cpp
Normal file
70
src/touchhandler/TouchHandler.cpp
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#include "TouchHandler.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
|
TouchHandler::TouchHandler(Drivers::Cst816S& touchPanel, Components::LittleVgl& lvgl)
|
||||||
|
: touchPanel {touchPanel},
|
||||||
|
lvgl {lvgl} {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::CancelTap() {
|
||||||
|
isCancelled = true;
|
||||||
|
lvgl.SetNewTapEvent(-1, -1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Pinetime::Drivers::Cst816S::Gestures TouchHandler::GestureGet() {
|
||||||
|
auto returnGesture = gesture;
|
||||||
|
gesture = Drivers::Cst816S::Gestures::None;
|
||||||
|
return returnGesture;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::Start() {
|
||||||
|
if (pdPASS != xTaskCreate(TouchHandler::Process, "Touch", 80, this, 0, &taskHandle)) {
|
||||||
|
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::Process(void* instance) {
|
||||||
|
auto* app = static_cast<TouchHandler*>(instance);
|
||||||
|
app->Work();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::Work() {
|
||||||
|
Pinetime::Drivers::Cst816S::TouchInfos info;
|
||||||
|
while (true) {
|
||||||
|
vTaskSuspend(taskHandle);
|
||||||
|
info = touchPanel.GetTouchInfo();
|
||||||
|
if (systemTask->IsSleeping()) {
|
||||||
|
systemTask->PushMessage(System::Messages::TouchWakeUp);
|
||||||
|
} else {
|
||||||
|
x = info.x;
|
||||||
|
y = info.y;
|
||||||
|
if (info.action == 0) {
|
||||||
|
lvgl.SetNewTapEvent(info.x, info.y, true);
|
||||||
|
} else if (info.action == 1) {
|
||||||
|
lvgl.SetNewTapEvent(info.x, info.y, false);
|
||||||
|
prevGesture = Pinetime::Drivers::Cst816S::Gestures::None;
|
||||||
|
isCancelled = false;
|
||||||
|
} else if (info.action == 2) {
|
||||||
|
if (!isCancelled) {
|
||||||
|
lvgl.SetNewTapEvent(info.x, info.y, true);
|
||||||
|
}
|
||||||
|
if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
|
||||||
|
if (prevGesture != info.gesture) {
|
||||||
|
prevGesture = info.gesture;
|
||||||
|
gesture = info.gesture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
systemTask->OnTouchEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::Register(Pinetime::System::SystemTask* systemTask) {
|
||||||
|
this->systemTask = systemTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchHandler::WakeUp() {
|
||||||
|
vTaskResume(taskHandle);
|
||||||
|
}
|
45
src/touchhandler/TouchHandler.h
Normal file
45
src/touchhandler/TouchHandler.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#pragma once
|
||||||
|
#include "drivers/Cst816s.h"
|
||||||
|
#include "systemtask/SystemTask.h"
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <task.h>
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Components {
|
||||||
|
class LittleVgl;
|
||||||
|
}
|
||||||
|
namespace Drivers {
|
||||||
|
class Cst816S;
|
||||||
|
}
|
||||||
|
namespace System {
|
||||||
|
class SystemTask;
|
||||||
|
}
|
||||||
|
namespace Controllers {
|
||||||
|
class TouchHandler {
|
||||||
|
public:
|
||||||
|
explicit TouchHandler(Drivers::Cst816S&, Components::LittleVgl&);
|
||||||
|
void CancelTap();
|
||||||
|
void Register(Pinetime::System::SystemTask* systemTask);
|
||||||
|
void Start();
|
||||||
|
void WakeUp();
|
||||||
|
uint8_t GetX() const {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
uint8_t GetY() const {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
Drivers::Cst816S::Gestures GestureGet();
|
||||||
|
private:
|
||||||
|
static void Process(void* instance);
|
||||||
|
void Work();
|
||||||
|
Pinetime::System::SystemTask* systemTask = nullptr;
|
||||||
|
TaskHandle_t taskHandle;
|
||||||
|
Pinetime::Drivers::Cst816S& touchPanel;
|
||||||
|
Pinetime::Components::LittleVgl& lvgl;
|
||||||
|
Pinetime::Drivers::Cst816S::Gestures gesture;
|
||||||
|
Pinetime::Drivers::Cst816S::Gestures prevGesture;
|
||||||
|
bool isCancelled = false;
|
||||||
|
uint8_t x, y;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user