Move to new variant structure and refactor inkHUD - Display does not work and SX1262 init fails on HT752-02

This commit is contained in:
Thomas Göttgens
2025-08-07 14:03:14 +02:00
committed by Tom Fifield
parent bfcc6f5bd7
commit 0c8e7481f4
4 changed files with 3 additions and 15 deletions

View File

@@ -0,0 +1,123 @@
/*
Most of the Meshtastic firmware uses preprocessor macros throughout the code to support different hardware variants.
NicheGraphics attempts a different approach:
Per-device config takes place in this setupNicheGraphics() method
(And a small amount in platformio.ini)
This file sets up InkHUD for Heltec VM-E290.
Different NicheGraphics UIs and different hardware variants will each have their own setup procedure.
*/
#pragma once
#include "configuration.h"
#include "mesh/MeshModule.h"
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
// InkHUD-specific components
// ---------------------------
// #include "graphics/niche/InkHUD/InkHUD.h"
#include "graphics/niche/InkHUD/WindowManager.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/DEPG0290BNS800.h"
#include "graphics/niche/Inputs/TwoButton.h"
void setupNicheGraphics()
{
using namespace NicheGraphics;
// SPI
// -----------------------------
// Display is connected to HSPI
SPIClass *hspi = new SPIClass(HSPI);
hspi->begin(PIN_EINK_SCLK, -1, PIN_EINK_MOSI, PIN_EINK_CS);
// E-Ink Driver
// -----------------------------
// Use E-Ink driver
Drivers::EInk *driver = new Drivers::DEPG0290BNS800;
driver->begin(hspi, PIN_EINK_DC, PIN_EINK_CS, PIN_EINK_BUSY);
// InkHUD
// ----------------------------
InkHUD::InkHUD *inkhud = InkHUD::InkHUD::getInstance();
// Set the driver
inkhud->setDriver(driver);
// Set how many FAST updates per FULL update
// Set how unhealthy additional FAST updates beyond this number are
inkhud->setDisplayResilience(7, 1.5);
// Prepare fonts
InkHUD::Applet::fontLarge = FREESANS_9PT_WIN1252;
InkHUD::Applet::fontSmall = FREESANS_6PT_WIN1252;
// Init settings, and customize defaults
inkhud->persistence->settings.userTiles.maxCount = 2; // How many tiles can the display handle?
inkhud->persistence->settings.rotation = 1; // 90 degrees clockwise
inkhud->persistence->settings.userTiles.count = 1; // One tile only by default, keep things simple for new users
inkhud->persistence->settings.optionalMenuItems.nextTile = false; // Behavior handled by aux button instead
inkhud->persistence->settings.optionalFeatures.batteryIcon = true; // Device definitely has a battery
// Setup backlight
// Note: AUX button behavior configured 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
// Optional arguments for defaults:
// - is activated?
// - is autoshown?
// - is foreground on a specific tile (index)?
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, not autoshown, default on tile 0
// inkhud->addApplet("Basic", new InkHUD::BasicExampleApplet);
// inkhud->addApplet("NewMsg", new InkHUD::NewMsgExampleApplet);
// Start running InkHUD
inkhud->begin();
// Buttons
// --------------------------
Inputs::TwoButton *buttons = Inputs::TwoButton::getInstance(); // A shared NicheGraphics component
// Setup the main user button (0)
buttons->setWiring(0, BUTTON_PIN);
buttons->setHandlerShortPress(0, []() { InkHUD::InkHUD::getInstance()->shortpress(); });
buttons->setHandlerLongPress(0, []() { InkHUD::InkHUD::getInstance()->longpress(); });
// Setup the aux button (1)
// Bonus feature of VME290
buttons->setWiring(1, BUTTON_PIN_SECONDARY);
buttons->setHandlerShortPress(1, []() { InkHUD::InkHUD::getInstance()->nextTile(); });
buttons->start();
}
#endif

View File

@@ -0,0 +1,27 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <stdint.h>
#define USB_VID 0x303a
#define USB_PID 0x1001
// The default Wire will be mapped to RTC and Touch
static const uint8_t SDA = 39;
static const uint8_t SCL = 40;
// Default SPI will be mapped to Radio
static const uint8_t SS = 46;
static const uint8_t MOSI = 17;
static const uint8_t MISO = 8;
static const uint8_t SCK = 18;
// Default SPI1 will be mapped to SD Card
#define SPI_MOSI (13)
#define SPI_SCK (14)
#define SPI_MISO (21)
#define SPI_CS (16)
#define SDCARD_CS SPI_CS
#endif /* Pins_Arduino_h */

View File

@@ -0,0 +1,29 @@
[env:t5s3-epaper-inkhud]
extends = esp32s3_base, inkhud
board = t5-epaper-s3
board_build.partition = default_16MB.csv
board_check = false
upload_protocol = esptool
build_flags =
${esp32_base.build_flags}
${inkhud.build_flags}
-I variants/esp32s3/t5s3_epaper
-D PRIVATE_HW
-D MESHTASTIC_EXCLUDE_I2C=1
-D MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
; -D GPS_POWER_TOGGLE
-D HAS_SDCARD
-D SDCARD_USE_SPI1
-D PCF8563_RTC=0x51
build_src_filter =
${esp32s3_base.build_src_filter}
${inkhud.build_src_filter}
lib_deps =
${inkhud.lib_deps} ; InkHUD libs first, so we get GFXRoot instead of AdafruitGFX
${esp32s3_base.lib_deps}
lewisxhe/PCF8563_Library@^1.0.1
lewisxhe/XPowersLib@^0.2.3
lewisxhe/SensorLib@^0.2.2

View File

@@ -0,0 +1,49 @@
// TODO: Display (E-Ink)
#define PIN_EINK_EN 11 // BL
#define PIN_EINK_CS 11
#define PIN_EINK_BUSY -1
#define PIN_EINK_DC 21
#define PIN_EINK_RES -1
#define PIN_EINK_SCLK 14
#define PIN_EINK_MOSI 13 // SDI
#define EPD_WIDTH 960
#define EPD_HEIGHT 540
// TODO: battery voltage measurement (I2C)
// BQ25896
// BQ27220
// #define I2C_SDA SDA
// #define I2C_SCL SCL
// optional GPS
#define GPS_DEFAULT_NOT_PRESENT 1
// #define GPS_RX_PIN 43
// #define GPS_TX_PIN 44
#define BUTTON_PIN 48
#define BUTTON_PIN_SECONDARY 0
#define USE_SX1262
#define LORA_SCK 18
#define LORA_MISO 8
#define LORA_MOSI 17
#define LORA_CS 46
#define LORA_RESET 1
#define LORA_DIO0
#define LORA_DIO1 10
#define LORA_DIO2
#define LORA_RXEN NC
#define LORA_TXEN NC
#ifdef USE_SX1262
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY 47
#define SX126X_RESET LORA_RESET
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 2.4
#endif