summaryrefslogtreecommitdiff
path: root/src/DisplayApp
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2020-01-26 15:44:26 +0100
committerGitHub <noreply@github.com>2020-01-26 15:44:26 +0100
commit7c03810f46ff1f7accd2f5adb7404b4f2cb723d9 (patch)
treef720612013c3518b54ecd22ccfc5aef6917d3023 /src/DisplayApp
parent9dc4e32e36eb1167ee241cdf8027089cad593cf1 (diff)
parent6491a7c3a0738d6e6ef3bf57da460f61298d1cd9 (diff)
Merge pull request #19 from JF002/spi-dma
Spi dma
Diffstat (limited to 'src/DisplayApp')
-rw-r--r--src/DisplayApp/DisplayApp.cpp46
-rw-r--r--src/DisplayApp/DisplayApp.h19
-rw-r--r--src/DisplayApp/Screens/Clock.cpp8
-rw-r--r--src/DisplayApp/Screens/Message.cpp2
4 files changed, 28 insertions, 47 deletions
diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp
index 3b7007af..ca139423 100644
--- a/src/DisplayApp/DisplayApp.cpp
+++ b/src/DisplayApp/DisplayApp.cpp
@@ -14,25 +14,19 @@
using namespace Pinetime::Applications;
-DisplayApp::DisplayApp(Controllers::Battery &batteryController,
+DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd,
+ Pinetime::Components::Gfx& gfx,
+ Pinetime::Drivers::Cst816S& touchPanel,
+ Controllers::Battery &batteryController,
Controllers::Ble &bleController,
Controllers::DateTime &dateTimeController) :
- spi{Drivers::SpiMaster::SpiModule::SPI0, {
- Drivers::SpiMaster::BitOrder::Msb_Lsb,
- Drivers::SpiMaster::Modes::Mode3,
- Drivers::SpiMaster::Frequencies::Freq8Mhz,
- pinSpiSck,
- pinSpiMosi,
- pinSpiMiso,
- pinSpiCsn
- }},
- lcd{new Drivers::St7789(spi, pinLcdDataCommand)},
- gfx{new Components::Gfx(*lcd.get()) },
+ lcd{lcd},
+ gfx{gfx},
+ touchPanel{touchPanel},
batteryController{batteryController},
bleController{bleController},
dateTimeController{dateTimeController},
- clockScreen{*(gfx.get())}/*,
- messageScreen{*(gfx.get())}*/ {
+ clockScreen{gfx} {
msgQueue = xQueueCreate(queueSize, itemSize);
currentScreen = &clockScreen;
}
@@ -59,12 +53,12 @@ void DisplayApp::InitHw() {
nrf_gpio_pin_clear(pinLcdBacklight2);
nrf_gpio_pin_clear(pinLcdBacklight3);
- spi.Init();
- gfx->Init();
currentScreen->Refresh(true);
- touchPanel.Init();
}
+uint32_t acc = 0;
+uint32_t count = 0;
+bool toggle = true;
void DisplayApp::Refresh() {
TickType_t queueTimeout;
switch (state) {
@@ -87,16 +81,16 @@ void DisplayApp::Refresh() {
nrf_gpio_pin_set(pinLcdBacklight2);
vTaskDelay(100);
nrf_gpio_pin_set(pinLcdBacklight1);
- lcd->DisplayOff();
- lcd->Sleep();
+ lcd.DisplayOff();
+ lcd.Sleep();
touchPanel.Sleep();
state = States::Idle;
break;
case Messages::GoToRunning:
- lcd->Wakeup();
+ lcd.Wakeup();
touchPanel.Wakeup();
- lcd->DisplayOn();
+ lcd.DisplayOn();
nrf_gpio_pin_clear(pinLcdBacklight3);
nrf_gpio_pin_clear(pinLcdBacklight2);
nrf_gpio_pin_clear(pinLcdBacklight1);
@@ -124,16 +118,8 @@ void DisplayApp::RunningState() {
if(currentScreen != nullptr) {
currentScreen->Refresh(false);
}
-
-// if(screenState) {
-// currentScreen = &clockScreen;
-// } else {
-// currentScreen = &messageScreen;
-// }
-// screenState = !screenState;
}
-
void DisplayApp::IdleState() {
}
@@ -153,7 +139,7 @@ void DisplayApp::OnTouchEvent() {
auto info = touchPanel.GetTouchInfo();
if(info.isTouch) {
- lcd->FillRectangle(info.x-10, info.y-10, 20,20, pointColor);
+ gfx.FillRectangle(info.x-10, info.y-10, 20,20, pointColor);
pointColor+=10;
}
}
diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h
index 5fb8f6f8..5a5d3ee6 100644
--- a/src/DisplayApp/DisplayApp.h
+++ b/src/DisplayApp/DisplayApp.h
@@ -23,7 +23,10 @@ namespace Pinetime {
public:
enum class States {Idle, Running};
enum class Messages : uint8_t {GoToSleep, GoToRunning, UpdateDateTime, UpdateBleConnection, UpdateBatteryLevel, TouchEvent} ;
- DisplayApp(Controllers::Battery &batteryController,
+ DisplayApp(Pinetime::Drivers::St7789& lcd,
+ Pinetime::Components::Gfx& gfx,
+ Pinetime::Drivers::Cst816S&,
+ Controllers::Battery &batteryController,
Controllers::Ble &bleController,
Controllers::DateTime& dateTimeController);
void Start();
@@ -33,9 +36,8 @@ namespace Pinetime {
TaskHandle_t taskHandle;
static void Process(void* instance);
void InitHw();
- Pinetime::Drivers::SpiMaster spi;
- std::unique_ptr<Drivers::St7789> lcd;
- std::unique_ptr<Components::Gfx> gfx;
+ Pinetime::Drivers::St7789& lcd;
+ Pinetime::Components::Gfx& gfx;
const FONT_INFO largeFont {lCD_70ptFontInfo.height, lCD_70ptFontInfo.startChar, lCD_70ptFontInfo.endChar, lCD_70ptFontInfo.spacePixels, lCD_70ptFontInfo.charInfo, lCD_70ptFontInfo.data};
const FONT_INFO smallFont {lCD_14ptFontInfo.height, lCD_14ptFontInfo.startChar, lCD_14ptFontInfo.endChar, lCD_14ptFontInfo.spacePixels, lCD_14ptFontInfo.charInfo, lCD_14ptFontInfo.data};
void Refresh();
@@ -52,18 +54,11 @@ namespace Pinetime {
Pinetime::Controllers::Ble &bleController;
Pinetime::Controllers::DateTime& dateTimeController;
- Pinetime::Drivers::Cst816S touchPanel;
+ Pinetime::Drivers::Cst816S& touchPanel;
void OnTouchEvent();
Screens::Clock clockScreen;
Screens::Screen* currentScreen = nullptr;
-// Screens::Message messageScreen;
-// bool screenState = false;
- static constexpr uint8_t pinSpiSck = 2;
- static constexpr uint8_t pinSpiMosi = 3;
- static constexpr uint8_t pinSpiMiso = 4;
- static constexpr uint8_t pinSpiCsn = 25;
- static constexpr uint8_t pinLcdDataCommand = 18;
static constexpr uint8_t pinLcdBacklight1 = 14;
static constexpr uint8_t pinLcdBacklight2 = 22;
static constexpr uint8_t pinLcdBacklight3 = 23;
diff --git a/src/DisplayApp/Screens/Clock.cpp b/src/DisplayApp/Screens/Clock.cpp
index 153f4f2e..155cb581 100644
--- a/src/DisplayApp/Screens/Clock.cpp
+++ b/src/DisplayApp/Screens/Clock.cpp
@@ -9,10 +9,10 @@ using namespace Pinetime::Applications::Screens;
void Clock::Refresh(bool fullRefresh) {
if(fullRefresh) {
gfx.FillRectangle(0,0,240,240,0x0000);
- currentChar[0] = 0;
- currentChar[1] = 0;
- currentChar[2] = 0;
- currentChar[3] = 0;
+ currentChar[0] = 1;
+ currentChar[1] = 2;
+ currentChar[2] = 3;
+ currentChar[3] = 4;
auto dummy = currentDateTime.Get();
}
diff --git a/src/DisplayApp/Screens/Message.cpp b/src/DisplayApp/Screens/Message.cpp
index 2ade4349..121e34b9 100644
--- a/src/DisplayApp/Screens/Message.cpp
+++ b/src/DisplayApp/Screens/Message.cpp
@@ -9,6 +9,6 @@ using namespace Pinetime::Applications::Screens;
void Message::Refresh(bool fullRefresh) {
if(fullRefresh) {
gfx.FillRectangle(0,0,240,240,0xffff);
- gfx.DrawString(120, 10, 0x0000, "COUCOU", &smallFont, false);
+ gfx.DrawString(120, 10, 0x5555, "COUCOU", &smallFont, false);
}
}