Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 47 additions & 10 deletions src/helpers/ui/E213Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,58 @@ bool E213Display::begin() {
}

void E213Display::powerOn() {
if (_periph_power) {
_periph_power->claim();
} else {
#ifdef PIN_VEXT_EN
pinMode(PIN_VEXT_EN, OUTPUT);
pinMode(PIN_VEXT_EN, OUTPUT);
#ifdef PIN_VEXT_EN_ACTIVE
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE);
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE);
#else
digitalWrite(PIN_VEXT_EN, LOW); // Active low
digitalWrite(PIN_VEXT_EN, LOW); // Active low
#endif
delay(50); // Allow power to stabilize
#endif
}
delay(50); // Allow power to stabilize
}

void E213Display::powerOff() {
if (_periph_power) {
_periph_power->release();
} else {
#ifdef PIN_VEXT_EN
#ifdef PIN_VEXT_EN_ACTIVE
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE);
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE);
#else
digitalWrite(PIN_VEXT_EN, HIGH); // Turn off power
digitalWrite(PIN_VEXT_EN, HIGH); // Turn off power
#endif
#endif
}
}

void E213Display::turnOn() {
if (!_init) begin();
powerOn();
else if (!_isOn) {
powerOn();
display->fastmodeOn(); // Reinitialize display controller after power was cut
}
_isOn = true;
}

void E213Display::turnOff() {
powerOff();
_isOn = false;
if (_isOn) {
powerOff();
_isOn = false;
}
}

void E213Display::clear() {
display->clear();

}

void E213Display::startFrame(Color bkg) {
display_crc.reset();

// Fill screen with white first to ensure clean background
display->fillRect(0, 0, width(), height(), WHITE);

Expand All @@ -107,31 +121,50 @@ void E213Display::startFrame(Color bkg) {
}

void E213Display::setTextSize(int sz) {
display_crc.update<int>(sz);
// The library handles text size internally
display->setTextSize(sz);
}

void E213Display::setColor(Color c) {
display_crc.update<Color>(c);
// implemented in individual display methods
}

void E213Display::setCursor(int x, int y) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display->setCursor(x, y);
}

void E213Display::print(const char *str) {
display_crc.update<char>(str, strlen(str));
display->print(str);
}

void E213Display::fillRect(int x, int y, int w, int h) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display->fillRect(x, y, w, h, BLACK);
}

void E213Display::drawRect(int x, int y, int w, int h) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display->drawRect(x, y, w, h, BLACK);
}

void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display_crc.update<uint8_t>(bits, w * h / 8);

// Width in bytes for bitmap processing
uint16_t widthInBytes = (w + 7) / 8;

Expand Down Expand Up @@ -160,5 +193,9 @@ uint16_t E213Display::getTextWidth(const char *str) {
}

void E213Display::endFrame() {
uint32_t crc = display_crc.finalize();
if (crc != last_display_crc_value) {
display->update();
last_display_crc_value = crc;
}
}
9 changes: 7 additions & 2 deletions src/helpers/ui/E213Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
#include <SPI.h>
#include <Wire.h>
#include <heltec-eink-modules.h>
#include <CRC32.h>
#include <helpers/RefCountedDigitalPin.h>

// Display driver for E213 e-ink display
class E213Display : public DisplayDriver {
BaseDisplay* display=NULL;
bool _init = false;
bool _isOn = false;
RefCountedDigitalPin* _periph_power;
CRC32 display_crc;
uint32_t last_display_crc_value = 0;

public:
E213Display() : DisplayDriver(250, 122) {}
E213Display(RefCountedDigitalPin* periph_power = NULL) : DisplayDriver(250, 122), _periph_power(periph_power) {}
~E213Display(){
if(display!=NULL) {
delete display;
Expand All @@ -39,4 +44,4 @@ class E213Display : public DisplayDriver {
BaseDisplay* detectEInk();
void powerOn();
void powerOff();
};
};
54 changes: 46 additions & 8 deletions src/helpers/ui/E290Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,50 @@ bool E290Display::begin() {
}

void E290Display::powerOn() {
if (_periph_power) {
_periph_power->claim();
} else {
#ifdef PIN_VEXT_EN
pinMode(PIN_VEXT_EN, OUTPUT);
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE);
delay(50); // Allow power to stabilize
pinMode(PIN_VEXT_EN, OUTPUT);
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE);
#endif
}
delay(50); // Allow power to stabilize
}

void E290Display::powerOff() {
if (_periph_power) {
_periph_power->release();
} else {
#ifdef PIN_VEXT_EN
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // Turn off power
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // Turn off power
#endif
}
}

void E290Display::turnOn() {
if (!_init) begin();
powerOn();
else if (!_isOn) {
powerOn();
display.fastmodeOn(); // Reinitialize display controller after power was cut
}
_isOn = true;
}

void E290Display::turnOff() {
powerOff();
_isOn = false;
if (_isOn) {
powerOff();
_isOn = false;
}
}

void E290Display::clear() {
display.clear();
}

