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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,8 @@
|
||||
#include <Components/Ble/BleController.h>
|
||||
#include <Components/DateTime/DateTimeController.h>
|
||||
#include "lcdfont14.h"
|
||||
#include "../drivers/Cst816s.h"
|
||||
|
||||
|
||||
extern const FONT_INFO lCD_70ptFontInfo;
|
||||
|
||||
@@ -18,7 +20,7 @@ namespace Pinetime {
|
||||
class DisplayApp {
|
||||
public:
|
||||
enum class States {Idle, Running};
|
||||
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel} ;
|
||||
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent} ;
|
||||
DisplayApp(Controllers::Battery &batteryController,
|
||||
Controllers::Ble &bleController,
|
||||
Controllers::DateTime& dateTimeController);
|
||||
@@ -59,11 +61,11 @@ namespace Pinetime {
|
||||
bool batteryLevelUpdated = false;
|
||||
|
||||
static char const *DaysString[];
|
||||
|
||||
static char const *MonthsString[];
|
||||
|
||||
bool dateUpdated = false;
|
||||
|
||||
Pinetime::Drivers::Cst816S touchPanel;
|
||||
void OnTouchEvent();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user