Add M5Stack Cardputer-Adv variant with keyboard/display companion UI

New variant variants/m5stack_cardputer_adv for the Cardputer-Adv
(ESP32-S3, 8 MB) with the Cap LoRa-1262 (SX1262 + GNSS):

- Envs: companion_radio_ble, companion_radio_usb, repeater, room_server.
- Board: enables the Cap's antenna path via the PI4IOE5V6408 on the
  internal I2C bus (Wire1, G8/G9); Wire stays on the Grove port. LoRa and
  microSD share FSPI because the display owns SPI3. TCXO 1.8 V.
- Companion UI adapted from MultiMote/meshcore-cardputer-adv (MIT,
  LICENSE.MultiMote), running on the standard companion so the USB
  terminal CLI stays available. Contacts/identity stay in internal
  SPIFFS; the microSD card is optional (chat history, keyboard layouts).
- Sticky Shift, one-shot Fn with Fn+letter shortcuts, top button (G0)
  sends a flood advert, brightness control.
- Text size setting (Normal/Large/Extra large) with DejaVu Sans fonts
  generated by tools/gen_vlw_font.py; layouts derive from the font size.
- Power save maps to the companion's powersaving pref; the UI vetoes
  light sleep while the screen is on. Low-battery power-off at 3.4 V.
- win_long_cmdline.py: Windows-only -iprefix include shortening so the
  ESP32 compile command stays under the 32,767-character limit.

Shared companion changes are guarded by CARDPUTER_ADV_UI: main.cpp
selects CardputerDataStore/CardputerUITask/CardputerMesh, and MyMesh.h
maps the_mesh to the subclass like the PSRAM storage path does.

Tested on hardware (910.525 MHz mesh): radio RX/TX, USB CLI, BLE, UI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mjgodatandClaude Opus 5.5 committed 2026-10-27 16:24:43 -07:00
1 parent 3ec3a07236
commit 5681898ad4
60 files changed
+25938 -3

No files matched your search

+4
View File
@@ -1189,6 +1189,10 @@ private:
MyMesh& companionMeshInstance();
// Keep the shared UI/CLI lvalue interface; the accessor never allocates.
#define the_mesh companionMeshInstance()
#elif CARDPUTER_ADV_UI
// The Cardputer-Adv UI owns a MyMesh subclass (variants/m5stack_cardputer_adv).
MyMesh& cardputerMeshInstance();
#define the_mesh cardputerMeshInstance()
#else
extern MyMesh the_mesh;
#endif
+42 -3
View File
@@ -268,11 +268,21 @@ static bool isNetworkTerminalActive();
DataStore store(LittleFS, rtc_clock);
#elif defined(ESP32)
#include <SPIFFS.h>
DataStore store(SPIFFS, rtc_clock);
#if CARDPUTER_ADV_UI
#include "CardputerDataStore.h"
CardputerDataStore store(SPIFFS, rtc_clock);
#else
DataStore store(SPIFFS, rtc_clock);
#endif
#endif
/* GLOBAL OBJECTS */
#ifdef DISPLAY_CLASS
#if CARDPUTER_ADV_UI
// Keyboard/display UI for the M5Stack Cardputer-Adv (variant-provided).
#include "CardputerMesh.h"
#include <SD.h>
CardputerUITask ui_task(&board, &interface_manager);
#elif defined(DISPLAY_CLASS)
#include "UITask.h"
UITask ui_task(&board, &interface_manager);
#endif
@@ -293,6 +303,9 @@ static bool initializeCompanionMeshStorage() {
: "ERROR: insufficient PSRAM for Full Companion; startup stopped");
return false;
}
#elif CARDPUTER_ADV_UI
CardputerMesh the_mesh_cp(radio_driver, fast_rng, rtc_clock, tables, store, &ui_task);
MyMesh& cardputerMeshInstance() { return the_mesh_cp; }
#else
MyMesh the_mesh(radio_driver, fast_rng, rtc_clock, tables, store
#ifdef DISPLAY_CLASS
@@ -3830,6 +3843,16 @@ void setup() {
companion_display_begin_status = companion_display_available ? 1 : 0;
#endif
#endif
#endif
#if CARDPUTER_ADV_UI
DisplayDriver* cardputer_disp = NULL;
if (display.begin()) {
cardputer_disp = &display;
display.startFrame();
display.setTextSize(2);
display.drawTextCentered(display.width() / 2, 28, "Loading...");
display.endFrame();
}
#endif
int radioinit_attempts = 0;
@@ -4267,7 +4290,17 @@ void setup() {
the_mesh.applyGpsPrefs();
#endif
#ifdef DISPLAY_CLASS
#if CARDPUTER_ADV_UI
// microSD is optional: chat history and keyboard layouts.
FILESYSTEM* cardputer_sd = NULL;
if (SD.begin(PIN_SD_CS, lora_spi, 25000000)) {
cardputer_sd = &SD;
board.readKeyboardLayout(SD);
}
store.beginCustom(cardputer_sd);
the_mesh_cp.beginCustom();
ui_task.begin(cardputer_disp, &sensors, the_mesh.getNodePrefs(), the_mesh_cp.getCustomNodePrefs());
#elif defined(DISPLAY_CLASS)
#if defined(HELTEC_V4_DISPLAY_UNIFIED) && HELTEC_V4_DISPLAY_UNIFIED
// Retain the wrapper dependency in headless mode so live selection can
// enable a screen. The UI skips rendering while no backend is selected.
@@ -4409,6 +4442,9 @@ void loop() {
#if defined(WIO_E5_MINI_HEADLESS_COMPANION_UI) && defined(PIN_USER_BTN)
serviceWioE5HeadlessControls();
#endif
#if CARDPUTER_ADV_UI
ui_task.loop();
#endif
#ifdef DISPLAY_CLASS
// Keep button/touch and critical UI power checks live. UITask itself skips
// only background redraws while the radio needs precise Morse timing.
@@ -4477,6 +4513,9 @@ void loop() {
if (pending) return pending;
if (mesh::isUsbLoggingWatchdogArmed()) return mask(Reason::UsbRecovery);
if (mesh::wireless::control().pending()) return mask(Reason::Wireless);
#if CARDPUTER_ADV_UI
if (ui_task.isAwake()) return mask(Reason::Button);
#endif
return 0;
}();
#if defined(ESP32_PLATFORM) && MESH_USB_LOGGING_AVAILABLE