void E290Display::startFrame(Color bkg) {
display_crc.reset();

// Fill screen with white first to ensure clean background
display.fillRect(0, 0, width(), height(), WHITE);
if (bkg == LIGHT) {
Expand All @@ -59,31 +74,50 @@ void E290Display::startFrame(Color bkg) {
}

void E290Display::setTextSize(int sz) {
display_crc.update<int>(sz);
// The library handles text size internally
display.setTextSize(sz);
}

void E290Display::setColor(Color c) {
display_crc.update<Color>(c);
// implemented in individual display methods
}

void E290Display::setCursor(int x, int y) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display.setCursor(x, y);
}

void E290Display::print(const char *str) {
display_crc.update<char>(str, strlen(str));
display.print(str);
}

void E290Display::fillRect(int x, int y, int w, int h) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display.fillRect(x, y, w, h, BLACK);
}

void E290Display::drawRect(int x, int y, int w, int h) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display.drawRect(x, y, w, h, BLACK);
}

void E290Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
display_crc.update<int>(x);
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display_crc.update<uint8_t>(bits, w * h / 8);

// Width in bytes for bitmap processing
uint16_t widthInBytes = (w + 7) / 8;

Expand Down Expand Up @@ -112,5 +146,9 @@ uint16_t E290Display::getTextWidth(const char *str) {
}

void E290Display::endFrame() {
display.update();
uint32_t crc = display_crc.finalize();
if (crc != last_display_crc_value) {
display.update();
last_display_crc_value = crc;
}
}
9 changes: 7 additions & 2 deletions src/helpers/ui/E290Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
#include <SPI.h>
#include <Wire.h>
#include <heltec-eink-modules.h>
#include <CRC32.h>
#include <helpers/RefCountedDigitalPin.h>

// Display driver for E290 e-ink display
class E290Display : public DisplayDriver {
EInkDisplay_VisionMasterE290 display;
bool _init = false;
bool _isOn = false;
RefCountedDigitalPin* _periph_power;
CRC32 display_crc;
uint32_t last_display_crc_value = 0;

public:
E290Display() : DisplayDriver(296, 128) {}
E290Display(RefCountedDigitalPin* periph_power = NULL) : DisplayDriver(296, 128), _periph_power(periph_power) {}

bool begin();
bool isOn() override { return _isOn; }
Expand All @@ -34,4 +39,4 @@ class E290Display : public DisplayDriver {
private:
void powerOn();
void powerOff();
};
};
20 changes: 14 additions & 6 deletions variants/heltec_e213/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ lib_deps =
${esp32_base.lib_deps}
https://github.com/Quency-D/heltec-eink-modules/archive/563dd41fd850a1bc3039b8723da4f3a20fe1c800.zip

[env:Heltec_E213_companion_radio_ble_]
[env:Heltec_E213_companion_radio_ble]
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=E213Display
-D AUTO_OFF_MILLIS=0
-D BLE_PIN_CODE=123456 ; dynamic, random PIN
-D BLE_DEBUG_LOGGING=1
-D OFFLINE_QUEUE_SIZE=256
Expand All @@ -59,15 +60,17 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
lib_deps =
${Heltec_E213_base.lib_deps}
densaugeo/base64 @ ~1.4.0
bakercp/CRC32 @ ^2.0.0

[env:Heltec_E213_companion_radio_usb_]
[env:Heltec_E213_companion_radio_usb]
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=E213Display
-D AUTO_OFF_MILLIS=0
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${Heltec_E213_base.build_src_filter}
+<helpers/ui/E213Display.cpp>
Expand All @@ -77,8 +80,9 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
lib_deps =
${Heltec_E213_base.lib_deps}
densaugeo/base64 @ ~1.4.0
bakercp/CRC32 @ ^2.0.0

[env:Heltec_E213_repeater_]
[env:Heltec_E213_repeater]
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
Expand All @@ -94,8 +98,9 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
lib_deps =
${Heltec_E213_base.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0

; [env:Heltec_E213_repeater_bridge_rs232_]
; [env:Heltec_E213_repeater_bridge_rs232]
; extends = Heltec_E213_base
; build_flags =
; ${Heltec_E213_base.build_flags}
Expand All @@ -118,8 +123,9 @@ lib_deps =
; lib_deps =
; ${Heltec_E213_base.lib_deps}
; ${esp32_ota.lib_deps}
; bakercp/CRC32 @ ^2.0.0

[env:Heltec_E213_repeater_bridge_espnow_]
[env:Heltec_E213_repeater_bridge_espnow]
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
Expand All @@ -140,8 +146,9 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
lib_deps =
${Heltec_E213_base.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0

[env:Heltec_E213_room_server_]
[env:Heltec_E213_room_server]
extends = Heltec_E213_base
build_flags =
${Heltec_E213_base.build_flags}
Expand All @@ -157,3 +164,4 @@ build_src_filter = ${Heltec_E213_base.build_src_filter}
lib_deps =
${Heltec_E213_base.lib_deps}
${esp32_ota.lib_deps}
bakercp/CRC32 @ ^2.0.0
Loading
Loading