diff options
Diffstat (limited to 'src/display.cpp')
-rw-r--r-- | src/display.cpp | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/src/display.cpp b/src/display.cpp index 44b13b1..104ce44 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -2,7 +2,7 @@ #include "badge/log.h" -#include <Fonts/FreeMonoBold9pt7b.h> +#include <Fonts/FreeMono9pt7b.h> #include <Fonts/FreeSansBold12pt7b.h> // #include <GxEPD2_3C.h> #include <GxEPD2_BW.h> @@ -46,6 +46,7 @@ static uint8_t displayed = 0; // #include "snep3.xbm" static bool is_initial = true; +static constexpr uint8_t rotation = 3; void de::uvok::badge::display_init(void) { @@ -95,7 +96,7 @@ static void displayDo(display_mode_t mode) LOG_F("Print image %d in full mode? %d\n", displayed, mode); - display.setRotation(3); + display.setRotation(rotation); display.setTextColor(GxEPD_BLACK); display.setFont(&FreeSansBold12pt7b); @@ -160,16 +161,60 @@ void de::uvok::badge::display_direct(uint8_t num) { LOG_F("Display direct\n"); if (num >= image_count) - return; + return; displayed = num; displayDo(DISPLAY_FULL); } void de::uvok::badge::display_indicator(DisplayIndicator indicator) +{ + // no idea what do about initial state.. + display.setRotation(rotation); + display.setTextColor(GxEPD_BLACK); + display.setFont(&FreeMono9pt7b); + + const char *display_text; + switch (indicator) { + case DisplayIndicator::None: + display_text = ""; + break; + case DisplayIndicator::Advertising: + display_text = "Adv"; + break; + case DisplayIndicator::Connected: + display_text = "Conn"; + break; + } + int16_t tbx, tby; + uint16_t tbw, tbh; + display.getTextBounds(display_text, 0, 0, &tbx, &tby, &tbw, &tbh); -} + constexpr int TEXT_BORDER = 3; + display.firstPage(); + do + { + if (is_initial) + { + display.setFullWindow(); + display.clearScreen(); + // display.drawXBitmap(0, 0, (unsigned char *)imgs[displayed].bits, imgs[displayed].width, + // imgs[displayed].height, GxEPD_BLACK); + } + else + { + display.setPartialWindow(tbx - TEXT_BORDER, tby - TEXT_BORDER, tbw + 2 * TEXT_BORDER, + tbh + 2 * TEXT_BORDER); + } + display.fillRect(tbx - TEXT_BORDER, tby - TEXT_BORDER, tbw + 2 * TEXT_BORDER, tbh + 2 * TEXT_BORDER, + GxEPD_WHITE); + display.setCursor(tbx, tby); + display.print(display_text); + } while (display.nextPage()); + + display.hibernate(); +} /* // -> |