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/Clock.cpp
|
||||
DisplayApp/Screens/Message.cpp
|
||||
DisplayApp/Screens/Rainbow.cpp
|
||||
main.cpp
|
||||
drivers/St7789.cpp
|
||||
drivers/SpiMaster.cpp
|
||||
|
@ -60,6 +61,7 @@ set(INCLUDE_FILES
|
|||
DisplayApp/Screens/Screen.h
|
||||
DisplayApp/Screens/Clock.h
|
||||
DisplayApp/Screens/Message.h
|
||||
DisplayApp/Screens/Rainbow.h
|
||||
drivers/St7789.h
|
||||
drivers/SpiMaster.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) {
|
||||
SetBackgroundColor(color);
|
||||
|
||||
state.remainingIterations = 240 + 1;
|
||||
state.remainingIterations = h;
|
||||
state.currentIteration = 0;
|
||||
state.busy = true;
|
||||
state.action = Action::FillRectangle;
|
||||
|
|
|
@ -26,9 +26,10 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd,
|
|||
batteryController{batteryController},
|
||||
bleController{bleController},
|
||||
dateTimeController{dateTimeController},
|
||||
clockScreen{gfx} {
|
||||
clockScreen{gfx},
|
||||
rainbowScreen{gfx} {
|
||||
msgQueue = xQueueCreate(queueSize, itemSize);
|
||||
currentScreen = &clockScreen;
|
||||
currentScreen = &rainbowScreen;
|
||||
}
|
||||
|
||||
void DisplayApp::Start() {
|
||||
|
@ -68,7 +69,7 @@ void DisplayApp::Refresh() {
|
|||
break;
|
||||
case States::Running:
|
||||
RunningState();
|
||||
queueTimeout = 1;
|
||||
queueTimeout = 50;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -139,7 +140,12 @@ void DisplayApp::OnTouchEvent() {
|
|||
auto info = touchPanel.GetTouchInfo();
|
||||
|
||||
if(info.isTouch) {
|
||||
gfx.FillRectangle(info.x-10, info.y-10, 20,20, pointColor);
|
||||
pointColor+=10;
|
||||
if(currentScreen == &clockScreen)
|
||||
currentScreen = &rainbowScreen;
|
||||
else {
|
||||
gfx.SetScrollStartLine(0);
|
||||
currentScreen = &clockScreen;
|
||||
}
|
||||
currentScreen->Refresh(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <date/date.h>
|
||||
#include <DisplayApp/Screens/Clock.h>
|
||||
#include <DisplayApp/Screens/Message.h>
|
||||
#include <DisplayApp/Screens/Rainbow.h>
|
||||
|
||||
extern const FONT_INFO lCD_70ptFontInfo;
|
||||
|
||||
|
@ -58,6 +59,7 @@ namespace Pinetime {
|
|||
void OnTouchEvent();
|
||||
|
||||
Screens::Clock clockScreen;
|
||||
Screens::Rainbow rainbowScreen;
|
||||
Screens::Screen* currentScreen = nullptr;
|
||||
static constexpr uint8_t pinLcdBacklight1 = 14;
|
||||
static constexpr uint8_t pinLcdBacklight2 = 22;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "Clock.h"
|
||||
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
uint16_t line = 0;
|
||||
void Clock::Refresh(bool fullRefresh) {
|
||||
if(fullRefresh) {
|
||||
gfx.FillRectangle(0,0,240,240,0x0000);
|
||||
|
@ -14,14 +13,9 @@ void Clock::Refresh(bool fullRefresh) {
|
|||
currentChar[2] = 3;
|
||||
currentChar[3] = 4;
|
||||
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()) {
|
||||
char batteryChar[11];
|
||||
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