mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 23:08:11 +00:00
feat(screenshot): extend e-ink screenshot support via GxEPD2 patch
- Add lib/GxEPD2-patch/src/GxEPD2_BW.h: local patched copy of GxEPD2_BW.h
that exposes getBuffer()/getBufferSize() under ENABLE_SCREENSHOT guard.
Include guard (_GxEPD2_BW_H_) prevents double-inclusion of the installed
library version.
- GxEPDDisplay.h: use patched header via relative include when
ENABLE_SCREENSHOT so the patch takes precedence over the installed lib
(PlatformIO adds library paths before -I build_flags).
- DisplayDriver.h: add virtual getBuffer()/getBufferSize()/getDisplayType()
defaults (nullptr/0/0) under ENABLE_SCREENSHOT.
- SH1106Display.h / SSD1306Display.h / GxEPDDisplay.h: add concrete overrides;
getDisplayType() returns 0 (OLED) or 1 (e-ink).
- MyMesh.cpp/h: replace fragile C-cast with virtual dispatch in
handleScreenshotRequest(); extend 5-byte header to 6 bytes by appending
display_type so the host tool can decode the correct pixel layout.
- tools/screenshot.py: parse 6-byte header; add eink_buffer_to_image()
that decodes the row-major MSB-first GxEPD2 buffer with DISPLAY_ROTATION=1
(phys_x = 127-ly, phys_y = lx); dispatch on display_type.
- variants/wio-tracker-l1-eink/platformio.ini: add
[env:WioTrackerL1Eink_companion_dual_dev] with ENABLE_SCREENSHOT.
- variants/wio-tracker-l1/platformio.ini: unchanged (OLED env already exists).
Builds verified: WioTrackerL1Eink_companion_dual_dev SUCCESS,
WioTrackerL1Eink_companion_radio_ble SUCCESS (unaffected).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -247,4 +247,12 @@ public:
|
||||
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)
|
||||
virtual void endFrame() = 0;
|
||||
|
||||
#ifdef ENABLE_SCREENSHOT
|
||||
// Screenshot support — return raw framebuffer and its size in bytes.
|
||||
// 0=OLED (page-based, column-major), 1=e-ink (row-major, MSB-first, 1=white/0=black).
|
||||
virtual const uint8_t* getBuffer() { return nullptr; }
|
||||
virtual uint16_t getBufferSize() { return 0; }
|
||||
virtual uint8_t getDisplayType() { return 0; }
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -5,7 +5,15 @@
|
||||
|
||||
#define ENABLE_GxEPD2_GFX 0
|
||||
|
||||
// When ENABLE_SCREENSHOT is active, use the patched copy of GxEPD2_BW.h from
|
||||
// lib/GxEPD2-patch/src/ that exposes getBuffer()/getBufferSize(). The include
|
||||
// guard (_GxEPD2_BW_H_) then prevents the installed library version from
|
||||
// being compiled again. Non-screenshot builds use the installed library as-is.
|
||||
#ifdef ENABLE_SCREENSHOT
|
||||
#include "../../../lib/GxEPD2-patch/src/GxEPD2_BW.h"
|
||||
#else
|
||||
#include <GxEPD2_BW.h>
|
||||
#endif
|
||||
#include <GxEPD2_3C.h>
|
||||
#include <GxEPD2_4C.h>
|
||||
#include <GxEPD2_7C.h>
|
||||
@@ -70,6 +78,12 @@ public:
|
||||
display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SCREENSHOT
|
||||
const uint8_t* getBuffer() override { return display.getBuffer(); }
|
||||
uint16_t getBufferSize() override { return display.getBufferSize(); }
|
||||
uint8_t getDisplayType() override { return 1; } // 1 = e-ink
|
||||
#endif
|
||||
|
||||
// Line height and approx. char width for each font size:
|
||||
// 1 = FreeSans9pt (lineH=16, charW≈9)
|
||||
// 2 = FreeSansBold12pt (lineH=20, charW≈12)
|
||||
|
||||
@@ -60,7 +60,8 @@ public:
|
||||
void endFrame() override;
|
||||
|
||||
#ifdef ENABLE_SCREENSHOT
|
||||
// Screenshot support
|
||||
uint8_t* getBuffer() { return display.getBuffer(); }
|
||||
const uint8_t* getBuffer() override { return display.getBuffer(); }
|
||||
uint16_t getBufferSize() override { return (uint16_t)((width() * height()) / 8); }
|
||||
uint8_t getDisplayType() override { return 0; }
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -47,7 +47,8 @@ public:
|
||||
void endFrame() override;
|
||||
|
||||
#ifdef ENABLE_SCREENSHOT
|
||||
// Screenshot support
|
||||
uint8_t* getBuffer() { return display.getBuffer(); }
|
||||
const uint8_t* getBuffer() override { return display.getBuffer(); }
|
||||
uint16_t getBufferSize() override { return (uint16_t)((width() * height()) / 8); }
|
||||
uint8_t getDisplayType() override { return 0; }
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user