feat(l1): Home pages slide sideways, the page pill glides along

DisplayDriver gains slideBegin()/slideCompose(): the driver keeps the frame
on screen and, in the next one, moves it out while the new rows follow.
SH1106 does it on its 1 KB buffer (+1 KB RAM for the copy), the sim on its
canvas; drivers that can't read their frame back keep cutting over (e-ink).

Home slides the content below the page-icon row in 220 ms with an ease-out
(the whole screen to and from the header-less clock), and the current-page
pill glides between icons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-01 23:08:40 +02:00
co-authored by Claude Opus 5.5
parent 608231ed6b
commit 061e5ba36b
5 changed files with 124 additions and 12 deletions
+8
View File
@@ -533,6 +533,14 @@ public:
virtual void setBrightness(uint8_t level) { } // level 0-4 (min to max), no-op default
virtual void setDisplayRotation(uint8_t rot) { } // 0-3, no-op for fixed-orientation displays
virtual void setFullRefreshInterval(uint8_t n) { } // e-ink: do full refresh every n partial refreshes (0=never)
// Sideways slide between two frames, for screens that page left/right.
// slideBegin() keeps rows y0.. of the frame on screen now; call it before the
// next frame is drawn. slideCompose(dx), at the end of drawing that frame,
// moves the kept rows dx px left (right when dx < 0) and fills the gap with
// the new frame's rows sliding in behind them. A driver that can't read its
// frame back returns false and the screen just cuts over.
virtual bool slideBegin(int y0) { return false; }
virtual void slideCompose(int dx) { }
virtual void endFrame() = 0;
// Called from board setup to run safe background work during a blocking
+31
View File
@@ -1,4 +1,5 @@
#include "SH1106Display.h"
#include <string.h>
#include <Adafruit_GrayOLED.h>
#include "Adafruit_SH110X.h"
#include "MiscFixedRenderer.h"
@@ -64,6 +65,36 @@ void SH1106Display::startFrame(Color bkg)
display.cp437(true); // Use full 256 char 'Code Page 437' font
}
// The GFX buffer still holds the last frame sent until the next startFrame().
bool SH1106Display::slideBegin(int y0)
{
_slide_y0 = y0 < 0 ? 0 : (y0 > height() ? height() : y0);
memcpy(_slide_old, display.getBuffer(), sizeof(_slide_old));
return true;
}
// Buffer layout: one byte per column per 8-row page, bit n = row page*8+n.
void SH1106Display::slideCompose(int dx)
{
uint8_t* buf = display.getBuffer();
const int W = width();
int off = dx < 0 ? -dx : dx;
if (off > W) off = W;
uint8_t fresh[128];
for (int p = _slide_y0 / 8; p < height() / 8; p++) {
const uint8_t keep = (p == _slide_y0 / 8) ? (uint8_t)~(0xFF << (_slide_y0 & 7)) : 0;
uint8_t* cur = buf + p * W;
const uint8_t* old = _slide_old + p * W;
memcpy(fresh, cur, W);
for (int x = 0; x < W; x++) {
uint8_t v;
if (dx >= 0) v = x < W - off ? old[x + off] : fresh[x - (W - off)];
else v = x >= off ? old[x - off] : fresh[x + (W - off)];
cur[x] = (cur[x] & keep) | (v & ~keep);
}
}
}
void SH1106Display::setTextSize(int sz)
{
_text_sz = sz;
+5
View File
@@ -44,6 +44,9 @@ class SH1106Display : public DisplayDriver
static const uint8_t BLOCKS = (128 / BLOCK_W) * (64 / 8);
uint32_t _block_hash[BLOCKS] = {};
bool _force_redraw = true;
// slideBegin()'s copy of the frame on screen (only rows >= _slide_y0 are used).
uint8_t _slide_old[128 * 64 / 8];
int _slide_y0 = 0;
bool i2c_probe(TwoWire &wire, uint8_t addr);
// Thin wrapper over the shared misc-fixed renderer (MiscFixedRenderer.h), kept
@@ -61,6 +64,8 @@ public:
void turnOff() override;
void clear() override;
void startFrame(Color bkg = DARK) override;
bool slideBegin(int y0) override;
void slideCompose(int dx) override;
void setTextSize(int sz) override;
void setColor(Color c) override;
void setCursor(int x, int y) override;