diff options
| author | JF <jf@codingfield.com> | 2020-01-03 15:32:31 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-01-03 15:32:31 (GMT) |
| commit | ee530baaa05faeb246392cd2ac0ee66e79af49db (patch) | |
| tree | 0fa4254e99d33bd065c3dd3a19157f125d053fc5 /src/DisplayApp/DisplayApp.cpp | |
| parent | 27d0e1e02f97912ae2a18a0254060a546d2fc42b (diff) | |
Add basic touch panel driver.
Handle touch event in display app : draw a big square at the touch point coordinates.
Diffstat (limited to 'src/DisplayApp/DisplayApp.cpp')
| -rw-r--r-- | src/DisplayApp/DisplayApp.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 20704c0..2a26f18 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -8,6 +8,7 @@ #include "Components/Gfx/Gfx.h" #include <queue.h> #include <Components/DateTime/DateTimeController.h> +#include <drivers/Cst816s.h> using namespace Pinetime::Applications; @@ -56,7 +57,6 @@ void DisplayApp::Process(void *instance) { auto *app = static_cast<DisplayApp *>(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; + } +} |
