Add basic touch panel driver.

Handle touch event in display app : draw a big square at the touch point coordinates.
This commit is contained in:
JF
2020-01-03 16:32:31 +01:00
parent 27d0e1e02f
commit ee530baaa0
8 changed files with 179 additions and 103 deletions
+17 -1
View File
@@ -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;
}
}