|
|
|
@ -1,36 +1,37 @@ |
|
|
|
#include "E213Display.h" |
|
|
|
|
|
|
|
#include "../../MeshCore.h" |
|
|
|
|
|
|
|
bool E213Display::begin() { |
|
|
|
if (_init) return true; |
|
|
|
|
|
|
|
|
|
|
|
powerOn(); |
|
|
|
display.begin(); |
|
|
|
|
|
|
|
|
|
|
|
// Set to landscape mode rotated 180 degrees
|
|
|
|
display.setRotation(3); |
|
|
|
|
|
|
|
|
|
|
|
_init = true; |
|
|
|
_isOn = true; |
|
|
|
|
|
|
|
|
|
|
|
clear(); |
|
|
|
display.fastmodeOn(); // Enable fast mode for quicker (partial) updates
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
void E213Display::powerOn() { |
|
|
|
#ifdef PIN_VEXT_EN |
|
|
|
pinMode(PIN_VEXT_EN, OUTPUT); |
|
|
|
digitalWrite(PIN_VEXT_EN, LOW); // Active low
|
|
|
|
delay(50); // Allow power to stabilize
|
|
|
|
#endif |
|
|
|
#ifdef PIN_VEXT_EN |
|
|
|
pinMode(PIN_VEXT_EN, OUTPUT); |
|
|
|
digitalWrite(PIN_VEXT_EN, LOW); // Active low
|
|
|
|
delay(50); // Allow power to stabilize
|
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void E213Display::powerOff() { |
|
|
|
#ifdef PIN_VEXT_EN |
|
|
|
digitalWrite(PIN_VEXT_EN, HIGH); // Turn off power
|
|
|
|
#endif |
|
|
|
#ifdef PIN_VEXT_EN |
|
|
|
digitalWrite(PIN_VEXT_EN, HIGH); // Turn off power
|
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void E213Display::turnOn() { |
|
|
|
@ -70,7 +71,7 @@ void E213Display::setCursor(int x, int y) { |
|
|
|
display.setCursor(x, y); |
|
|
|
} |
|
|
|
|
|
|
|
void E213Display::print(const char* str) { |
|
|
|
void E213Display::print(const char *str) { |
|
|
|
display.print(str); |
|
|
|
} |
|
|
|
|
|
|
|
@ -82,10 +83,10 @@ void E213Display::drawRect(int x, int y, int w, int h) { |
|
|
|
display.drawRect(x, y, w, h, BLACK); |
|
|
|
} |
|
|
|
|
|
|
|
void E213Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) { |
|
|
|
void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) { |
|
|
|
// Width in bytes for bitmap processing
|
|
|
|
uint16_t widthInBytes = (w + 7) / 8; |
|
|
|
|
|
|
|
|
|
|
|
// Process the bitmap row by row
|
|
|
|
for (int by = 0; by < h; by++) { |
|
|
|
// Scan across the row bit by bit
|
|
|
|
@ -94,7 +95,7 @@ void E213Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) { |
|
|
|
uint16_t byteOffset = (by * widthInBytes) + (bx / 8); |
|
|
|
uint8_t bitMask = 0x80 >> (bx & 7); |
|
|
|
bool bitSet = bits[byteOffset] & bitMask; |
|
|
|
|
|
|
|
|
|
|
|
// If the bit is set, draw the pixel
|
|
|
|
if (bitSet) { |
|
|
|
display.drawPixel(x + bx, y + by, BLACK); |
|
|
|
@ -103,7 +104,7 @@ void E213Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
uint16_t E213Display::getTextWidth(const char* str) { |
|
|
|
uint16_t E213Display::getTextWidth(const char *str) { |
|
|
|
int16_t x1, y1; |
|
|
|
uint16_t w, h; |
|
|
|
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h); |
|
|
|
@ -113,4 +114,3 @@ uint16_t E213Display::getTextWidth(const char* str) { |
|
|
|
void E213Display::endFrame() { |
|
|
|
display.update(); |
|
|
|
} |
|
|
|
|
|
|
|
|