From ee530baaa05faeb246392cd2ac0ee66e79af49db Mon Sep 17 00:00:00 2001 From: JF Date: Fri, 3 Jan 2020 16:32:31 +0100 Subject: Add basic touch panel driver. Handle touch event in display app : draw a big square at the touch point coordinates. --- src/DisplayApp/DisplayApp.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/DisplayApp/DisplayApp.cpp') diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 20704c0d..2a26f189 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -8,6 +8,7 @@ #include "Components/Gfx/Gfx.h" #include #include +#include using namespace Pinetime::Applications; @@ -56,7 +57,6 @@ void DisplayApp::Process(void *instance) { auto *app = static_cast(instance); NRF_LOG_INFO("DisplayApp task started!"); app->InitHw(); - while (1) { app->Refresh(); } @@ -101,6 +101,8 @@ void DisplayApp::InitHw() { gfx->DrawString(10, 0, 0x0000, "BLE", &smallFont, false); gfx->DrawString(20, 180, 0xffff, "", &smallFont, false); + + touchPanel.Init(); } void DisplayApp::Refresh() { @@ -148,6 +150,10 @@ void DisplayApp::Refresh() { case Messages::UpdateBatteryLevel: batteryLevelUpdated = true; break; + case Messages::TouchEvent: + if(state != States::Running) break; + OnTouchEvent(); + break; } } } @@ -247,3 +253,13 @@ void DisplayApp::PushMessage(DisplayApp::Messages msg) { // TODO : should I do something here? } } + +static uint16_t pointColor = 0x07e0; +void DisplayApp::OnTouchEvent() { + auto info = touchPanel.GetTouchInfo(); + + if(info.isTouch) { + lcd->FillRectangle(info.x-10, info.y-10, 20,20, pointColor); + pointColor+=10; + } +} -- cgit v1.2.3-70-g09d2