mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 14:12:05 +00:00

* 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..
108 lines
4.1 KiB
C++
108 lines
4.1 KiB
C++
#pragma once
|
|
|
|
#include "configuration.h"
|
|
|
|
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
|
|
|
|
// InkHUD-specific components
|
|
// ---------------------------
|
|
#include "graphics/niche/InkHUD/InkHUD.h"
|
|
|
|
// Applets
|
|
#include "graphics/niche/InkHUD/Applets/User/AllMessage/AllMessageApplet.h"
|
|
#include "graphics/niche/InkHUD/Applets/User/DM/DMApplet.h"
|
|
#include "graphics/niche/InkHUD/Applets/User/Heard/HeardApplet.h"
|
|
#include "graphics/niche/InkHUD/Applets/User/Positions/PositionsApplet.h"
|
|
#include "graphics/niche/InkHUD/Applets/User/RecentsList/RecentsListApplet.h"
|
|
#include "graphics/niche/InkHUD/Applets/User/ThreadedMessage/ThreadedMessageApplet.h"
|
|
|
|
// Shared NicheGraphics components
|
|
// --------------------------------
|
|
#include "graphics/niche/Drivers/Backlight/LatchingBacklight.h"
|
|
#include "graphics/niche/Drivers/EInk/GDEY0154D67.h"
|
|
#include "graphics/niche/Inputs/TwoButton.h"
|
|
|
|
void setupNicheGraphics()
|
|
{
|
|
using namespace NicheGraphics;
|
|
|
|
// SPI
|
|
// -----------------------------
|
|
|
|
// For NRF52 platforms, SPI pins are defined in variant.h
|
|
SPI1.begin();
|
|
|
|
// E-Ink Driver
|
|
// -----------------------------
|
|
|
|
Drivers::EInk *driver = new Drivers::GDEY0154D67;
|
|
driver->begin(&SPI1, PIN_EINK_DC, PIN_EINK_CS, PIN_EINK_BUSY, PIN_EINK_RES);
|
|
|
|
// InkHUD
|
|
// ----------------------------
|
|
|
|
InkHUD::InkHUD *inkhud = InkHUD::InkHUD::getInstance();
|
|
|
|
// Set the E-Ink driver
|
|
inkhud->setDriver(driver);
|
|
|
|
// Set how many FAST updates per FULL update
|
|
// Set how unhealthy additional FAST updates beyond this number are
|
|
// Todo: observe the display's performance in-person and adjust accordingly.
|
|
// Currently set to the values given by Elecrow for EInkDynamicDisplay.
|
|
inkhud->setDisplayResilience(10, 1.5);
|
|
|
|
// 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.optionalFeatures.batteryIcon = true; // Device definitely has a battery
|
|
|
|
// 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); // -
|
|
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); // -
|
|
inkhud->addApplet("Heard", new InkHUD::HeardApplet, true, false, 0); // Activated, no autoshow, default on tile 0
|
|
|
|
// Start running InkHUD
|
|
inkhud->begin();
|
|
|
|
// Buttons
|
|
// --------------------------
|
|
|
|
Inputs::TwoButton *buttons = Inputs::TwoButton::getInstance(); // Shared NicheGraphics component
|
|
|
|
// Elecrow diagram: https://www.elecrow.com/download/product/CIL12901M/ThinkNode-M1_User_Manual.pdf
|
|
|
|
// #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(); });
|
|
|
|
// #1: Aux Button
|
|
// Labeled "Function Button" by manual
|
|
// Todo: additional features
|
|
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();
|
|
}
|
|
|
|
#endif |