Add vertical scrolling support in st7789 driver
Demo of vertical scrolling in screen Clock.
This commit is contained in:
parent
e737fb0499
commit
7785e3bcfe
|
@ -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();
|
||||
|
|
|
@ -68,7 +68,7 @@ void DisplayApp::Refresh() {
|
|||
break;
|
||||
case States::Running:
|
||||
RunningState();
|
||||
queueTimeout = 1000;
|
||||
queueTimeout = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#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,8 +14,14 @@ 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();
|
||||
|
|
|
@ -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