Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/helpers/ui/DisplayDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DisplayDriver {
protected:
DisplayDriver(int w, int h) { _w = w; _h = h; }
public:
enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light
enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light (inverted on epaper)

int width() const { return _w; }
int height() const { return _h; }
Expand Down
17 changes: 10 additions & 7 deletions src/helpers/ui/E213Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool E213Display::begin() {

_init = true;
_isOn = true;
_color = WHITE;

clear();
display->fastmodeOn(); // Enable fast mode for quicker (partial) updates
Expand Down Expand Up @@ -123,39 +124,41 @@ void E213Display::startFrame(Color bkg) {
void E213Display::setTextSize(int sz) {
display_crc.update<int>(sz);
// The library handles text size internally
display->setTextSize(sz);
display->setTextSize(sz);
}

void E213Display::setColor(Color c) {
display_crc.update<Color>(c);
// implemented in individual display methods
// keep in mind this is inverted on e-ink
_color = c == 0 ? WHITE : BLACK; // for rectangles and bitmaps
display->setTextColor(UINT16_MAX * _color); // for text
}

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

void E213Display::print(const char *str) {
display_crc.update<char>(str, strlen(str));
display->print(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);
display->fillRect(x, y, w, h, _color);
}

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);
display->drawRect(x, y, w, h, _color);
}

void E213Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
Expand All @@ -179,7 +182,7 @@ 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);
display->drawPixel(x + bx, y + by, _color);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/ui/E213Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class E213Display : public DisplayDriver {
BaseDisplay* display=NULL;
bool _init = false;
bool _isOn = false;
uint8_t _color;
RefCountedDigitalPin* _periph_power;
CRC32 display_crc;
uint32_t last_display_crc_value = 0;
Expand Down
11 changes: 7 additions & 4 deletions src/helpers/ui/E290Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bool E290Display::begin() {

_init = true;
_isOn = true;
_color = WHITE;

clear();
display.fastmodeOn(); // Enable fast mode for quicker (partial) updates
Expand Down Expand Up @@ -81,7 +82,9 @@ void E290Display::setTextSize(int sz) {

void E290Display::setColor(Color c) {
display_crc.update<Color>(c);
// implemented in individual display methods
// keep in mind this is inverted on e-ink
_color = c == 0 ? WHITE : BLACK; // for rectangles and bitmaps
display.setTextColor(UINT16_MAX * _color); // for text
}

void E290Display::setCursor(int x, int y) {
Expand All @@ -100,15 +103,15 @@ void E290Display::fillRect(int x, int y, int w, int h) {
display_crc.update<int>(y);
display_crc.update<int>(w);
display_crc.update<int>(h);
display.fillRect(x, y, w, h, BLACK);
display.fillRect(x, y, w, h, _color);
}

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);
display.drawRect(x, y, w, h, _color);
}

void E290Display::drawXbm(int x, int y, const uint8_t *bits, int w, int h) {
Expand All @@ -132,7 +135,7 @@ void E290Display::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);
display.drawPixel(x + bx, y + by, _color);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/ui/E290Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class E290Display : public DisplayDriver {
EInkDisplay_VisionMasterE290 display;
bool _init = false;
bool _isOn = false;
uint8_t _color;
RefCountedDigitalPin* _periph_power;
CRC32 display_crc;
uint32_t last_display_crc_value = 0;
Expand Down