Switch from clock to rainbow using touchscreen.
This commit is contained in:
parent
7785e3bcfe
commit
0aa636834c
|
@ -36,6 +36,7 @@ list(APPEND SOURCE_FILES
|
||||||
DisplayApp/Screens/Screen.cpp
|
DisplayApp/Screens/Screen.cpp
|
||||||
DisplayApp/Screens/Clock.cpp
|
DisplayApp/Screens/Clock.cpp
|
||||||
DisplayApp/Screens/Message.cpp
|
DisplayApp/Screens/Message.cpp
|
||||||
|
DisplayApp/Screens/Rainbow.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
drivers/St7789.cpp
|
drivers/St7789.cpp
|
||||||
drivers/SpiMaster.cpp
|
drivers/SpiMaster.cpp
|
||||||
|
@ -60,6 +61,7 @@ set(INCLUDE_FILES
|
||||||
DisplayApp/Screens/Screen.h
|
DisplayApp/Screens/Screen.h
|
||||||
DisplayApp/Screens/Clock.h
|
DisplayApp/Screens/Clock.h
|
||||||
DisplayApp/Screens/Message.h
|
DisplayApp/Screens/Message.h
|
||||||
|
DisplayApp/Screens/Rainbow.h
|
||||||
drivers/St7789.h
|
drivers/St7789.h
|
||||||
drivers/SpiMaster.h
|
drivers/SpiMaster.h
|
||||||
Components/Gfx/Gfx.h
|
Components/Gfx/Gfx.h
|
||||||
|
|
|
@ -30,7 +30,7 @@ void Gfx::ClearScreen() {
|
||||||
void Gfx::FillRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t color) {
|
void Gfx::FillRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t color) {
|
||||||
SetBackgroundColor(color);
|
SetBackgroundColor(color);
|
||||||
|
|
||||||
state.remainingIterations = 240 + 1;
|
state.remainingIterations = h;
|
||||||
state.currentIteration = 0;
|
state.currentIteration = 0;
|
||||||
state.busy = true;
|
state.busy = true;
|
||||||
state.action = Action::FillRectangle;
|
state.action = Action::FillRectangle;
|
||||||
|
|
|
@ -26,9 +26,10 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd,
|
||||||
batteryController{batteryController},
|
batteryController{batteryController},
|
||||||
bleController{bleController},
|
bleController{bleController},
|
||||||
dateTimeController{dateTimeController},
|
dateTimeController{dateTimeController},
|
||||||
clockScreen{gfx} {
|
clockScreen{gfx},
|
||||||
|
rainbowScreen{gfx} {
|
||||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||||
currentScreen = &clockScreen;
|
currentScreen = &rainbowScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::Start() {
|
void DisplayApp::Start() {
|
||||||
|
@ -68,7 +69,7 @@ void DisplayApp::Refresh() {
|
||||||
break;
|
break;
|
||||||
case States::Running:
|
case States::Running:
|
||||||
RunningState();
|
RunningState();
|
||||||
queueTimeout = 1;
|
queueTimeout = 50;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +140,12 @@ void DisplayApp::OnTouchEvent() {
|
||||||
auto info = touchPanel.GetTouchInfo();
|
auto info = touchPanel.GetTouchInfo();
|
||||||
|
|
||||||
if(info.isTouch) {
|
if(info.isTouch) {
|
||||||
gfx.FillRectangle(info.x-10, info.y-10, 20,20, pointColor);
|
if(currentScreen == &clockScreen)
|
||||||
pointColor+=10;
|
currentScreen = &rainbowScreen;
|
||||||
|
else {
|
||||||
|
gfx.SetScrollStartLine(0);
|
||||||
|
currentScreen = &clockScreen;
|
||||||
|
}
|
||||||
|
currentScreen->Refresh(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <date/date.h>
|
#include <date/date.h>
|
||||||
#include <DisplayApp/Screens/Clock.h>
|
#include <DisplayApp/Screens/Clock.h>
|
||||||
#include <DisplayApp/Screens/Message.h>
|
#include <DisplayApp/Screens/Message.h>
|
||||||
|
#include <DisplayApp/Screens/Rainbow.h>
|
||||||
|
|
||||||
extern const FONT_INFO lCD_70ptFontInfo;
|
extern const FONT_INFO lCD_70ptFontInfo;
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ namespace Pinetime {
|
||||||
void OnTouchEvent();
|
void OnTouchEvent();
|
||||||
|
|
||||||
Screens::Clock clockScreen;
|
Screens::Clock clockScreen;
|
||||||
|
Screens::Rainbow rainbowScreen;
|
||||||
Screens::Screen* currentScreen = nullptr;
|
Screens::Screen* currentScreen = nullptr;
|
||||||
static constexpr uint8_t pinLcdBacklight1 = 14;
|
static constexpr uint8_t pinLcdBacklight1 = 14;
|
||||||
static constexpr uint8_t pinLcdBacklight2 = 22;
|
static constexpr uint8_t pinLcdBacklight2 = 22;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "Clock.h"
|
#include "Clock.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
uint16_t line = 0;
|
|
||||||
void Clock::Refresh(bool fullRefresh) {
|
void Clock::Refresh(bool fullRefresh) {
|
||||||
if(fullRefresh) {
|
if(fullRefresh) {
|
||||||
gfx.FillRectangle(0,0,240,240,0x0000);
|
gfx.FillRectangle(0,0,240,240,0x0000);
|
||||||
|
@ -14,14 +13,9 @@ void Clock::Refresh(bool fullRefresh) {
|
||||||
currentChar[2] = 3;
|
currentChar[2] = 3;
|
||||||
currentChar[3] = 4;
|
currentChar[3] = 4;
|
||||||
auto dummy = currentDateTime.Get();
|
auto dummy = currentDateTime.Get();
|
||||||
|
|
||||||
gfx.SetScrollArea(74, 78, 320-(78+74));
|
|
||||||
line = 74;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx.SetScrollStartLine(line);
|
|
||||||
line++;
|
|
||||||
if(line == 78+74) line = 74;
|
|
||||||
if (fullRefresh || batteryPercentRemaining.IsUpdated()) {
|
if (fullRefresh || batteryPercentRemaining.IsUpdated()) {
|
||||||
char batteryChar[11];
|
char batteryChar[11];
|
||||||
auto newBatteryValue = batteryPercentRemaining.Get();
|
auto newBatteryValue = batteryPercentRemaining.Get();
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#include "Rainbow.h"
|
||||||
|
|
||||||
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
void Rainbow::Refresh(bool fullRefresh) {
|
||||||
|
if(fullRefresh) {
|
||||||
|
gfx.FillRectangle(0, 0, 240, 240, 0x0000);
|
||||||
|
|
||||||
|
gfx.SetScrollArea(0, 240, 320 - 240);
|
||||||
|
scrollLine = 0;
|
||||||
|
b = 31;
|
||||||
|
r = 0;
|
||||||
|
g = 0;
|
||||||
|
step = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx.SetScrollStartLine(scrollLine);
|
||||||
|
|
||||||
|
switch(step) {
|
||||||
|
case 0:
|
||||||
|
if(r == 31) step = 1;
|
||||||
|
else r++;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if(b == 0) step = 2;
|
||||||
|
else b--;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if(g == 31) step = 3;
|
||||||
|
else g++;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if(r == 0) step = 4;
|
||||||
|
else r--;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if(b == 31) step = 5;
|
||||||
|
else b++;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if(g == 0) step = 0;
|
||||||
|
else g--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t color = (g & 0x1f) | ((r & 0x1f) << 6) | ((b & 0x1f) << 11);
|
||||||
|
|
||||||
|
// Invert the 2 byte from color to adapt to the lcd controller
|
||||||
|
uint8_t l = color & 0x00ffu;
|
||||||
|
uint8_t h = (color >> 8u) & 0x00ffu;
|
||||||
|
|
||||||
|
uint16_t c = h + (l << 8);
|
||||||
|
|
||||||
|
gfx.FillRectangle(0, scrollLine,240,1, c);
|
||||||
|
scrollLine+=1;
|
||||||
|
|
||||||
|
if(scrollLine == 240) scrollLine = 0;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Screen.h"
|
||||||
|
|
||||||
|
namespace Pinetime {
|
||||||
|
namespace Applications {
|
||||||
|
namespace Screens {
|
||||||
|
class Rainbow : public Screen{
|
||||||
|
public:
|
||||||
|
explicit Rainbow(Components::Gfx& gfx) : Screen(gfx) {}
|
||||||
|
|
||||||
|
void Refresh(bool fullRefresh) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16_t scrollLine = 0;
|
||||||
|
uint8_t r = 0;
|
||||||
|
uint8_t g = 0;
|
||||||
|
uint8_t b = 0;
|
||||||
|
|
||||||
|
uint8_t step = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue