summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-02-15 15:12:29 +0100
committerJF <jf@codingfield.com>2020-02-15 15:12:29 +0100
commitf30573a9b0fd33290ce13807714d812086ce1398 (patch)
tree249fc3233227afd9da881bdf77392db6bd0c0647
parente737fb0499769fa342e4dc267416a7ce5da2574c (diff)
Add support for hardware assisted vertical scrolling.
-rw-r--r--src/Components/Gfx/Gfx.cpp9
-rw-r--r--src/Components/Gfx/Gfx.h3
-rw-r--r--src/drivers/St7789.cpp17
-rw-r--r--src/drivers/St7789.h6
4 files changed, 34 insertions, 1 deletions
diff --git a/src/Components/Gfx/Gfx.cpp b/src/Components/Gfx/Gfx.cpp
index 0dcb98a6..ed323bc0 100644
--- a/src/Components/Gfx/Gfx.cpp
+++ b/src/Components/Gfx/Gfx.cpp
@@ -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,11 @@ 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);
+}
diff --git a/src/Components/Gfx/Gfx.h b/src/Components/Gfx/Gfx.h
index f31b13c0..6d1d02fd 100644
--- a/src/Components/Gfx/Gfx.h
+++ b/src/Components/Gfx/Gfx.h
@@ -19,6 +19,9 @@ 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();
diff --git a/src/drivers/St7789.cpp b/src/drivers/St7789.cpp
index 39595dc9..1de5f5f4 100644
--- a/src/drivers/St7789.cpp
+++ b/src/drivers/St7789.cpp
@@ -120,6 +120,23 @@ 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() {
}
diff --git a/src/drivers/St7789.h b/src/drivers/St7789.h
index 9ecf9f27..4341e909 100644
--- a/src/drivers/St7789.h
+++ b/src/drivers/St7789.h
@@ -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);
@@ -48,6 +52,8 @@ namespace Pinetime {
RowAddressSet = 0x2b,
WriteToRam = 0x2c,
MemoryDataAccessControl = 036,
+ VerticalScrollDefinition = 0x33,
+ VerticalScrollStartAddress = 0x37,
ColMod = 0x3a,
};
void WriteData(uint8_t data);