Compare commits
2 Commits
rei/develo
...
scroll
Author | SHA1 | Date |
---|---|---|
JF | 0aa636834c | |
JF | 7785e3bcfe |
|
@ -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;
|
||||
|
@ -183,4 +183,12 @@ void Gfx::WaitTransfertFinished() const {
|
|||
ulTaskNotifyTake(pdTRUE, 500);
|
||||
}
|
||||
|
||||
void Gfx::SetScrollArea(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines) {
|
||||
lcd.VerticalScrollDefinition(topFixedLines, scrollLines, bottomFixedLines);
|
||||
}
|
||||
|
||||
void Gfx::SetScrollStartLine(uint16_t line) {
|
||||
lcd.VerticalScrollStartAddress(line);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace Pinetime {
|
|||
void DrawString(uint8_t x, uint8_t y, uint16_t color, const char* text, const FONT_INFO *p_font, bool wrap);
|
||||
void DrawChar(const FONT_INFO *font, uint8_t c, uint8_t *x, uint8_t y, uint16_t color);
|
||||
void FillRectangle(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color);
|
||||
void SetScrollArea(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines);
|
||||
void SetScrollStartLine(uint16_t line);
|
||||
|
||||
void Sleep();
|
||||
void Wakeup();
|
||||
|
|
|
@ -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 = 1000;
|
||||
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;
|
||||
|
||||
void Clock::Refresh(bool fullRefresh) {
|
||||
if(fullRefresh) {
|
||||
gfx.FillRectangle(0,0,240,240,0x0000);
|
||||
|
@ -16,6 +15,7 @@ void Clock::Refresh(bool fullRefresh) {
|
|||
auto dummy = currentDateTime.Get();
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -120,6 +120,22 @@ void St7789::DisplayOff() {
|
|||
nrf_delay_ms(500);
|
||||
}
|
||||
|
||||
void St7789::VerticalScrollDefinition(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines) {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::VerticalScrollDefinition));
|
||||
WriteData(topFixedLines >> 8u);
|
||||
WriteData(topFixedLines & 0x00ffu);
|
||||
WriteData(scrollLines >> 8u);
|
||||
WriteData(scrollLines & 0x00ffu);
|
||||
WriteData(bottomFixedLines >> 8u);
|
||||
WriteData(bottomFixedLines & 0x00ffu);
|
||||
}
|
||||
|
||||
void St7789::VerticalScrollStartAddress(uint16_t line) {
|
||||
WriteCommand(static_cast<uint8_t>(Commands::VerticalScrollStartAddress));
|
||||
WriteData(line >> 8u);
|
||||
WriteData(line & 0x00ffu);
|
||||
}
|
||||
|
||||
void St7789::Uninit() {
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ namespace Pinetime {
|
|||
void Uninit();
|
||||
void DrawPixel(uint16_t x, uint16_t y, uint32_t color);
|
||||
|
||||
void VerticalScrollDefinition(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines);
|
||||
void VerticalScrollStartAddress(uint16_t line);
|
||||
|
||||
|
||||
void BeginDrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
|
||||
void NextDrawBuffer(const uint8_t* data, size_t size);
|
||||
|
||||
|
@ -47,7 +51,9 @@ namespace Pinetime {
|
|||
ColumnAddressSet = 0x2a,
|
||||
RowAddressSet = 0x2b,
|
||||
WriteToRam = 0x2c,
|
||||
MemoryDataAccessControl = 036,
|
||||
MemoryDataAccessControl = 0x36,
|
||||
VerticalScrollDefinition = 0x33,
|
||||
VerticalScrollStartAddress = 0x37,
|
||||
ColMod = 0x3a,
|
||||
};
|
||||
void WriteData(uint8_t data);
|
||||
|
|
Loading…
Reference in New Issue