diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index 01770363..7448f303 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -99,7 +99,7 @@ void UITask::renderCurrScreen() { _display->setColor(DisplayDriver::LIGHT); _display->print(_msg); - _display->setCursor(100, 9); + _display->setCursor(_display->width() - 28, 9); _display->setTextSize(2); _display->setColor(DisplayDriver::ORANGE); sprintf(tmp, "%d", _msgcount); diff --git a/src/helpers/ui/GxEPDDisplay.cpp b/src/helpers/ui/GxEPDDisplay.cpp index 0b8bf502..e7b70b49 100644 --- a/src/helpers/ui/GxEPDDisplay.cpp +++ b/src/helpers/ui/GxEPDDisplay.cpp @@ -6,22 +6,33 @@ bool GxEPDDisplay::begin() { SPI1.begin(); display.init(115200, true, 2, false); display.setRotation(3); - display.setFont(&FreeMono9pt7b); - + #ifdef TECHO_ZOOM + display.setFont(&FreeMono9pt7b); + #endif display.setPartialWindow(0, 0, display.width(), display.height()); display.fillScreen(GxEPD_WHITE); display.display(true); + #if DISP_BACKLIGHT + pinMode(DISP_BACKLIGHT, OUTPUT); + #endif _init = true; return true; } void GxEPDDisplay::turnOn() { if (!_init) begin(); +#if DISP_BACKLIGHT + digitalWrite(DISP_BACKLIGHT, HIGH); + _isOn = true; +#endif } void GxEPDDisplay::turnOff() { - +#if DISP_BACKLIGHT + digitalWrite(DISP_BACKLIGHT, LOW); +#endif + _isOn = false; } void GxEPDDisplay::clear() { @@ -34,6 +45,7 @@ void GxEPDDisplay::startFrame(Color bkg) { } void GxEPDDisplay::setTextSize(int sz) { + display.setTextSize(sz); } void GxEPDDisplay::setColor(Color c) { @@ -41,7 +53,11 @@ void GxEPDDisplay::setColor(Color c) { } void GxEPDDisplay::setCursor(int x, int y) { - display.setCursor(x*1.5, (y*1.5)+10); +#ifdef TECHO_ZOOM + x = x + (x >> 1); + y = y + (y >> 1); +#endif + display.setCursor(x, (y+10)); } void GxEPDDisplay::print(const char* str) { @@ -49,12 +65,32 @@ void GxEPDDisplay::print(const char* str) { } void GxEPDDisplay::fillRect(int x, int y, int w, int h) { +#ifdef TECHO_ZOOM + x = x + (x >> 1); + y = y + (y >> 1); + w = w + (w >> 1); + h = h + (h >> 1); +#endif + display.fillRect(x, y, w, h, GxEPD_BLACK); } void GxEPDDisplay::drawRect(int x, int y, int w, int h) { +#ifdef TECHO_ZOOM + x = x + (x >> 1); + y = y + (y >> 1); + w = w + (w >> 1); + h = h + (h >> 1); +#endif + display.drawRect(x, y, w, h, GxEPD_BLACK); } void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) { +#ifdef TECHO_ZOOM + x = x + (x >> 1); + y = y + (y >> 1); + w = w + (w >> 1); + h = h + (h >> 1); +#endif display.drawBitmap(x*1.5, (y*1.5) + 10, bits, w, h, GxEPD_BLACK); } diff --git a/src/helpers/ui/GxEPDDisplay.h b/src/helpers/ui/GxEPDDisplay.h index 1dbf3a9a..ecadc50c 100644 --- a/src/helpers/ui/GxEPDDisplay.h +++ b/src/helpers/ui/GxEPDDisplay.h @@ -25,15 +25,17 @@ class GxEPDDisplay : public DisplayDriver { GxEPD2_BW display; bool _init = false; + bool _isOn = false; public: - GxEPDDisplay() : DisplayDriver(200, 200), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) { + // there is a margin in y... + GxEPDDisplay() : DisplayDriver(200, 200-10), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) { } bool begin(); - bool isOn() override { return true; } + bool isOn() override {return _isOn;}; void turnOn() override; void turnOff() override; void clear() override;