Update
This commit is contained in:
parent
329482f873
commit
3e42297bd8
|
@ -21,7 +21,7 @@ namespace Pinetime {
|
|||
uint16_t y = 0;
|
||||
Gestures gesture = Gestures::None;
|
||||
bool touching = false;
|
||||
bool isValid = false;
|
||||
bool isValid = true;
|
||||
};
|
||||
|
||||
Cst816S(TwiMaster& twiMaster, uint8_t twiAddress);
|
||||
|
|
|
@ -315,9 +315,6 @@ int main(void) {
|
|||
|
||||
systemTask.Start();
|
||||
|
||||
touchHandler.Register(&systemTask);
|
||||
touchHandler.Start();
|
||||
|
||||
nimble_port_init();
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
|
|
@ -144,6 +144,9 @@ void SystemTask::Work() {
|
|||
heartRateSensor.Disable();
|
||||
heartRateApp.Start();
|
||||
|
||||
touchHandler.Register(this);
|
||||
touchHandler.Start();
|
||||
|
||||
nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_High);
|
||||
nrf_gpio_cfg_output(15);
|
||||
nrf_gpio_pin_set(15);
|
||||
|
|
|
@ -30,37 +30,39 @@ void TouchHandler::Process(void* instance) {
|
|||
}
|
||||
|
||||
void TouchHandler::Work() {
|
||||
Pinetime::Drivers::Cst816S::Gestures prevGesture = Pinetime::Drivers::Cst816S::Gestures::None;
|
||||
bool slideReleased = true;
|
||||
while (true) {
|
||||
vTaskSuspend(taskHandle);
|
||||
|
||||
info = touchPanel.GetTouchInfo();
|
||||
|
||||
if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
|
||||
if (prevGesture != info.gesture) {
|
||||
if (info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideDown || info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideLeft ||
|
||||
info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideUp || info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideRight) {
|
||||
prevGesture = info.gesture;
|
||||
if (info.isValid) {
|
||||
if (info.gesture != Pinetime::Drivers::Cst816S::Gestures::None) {
|
||||
if (slideReleased) {
|
||||
if (info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideDown ||
|
||||
info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideLeft ||
|
||||
info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideUp ||
|
||||
info.gesture == Pinetime::Drivers::Cst816S::Gestures::SlideRight) {
|
||||
slideReleased = false;
|
||||
}
|
||||
gesture = info.gesture;
|
||||
}
|
||||
gesture = info.gesture;
|
||||
}
|
||||
}
|
||||
|
||||
if (systemTask->IsSleeping()) {
|
||||
systemTask->PushMessage(System::Messages::TouchWakeUp);
|
||||
} else {
|
||||
if (info.touching) {
|
||||
if (!isCancelled) {
|
||||
lvgl.SetNewTouchPoint(info.x, info.y, true);
|
||||
}
|
||||
} else {
|
||||
if (isCancelled) {
|
||||
lvgl.SetNewTouchPoint(-1, -1, false);
|
||||
isCancelled = false;
|
||||
if (!systemTask->IsSleeping()) {
|
||||
if (info.touching) {
|
||||
if (!isCancelled) {
|
||||
lvgl.SetNewTouchPoint(info.x, info.y, true);
|
||||
}
|
||||
} else {
|
||||
lvgl.SetNewTouchPoint(info.x, info.y, false);
|
||||
if (isCancelled) {
|
||||
lvgl.SetNewTouchPoint(-1, -1, false);
|
||||
isCancelled = false;
|
||||
} else {
|
||||
lvgl.SetNewTouchPoint(info.x, info.y, false);
|
||||
}
|
||||
slideReleased = true;
|
||||
}
|
||||
prevGesture = Pinetime::Drivers::Cst816S::Gestures::None;
|
||||
}
|
||||
systemTask->OnTouchEvent();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue