summaryrefslogtreecommitdiff
path: root/src/display.cpp
diff options
context:
space:
mode:
authoruvok2025-07-20 11:16:11 +0200
committeruvok2025-07-20 12:41:58 +0200
commit7791f43fb1b328e470ed14facc064f4252ce636e (patch)
tree4d6c3647e3d8c4933d53f8f1031aa8bcf30446e9 /src/display.cpp
parentf5794c6f8b8a1f736ea7a524e72aed46baba4bd6 (diff)
Handle r/w/notify properly
signal back bluetooth selection
Diffstat (limited to 'src/display.cpp')
-rw-r--r--src/display.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/display.cpp b/src/display.cpp
index bc4c8dc..abbe9cf 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -1,5 +1,7 @@
#include "badge/display.h"
+#include "badge/log.h"
+
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMonoBold9pt7b.h>
// #include <GxEPD2_3C.h>
@@ -37,10 +39,11 @@ static uint8_t displayed = 0;
#include "hug.c"
#include "hungry.c"
#include "uvok.c"
+#include "cheebox.c"
void de::uvok::badge::display_init(void)
{
- Serial.println("Init display...");
+ LOG_F("Init display...\n");
#if UVOK_EPAP_DISPLAY == DISPLAY_ELECROW_290_BW
// Turn on once, let controller handle the rest, lest I want to do re-init...
@@ -52,7 +55,7 @@ void de::uvok::badge::display_init(void)
#endif
display.hibernate();
- Serial.println("Display done.");
+ LOG_F("Display done.\n");
}
void de::uvok::badge::display_demo(void)
@@ -96,15 +99,20 @@ const struct
const int height;
const char *text;
} imgs[] = {
- #include "./images.cfg"
+#include "./images.cfg"
};
const int de::uvok::badge::image_count = (ARRAY_LENGTH(imgs));
-typedef enum { DISPLAY_PREVIEW, DISPLAY_FULL} display_mode_t;
-static void displayDo(display_mode_t preview)
+typedef enum
+{
+ DISPLAY_PREVIEW,
+ DISPLAY_FULL
+} display_mode_t;
+
+static void displayDo(display_mode_t mode)
{
- Serial.printf("Print image %d\n", displayed);
+ LOG_F("Print image %d in full mode? %d\n", displayed, mode);
display.setRotation(3);
display.setTextColor(GxEPD_BLACK);
@@ -124,7 +132,7 @@ static void displayDo(display_mode_t preview)
display.firstPage();
do
{
- if (!preview)
+ if (mode == DISPLAY_FULL)
{
display.setFullWindow();
display.drawXBitmap(0, 0, (unsigned char *)imgs[displayed].bits, imgs[displayed].width,
@@ -143,22 +151,34 @@ static void displayDo(display_mode_t preview)
} while (display.nextPage());
}
-void de::uvok::badge::display_prev(void)
+uint8_t de::uvok::badge::display_prev(void)
{
displayed--;
if (displayed >= image_count)
displayed = image_count - 1;
displayDo(DISPLAY_PREVIEW);
+ return displayed;
}
-void de::uvok::badge::display_next(void)
+uint8_t de::uvok::badge::display_next(void)
{
displayed = (displayed + 1) % image_count;
displayDo(DISPLAY_PREVIEW);
+ return displayed;
+}
+
+uint8_t de::uvok::badge::display_refresh(void)
+{
+ displayDo(DISPLAY_FULL);
+ return displayed;
}
-void de::uvok::badge::display_refresh(void)
+void de::uvok::badge::display_direct(uint8_t num)
{
+ LOG_F("Display direct\n");
+ if (num >= image_count)
+ return;
+ displayed = num;
displayDo(DISPLAY_FULL);
}