formatting

This commit is contained in:
JQ
2025-06-27 23:30:52 -07:00
parent e417c43c30
commit ff3e888dfd
4 changed files with 35 additions and 34 deletions

View File

@@ -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();
}

View File

@@ -1,9 +1,10 @@
#pragma once
#include "DisplayDriver.h"
#include <SPI.h>
#include <Wire.h>
#include <heltec-eink-modules.h>
#include "DisplayDriver.h"
// Display driver for E213 e-ink display
class E213Display : public DisplayDriver {
@@ -12,8 +13,7 @@ class E213Display : public DisplayDriver {
bool _isOn = false;
public:
E213Display() : DisplayDriver(250, 122) {
}
E213Display() : DisplayDriver(250, 122) {}
bool begin();
bool isOn() override { return _isOn; }
@@ -24,13 +24,13 @@ public:
void setTextSize(int sz) override;
void setColor(Color c) override;
void setCursor(int x, int y) override;
void print(const char* str) 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;
void drawXbm(int x, int y, const uint8_t *bits, int w, int h) override;
uint16_t getTextWidth(const char *str) override;
void endFrame() override;
private:
void powerOn();
void powerOff();