mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Add heltec_vision_master_e213 board.
This commit is contained in:
parent
dc6b830970
commit
be243a2663
11 changed files with 493 additions and 21 deletions
|
|
@ -5,25 +5,25 @@
|
|||
class RefCountedDigitalPin {
|
||||
uint8_t _pin;
|
||||
int8_t _claims = 0;
|
||||
|
||||
uint8_t _active = 0;
|
||||
public:
|
||||
RefCountedDigitalPin(uint8_t pin): _pin(pin) { }
|
||||
RefCountedDigitalPin(uint8_t pin,uint8_t active=HIGH): _pin(pin), _active(active) { }
|
||||
|
||||
void begin() {
|
||||
pinMode(_pin, OUTPUT);
|
||||
digitalWrite(_pin, LOW); // initial state
|
||||
digitalWrite(_pin, !_active); // initial state
|
||||
}
|
||||
|
||||
void claim() {
|
||||
_claims++;
|
||||
if (_claims > 0) {
|
||||
digitalWrite(_pin, HIGH);
|
||||
digitalWrite(_pin, _active);
|
||||
}
|
||||
}
|
||||
void release() {
|
||||
_claims--;
|
||||
if (_claims == 0) {
|
||||
digitalWrite(_pin, LOW);
|
||||
digitalWrite(_pin, !_active);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,20 +2,59 @@
|
|||
|
||||
#include "../../MeshCore.h"
|
||||
|
||||
EInkDetectionResult E213Display::detectEInk()
|
||||
{
|
||||
// Test 1: Logic of BUSY pin
|
||||
|
||||
// Determines controller IC manufacturer
|
||||
// Fitipower: busy when LOW
|
||||
// Solomon Systech: busy when HIGH
|
||||
|
||||
// Force display BUSY by holding reset pin active
|
||||
pinMode(DISP_RST, OUTPUT);
|
||||
digitalWrite(DISP_RST, LOW);
|
||||
|
||||
delay(10);
|
||||
|
||||
// Read whether pin is HIGH or LOW while busy
|
||||
pinMode(DISP_BUSY, INPUT);
|
||||
bool busyLogic = digitalRead(DISP_BUSY);
|
||||
|
||||
// Test complete. Release pin
|
||||
pinMode(DISP_RST, INPUT);
|
||||
|
||||
if (busyLogic == LOW)
|
||||
return V_LCMEN213EFC1;
|
||||
else // busy HIGH
|
||||
return V_E0213A367;
|
||||
}
|
||||
|
||||
|
||||
bool E213Display::begin() {
|
||||
if (_init) return true;
|
||||
|
||||
powerOn();
|
||||
display.begin();
|
||||
_version = detectEInk();
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.begin();
|
||||
// Set to landscape mode rotated 180 degrees
|
||||
display.setRotation(3);
|
||||
} else{
|
||||
display1.begin();
|
||||
// Set to landscape mode rotated 180 degrees
|
||||
display1.setRotation(3);
|
||||
}
|
||||
|
||||
// Set to landscape mode rotated 180 degrees
|
||||
display.setRotation(3);
|
||||
|
||||
_init = true;
|
||||
_isOn = true;
|
||||
|
||||
clear();
|
||||
display.fastmodeOn(); // Enable fast mode for quicker (partial) updates
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.fastmodeOn(); // Enable fast mode for quicker (partial) updates
|
||||
} else{
|
||||
display1.fastmodeOn(); // Enable fast mode for quicker (partial) updates
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -23,15 +62,23 @@ bool E213Display::begin() {
|
|||
void E213Display::powerOn() {
|
||||
#ifdef PIN_VEXT_EN
|
||||
pinMode(PIN_VEXT_EN, OUTPUT);
|
||||
#ifdef PIN_VEXT_EN_ACTIVE
|
||||
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE);
|
||||
#else
|
||||
digitalWrite(PIN_VEXT_EN, LOW); // Active low
|
||||
#endif
|
||||
delay(50); // Allow power to stabilize
|
||||
#endif
|
||||
}
|
||||
|
||||
void E213Display::powerOff() {
|
||||
#ifdef PIN_VEXT_EN
|
||||
#ifdef PIN_VEXT_EN_ACTIVE
|
||||
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE);
|
||||
#else
|
||||
digitalWrite(PIN_VEXT_EN, HIGH); // Turn off power
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void E213Display::turnOn() {
|
||||
|
|
@ -46,21 +93,37 @@ void E213Display::turnOff() {
|
|||
}
|
||||
|
||||
void E213Display::clear() {
|
||||
display.clear();
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.clear();
|
||||
} else{
|
||||
display1.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void E213Display::startFrame(Color bkg) {
|
||||
// Fill screen with white first to ensure clean background
|
||||
display.fillRect(0, 0, width(), height(), WHITE);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.fillRect(0, 0, width(), height(), WHITE);
|
||||
} else{
|
||||
display1.fillRect(0, 0, width(), height(), WHITE);
|
||||
}
|
||||
if (bkg == LIGHT) {
|
||||
// Fill with black if light background requested (inverted for e-ink)
|
||||
display.fillRect(0, 0, width(), height(), BLACK);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.fillRect(0, 0, width(), height(), BLACK);
|
||||
} else{
|
||||
display1.fillRect(0, 0, width(), height(), BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void E213Display::setTextSize(int sz) {
|
||||
// The library handles text size internally
|
||||
display.setTextSize(sz);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.setTextSize(sz);
|
||||
} else{
|
||||
display1.setTextSize(sz);
|
||||
}
|
||||
}
|
||||
|
||||
void E213Display::setColor(Color c) {
|
||||
|
|
@ -68,19 +131,35 @@ void E213Display::setColor(Color c) {
|
|||
}
|
||||
|
||||
void E213Display::setCursor(int x, int y) {
|
||||
display.setCursor(x, y);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.setCursor(x, y);
|
||||
} else{
|
||||
display1.setCursor(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void E213Display::print(const char *str) {
|
||||
display.print(str);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.print(str);
|
||||
} else {
|
||||
display1.print(str);
|
||||
}
|
||||
}
|
||||
|
||||
void E213Display::fillRect(int x, int y, int w, int h) {
|
||||
display.fillRect(x, y, w, h, BLACK);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.fillRect(x, y, w, h, BLACK);
|
||||
} else {
|
||||
display1.fillRect(x, y, w, h, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
void E213Display::drawRect(int x, int y, int w, int h) {
|
||||
display.drawRect(x, y, w, h, BLACK);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.drawRect(x, y, w, h, BLACK);
|
||||
} else {
|
||||
display1.drawRect(x, y, w, h, BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
|
||||
|
|
@ -98,7 +177,11 @@ void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
|
|||
|
||||
// If the bit is set, draw the pixel
|
||||
if (bitSet) {
|
||||
display.drawPixel(x + bx, y + by, BLACK);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.drawPixel(x + bx, y + by, BLACK);
|
||||
} else {
|
||||
display1.drawPixel(x + bx, y + by, BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -107,10 +190,18 @@ void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
|
|||
uint16_t E213Display::getTextWidth(const char *str) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
} else {
|
||||
display1.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
void E213Display::endFrame() {
|
||||
display.update();
|
||||
if(_version==V_LCMEN213EFC1) {
|
||||
display.update();
|
||||
} else {
|
||||
display1.update();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,21 @@
|
|||
#include <Wire.h>
|
||||
#include <heltec-eink-modules.h>
|
||||
|
||||
enum EInkDetectionResult {
|
||||
V_LCMEN213EFC1 = 0, // Initial version
|
||||
V_E0213A367 = 1, // E213 PCB marked V1.1 (Mid 2025)
|
||||
};
|
||||
|
||||
// Display driver for E213 e-ink display
|
||||
class E213Display : public DisplayDriver {
|
||||
#ifdef VISION_MASTER_E213
|
||||
EInkDisplay_VisionMasterE213 display;
|
||||
EInkDisplay_VisionMasterE213V1_1 display1;
|
||||
#else
|
||||
EInkDisplay_WirelessPaperV1_1 display;
|
||||
EInkDisplay_WirelessPaperV1_1_1 display1;
|
||||
#endif
|
||||
EInkDetectionResult _version =V_LCMEN213EFC1;
|
||||
bool _init = false;
|
||||
bool _isOn = false;
|
||||
|
||||
|
|
@ -32,6 +44,7 @@ public:
|
|||
void endFrame() override;
|
||||
|
||||
private:
|
||||
EInkDetectionResult detectEInk();
|
||||
void powerOn();
|
||||
void powerOff();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue