Files
MeshCore-Solo/variants/m5stack_cardputer_adv/target.cpp
T
JakubandClaude Opus 5 05e57357d3 feat(boards): add M5Stack Cardputer ADV and LilyGO T-Echo Lite KeyShield
New M5Stack Cardputer ADV variant (ESP32-S3, ST7789 TFT, built-in TCA8418
QWERTY keyboard, PI4IOE5V6408 LoRa-cap IO-expander autodetect), and a
KeyShield accessory variant for the existing LilyGO T-Echo Lite (external
TCA8418 T9 keypad + AW21009 backlight driver). Both keyboards share one
ENV_USE_TCA8418 polling block in UITask.cpp::loop(), coexisting with the
unrelated CardKB support (different chip/address/flag).

Fixes carried in from the contributed T-Echo Lite code: swapped GPS RX/TX
pins, TX-LED hooks, TCXO voltage, missing GxEPD2_122_T61 panel include.
Fixed during integration: I2C bus was probed for an RTC before Wire.begin()
configured its pins on Cardputer ADV (silent RTC autodetect failure).

Added dedicated *_solo_dual release envs for both boards (auto-picked up by
the solo-firmware release workflow). Gave the T-Echo Lite KeyShield solo
build -Os/-Ofast-unflag like every other nRF52 solo build (was missing,
cut flash usage from 90.7% to 61.4%).

Ported the shared misc-fixed 6x9 font (full Latin/Greek/Cyrillic, opt-in via
OLED_MISC_FIXED_FONT) to ST7789Display for the Cardputer's on-screen
keyboard. ST7789Spi isn't Adafruit_GFX-based like the other single-font
drivers, and this panel's logical->physical scale is non-integer, so glyphs
are re-packed to XBM and blitted through the existing drawXbm(), which
already does correct fractional-scale boundary math, rather than
duplicating that logic.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-08 01:06:24 +02:00

64 lines
1.9 KiB
C++

#include <Arduino.h>
#include "target.h"
CardputerADVBoard board;
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider gps(Serial1, &rtc_clock);
EnvironmentSensorManager sensors(gps);
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
#endif
static void init_lora_cap_ioe() {
const uint8_t PI4IOE_ADDR = 0x43; // PI4IOE5V6408, ADDR pin -> GND
// Egyszerű "probe": ha nincs ACK, nincs ott az IO expander (régi cap)
Wire.beginTransmission(PI4IOE_ADDR);
if (Wire.endTransmission() != 0) {
return; // régi Cap LoRa868, nincs teendő
}
// Új Cap LoRa-1262: P0 -> output, High-Z letiltva, majd HIGH
Wire.beginTransmission(PI4IOE_ADDR);
Wire.write(0x03); // I/O Direction register
Wire.write(0x01); // bit0 = 1 -> P0 kimenet, többi marad bemenet
Wire.endTransmission();
Wire.beginTransmission(PI4IOE_ADDR);
Wire.write(0x07); // Output High-Impedance register
Wire.write(0x00); // bit0 = 0 -> P0 kijön a High-Z állapotból
Wire.endTransmission();
Wire.beginTransmission(PI4IOE_ADDR);
Wire.write(0x05); // Output Port register
Wire.write(0x01); // bit0 = 1 -> P0 HIGH (LoRa "SW" pin engedélyezve)
Wire.endTransmission();
}
bool radio_init() {
fallback_clock.begin();
Wire.begin(PIN_BOARD_SDA, PIN_BOARD_SCL); // 14pin header & internal
Wire1.begin(PIN_BOARD_SDA1, PIN_BOARD_SCL1); // grove
rtc_clock.begin(Wire); // needs Wire already begun on the right pins to auto-detect an RTC chip
init_lora_cap_ioe();
return radio.std_init(&spi);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}