InkHUD Extended ASCII (#6768)

* Custom AdafruitGFX fonts with extended ASCII encodings

* AppletFont handles re-encoding of UTF-8 text

* Manual parsing of text which may contain non-ASCII chars

* Display emoji reactions, even when unprintable
Important to indicate to users that a message has been received, even if meaning is unclear.

* Superstitious shrink_to_fit
I don't think these help, but they're not hurting!

* Use Windows-1252 fonts by default

* Spelling

* Tidy up nicheGraphics.h

* Documentation

* Fix inverted logic
Slipped in during a last minute renaming while tidying up to push..
This commit is contained in:
todd-herbert
2025-05-23 11:16:53 +12:00
committed by GitHub
parent b12e9d43be
commit ba1ef45024
33 changed files with 3977 additions and 914 deletions

View File

@@ -22,10 +22,6 @@
#include "graphics/niche/Drivers/EInk/GDEY0154D67.h"
#include "graphics/niche/Inputs/TwoButton.h"
#include "graphics/niche/Fonts/FreeSans6pt7b.h"
#include "graphics/niche/Fonts/FreeSans6pt8bCyrillic.h"
#include <Fonts/FreeSans9pt7b.h>
void setupNicheGraphics()
{
using namespace NicheGraphics;
@@ -33,14 +29,13 @@ void setupNicheGraphics()
// SPI
// -----------------------------
// For NRF52 platforms, SPI pins are defined in variant.h, not passed to begin()
// For NRF52 platforms, SPI pins are defined in variant.h
SPI1.begin();
// Driver
// E-Ink Driver
// -----------------------------
// Use E-Ink driver
Drivers::EInk *driver = new Drivers::GDEY0154D67; // Todo: confirm display model
Drivers::EInk *driver = new Drivers::GDEY0154D67;
driver->begin(&SPI1, PIN_EINK_DC, PIN_EINK_CS, PIN_EINK_BUSY, PIN_EINK_RES);
// InkHUD
@@ -48,7 +43,7 @@ void setupNicheGraphics()
InkHUD::InkHUD *inkhud = InkHUD::InkHUD::getInstance();
// Set the driver
// Set the E-Ink driver
inkhud->setDriver(driver);
// Set how many FAST updates per FULL update
@@ -57,33 +52,27 @@ void setupNicheGraphics()
// Currently set to the values given by Elecrow for EInkDynamicDisplay.
inkhud->setDisplayResilience(10, 1.5);
// Prepare fonts
InkHUD::Applet::fontLarge = InkHUD::AppletFont(FreeSans9pt7b);
InkHUD::Applet::fontSmall = InkHUD::AppletFont(FreeSans6pt7b);
/*
// Font localization demo: Cyrillic
InkHUD::Applet::fontSmall = InkHUD::AppletFont(FreeSans6pt8bCyrillic);
InkHUD::Applet::fontSmall.addSubstitutionsWin1251();
*/
// Select fonts
InkHUD::Applet::fontLarge = FREESANS_9PT_WIN1252;
InkHUD::Applet::fontSmall = FREESANS_6PT_WIN1252;
// Customize default settings
inkhud->persistence->settings.userTiles.maxCount = 2; // Two applets side-by-side
inkhud->persistence->settings.rotation = 0; // To be confirmed?
inkhud->persistence->settings.optionalFeatures.batteryIcon = true; // Device definitely has a battery
// Setup backlight
// Note: button mapping for this configured further down
// Setup backlight controller
// Note: button is attached further down
Drivers::LatchingBacklight *backlight = Drivers::LatchingBacklight::getInstance();
backlight->setPin(PIN_EINK_EN);
// Pick applets
// Note: order of applets determines priority of "auto-show" feature
inkhud->addApplet("All Messages", new InkHUD::AllMessageApplet, true, true); // Activated, autoshown
inkhud->addApplet("DMs", new InkHUD::DMApplet); // Inactive
inkhud->addApplet("Channel 0", new InkHUD::ThreadedMessageApplet(0)); // Inactive
inkhud->addApplet("Channel 1", new InkHUD::ThreadedMessageApplet(1)); // Inactive
inkhud->addApplet("DMs", new InkHUD::DMApplet); // -
inkhud->addApplet("Channel 0", new InkHUD::ThreadedMessageApplet(0)); // -
inkhud->addApplet("Channel 1", new InkHUD::ThreadedMessageApplet(1)); // -
inkhud->addApplet("Positions", new InkHUD::PositionsApplet, true); // Activated
inkhud->addApplet("Recents List", new InkHUD::RecentsListApplet); // Inactive
inkhud->addApplet("Recents List", new InkHUD::RecentsListApplet); // -
inkhud->addApplet("Heard", new InkHUD::HeardApplet, true, false, 0); // Activated, no autoshow, default on tile 0
// Start running InkHUD
@@ -94,25 +83,25 @@ void setupNicheGraphics()
Inputs::TwoButton *buttons = Inputs::TwoButton::getInstance(); // Shared NicheGraphics component
// As labeled on Elecrow diagram: https://www.elecrow.com/download/product/CIL12901M/ThinkNode-M1_User_Manual.pdf
constexpr uint8_t PAGE_TURN_BUTTON = 0;
constexpr uint8_t FUNCTION_BUTTON = 1;
// Elecrow diagram: https://www.elecrow.com/download/product/CIL12901M/ThinkNode-M1_User_Manual.pdf
// Setup the main user button
buttons->setWiring(PAGE_TURN_BUTTON, PIN_BUTTON2);
buttons->setTiming(PAGE_TURN_BUTTON, 50, 500); // Todo: confirm 50ms is adequate debounce
buttons->setHandlerShortPress(PAGE_TURN_BUTTON, []() { InkHUD::InkHUD::getInstance()->shortpress(); });
buttons->setHandlerLongPress(PAGE_TURN_BUTTON, []() { InkHUD::InkHUD::getInstance()->longpress(); });
// #0: Main User Button
// Labeled "Page Turn Button" by manual
buttons->setWiring(0, PIN_BUTTON2);
buttons->setTiming(0, 50, 500); // Todo: confirm 50ms is adequate debounce
buttons->setHandlerShortPress(0, [inkhud]() { inkhud->shortpress(); });
buttons->setHandlerLongPress(0, [inkhud]() { inkhud->longpress(); });
// Setup the aux button
// Initial testing only: mapped to the backlight
// #1: Aux Button
// Labeled "Function Button" by manual
// Todo: additional features
buttons->setWiring(FUNCTION_BUTTON, PIN_BUTTON1);
buttons->setTiming(FUNCTION_BUTTON, 50, 500); // 500ms before latch
buttons->setHandlerDown(FUNCTION_BUTTON, [backlight]() { backlight->peek(); });
buttons->setHandlerLongPress(FUNCTION_BUTTON, [backlight]() { backlight->latch(); });
buttons->setHandlerShortPress(FUNCTION_BUTTON, [backlight]() { backlight->off(); });
buttons->setWiring(1, PIN_BUTTON1);
buttons->setTiming(1, 50, 500); // 500ms before latch
buttons->setHandlerDown(1, [backlight]() { backlight->peek(); });
buttons->setHandlerLongPress(1, [backlight]() { backlight->latch(); });
buttons->setHandlerShortPress(1, [backlight]() { backlight->off(); });
// Begin handling button events
buttons->start();
}