mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-29 16:28:11 +00:00
- 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>
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "DisplayDriver.h"
|
|
#include <Wire.h>
|
|
#include <Adafruit_GFX.h>
|
|
#define SH110X_NO_SPLASH
|
|
#include <Adafruit_SH110X.h>
|
|
|
|
#ifndef PIN_OLED_RESET
|
|
#define PIN_OLED_RESET -1
|
|
#endif
|
|
|
|
#ifndef DISPLAY_ADDRESS
|
|
#define DISPLAY_ADDRESS 0x3C
|
|
#endif
|
|
|
|
class SH1106Display : public DisplayDriver
|
|
{
|
|
Adafruit_SH1106G display;
|
|
bool _isOn;
|
|
uint8_t _color;
|
|
uint8_t _contrast;
|
|
uint8_t _precharge;
|
|
bool _use_lemon = false;
|
|
int _text_sz;
|
|
|
|
bool i2c_probe(TwoWire &wire, uint8_t addr);
|
|
int16_t drawLemonChar(int16_t x, int16_t y, uint32_t cp);
|
|
uint8_t lemonXAdvance(uint32_t cp);
|
|
|
|
public:
|
|
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) {
|
|
_isOn = false; _contrast = 255; _precharge = 0x1F; _text_sz = 1;
|
|
}
|
|
bool begin();
|
|
|
|
bool isOn() override { return _isOn; }
|
|
void turnOn() override;
|
|
void turnOff() override;
|
|
void clear() override;
|
|
void startFrame(Color bkg = DARK) override;
|
|
void setTextSize(int sz) override;
|
|
void setColor(Color c) override;
|
|
void setCursor(int x, int y) override;
|
|
void print(const char *str) override;
|
|
void fillRect(int x, int y, int w, int h) override;
|
|
void drawRect(int x, int y, int w, int h) override;
|
|
void drawXbm(int x, int y, const uint8_t *bits, int w, int h) override;
|
|
uint16_t getTextWidth(const char *str) override;
|
|
uint16_t getCodepointWidth(uint32_t cp) override {
|
|
if (_use_lemon) return lemonXAdvance(cp);
|
|
return 6 * _text_sz; // built-in 5x7 font: 6 px advance per glyph
|
|
}
|
|
int getCharWidth() const override { return (_use_lemon ? 5 : 6) * _text_sz; }
|
|
int getLineHeight() const override { return (_use_lemon ? 9 : 8) * _text_sz; }
|
|
void setLemonFont(bool enabled) override { _use_lemon = enabled; _vw_dirty = true; }
|
|
bool isLemonFont() const override { return _use_lemon; }
|
|
void translateUTF8ToBlocks(char* dest, const char* src, size_t dest_size) override;
|
|
void setBrightness(uint8_t level) override;
|
|
void endFrame() override;
|
|
|
|
#ifdef ENABLE_SCREENSHOT
|
|
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
|
|
};
|