Files
trail-mate/platform/shared/include/board/LilyGoKeyboard.h
T
vicliuandGitHub 7bade6ab9c Gat562 mesh evb pro (#12)
* feat(gat562): wire nrf52 board runtime and bluetooth stack

* refactor(chat): align shared BLE cores and nrf meshtastic routing

- extract Meshtastic and MeshCore phone/business flows into shared core_chat BLE cores with owner hook seams for ESP and nRF backends

- replace nrf-specific lite adapters with board/platform adapters that consume shared cores and shared storage contracts

- extend nrf Meshtastic radio path with packet history dedupe, flooding rebroadcast, route discovery/traceroute responses, routing ACK/error handling, observed relay learning, retransmit queueing, and next-hop persistence

- persist nrf device identity and node metadata more explicitly, including next-hop state and node-id initialization support

- move nrf chat/contact/blob storage further toward InternalFS-backed persistence and update contact/node store behavior accordingly

- wire gat562 protocol/app facade pieces to the concrete nrf stores/adapters and add supporting app time-sync hooks used by platform runtimes

- add owner-hook split files and planning/status docs to document the ongoing alignment with the reference meshtastic-firmware multi-platform structure

* Add NRF Fusion Pixel font and fix Meshtastic RX

Integrate Fusion Pixel 8px as the NRF mono UI font stack and switch the mono runtime to a dedicated MonoFont/TextRenderer path that can render ASCII, CJK, and symbols from one asset set.

Add the generated NRF font assets and generator script, including the compact font format with per-glyph advance support, and fix the BDF bitmap parsing bug that previously produced blank ASCII glyphs on device.

Move the LVGL Noto CJK font asset out of shared modules into the ESP-specific platform tree and update the related build/config references so the ESP-only font boundary is explicit and NRF does not compile the LVGL asset by accident.

Update the mono UI runtime to use the new renderer, normalize major menu and title labels to uppercase, and wire the GAT562 UI runtime to the Fusion Pixel font.

Fix the core mesh adapter router so Meshtastic and MeshCore backends can coexist without overwriting each other, and ensure active protocol selection is applied before mesh config changes are pushed into the runtime.

Improve GAT562 runtime diagnostics by mirroring debug output to both Serial and Serial2, logging startup radio configuration, and logging raw RX packets with RSSI/SNR so radio-path issues are visible during bring-up.

Relax SX1262 receive polling so it no longer hard-gates RX handling on DIO1 state alone, avoiding a failure mode where the board appeared alive but never delivered packets into the receive path.

Align the NRF Meshtastic adapter with the working ESP behavior for channel handling: use the default expanded public PSK for an unconfigured primary channel, compute channel hashes from the active preset name or Custom label instead of a hard-coded Primary string, and apply the same logic to self-announcement/NodeInfo packets.

Add protocol-layer Meshtastic RX diagnostics for parse, decrypt, decode, text queueing, app-data queueing, unknown-channel, and dedup events to make packet flow visible while validating interoperability.

Fix early duplicate handling for relayed packets so the first valid packet is still delivered into text processing while later relays are correctly suppressed, which restores Broadcast conversation creation and message visibility in the CHATS page.

* feat(gat562): align nrf ui and meshtastic behavior

* Refine mono UI GPS pages and board diagnostics

* refactor: align board runtimes, GAT562 app shell, and BLE integrations

- migrate ESP board-specific implementations and runtime adapters into boards/*
- continue GAT562/Tab5/UI runtime alignment across app and board layers
- sync BLE and runtime integrations, and apply repository clang-format rules

* Refine gat562 mono UI and persist UI settings

* Fix settings persistence and GNSS UI behavior

* Improve mono UI paging and Meshtastic RX fallback

* Align nRF52 Meshtastic BLE and PKI behavior

* Refine mono UI node and chat interactions

* Fix deferred config persistence on gat562 BLE

* Refine mono node compass and GPS layouts

* Include node position in Meshtastic phone info

* Refactor shared board contracts out of ESP platform layer

* Persist node positions across restarts

* Ignore local compile commands database

* Sync README acknowledgements updates

* Apply CI formatting
2026-03-24 16:09:14 +08:00

85 lines
2.4 KiB
C++

/**
* @file LilyGoKeyboard.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2025 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2025-01-04
*
*/
#pragma once
#include <Arduino.h>
#if defined(ARDUINO_T_LORA_PAGER)
#include <Adafruit_TCA8418.h>
#define KB_NONE -1
#define KB_PRESSED 1
#define KB_RELEASED 0
typedef struct LilyGoKeyboardConfigure
{
uint8_t kb_rows;
uint8_t kb_cols;
const char* current_keymap;
const char* current_symbol_map;
uint8_t symbol_key_value;
uint8_t alt_key_value;
uint8_t caps_key_value;
uint8_t caps_b_key_value;
uint8_t char_b_value;
uint8_t backspace_value;
bool has_symbol_key;
} LilyGoKeyboardConfigure_t;
class LilyGoKeyboard : public Adafruit_TCA8418
{
public:
using KeyboardReadCallback = void (*)(int state, char& c);
using GpioEventCallback = void (*)(bool pressed, uint8_t gpio_idx);
using BacklightCallback = void (*)(uint8_t level);
using KeyboardRawCallback = void (*)(bool pressed, uint8_t raw);
LilyGoKeyboard();
~LilyGoKeyboard();
void setPins(int backlight);
bool begin(const LilyGoKeyboardConfigure_t& config, TwoWire& w, uint8_t irq, uint8_t sda = SDA, uint8_t scl = SCL);
void end();
int getKey(char* c);
void setBrightness(uint8_t level);
uint8_t getBrightness();
void setCallback(KeyboardReadCallback cb);
void setGpioEventCallback(GpioEventCallback cb);
void setBacklightChangeCallback(BacklightCallback cb);
void setRawCallback(KeyboardRawCallback cb);
void setRepeat(bool enable);
private:
int update(char* c);
void printDebugInfo(bool pressed, uint8_t k, char keyVal);
char handleSpaceAndNullChar(char keyVal, char& lastKeyVal, bool& pressed);
char getKeyChar(uint8_t k);
bool handleBrightnessAdjustment(uint8_t k, bool pressed);
int handleSpecialKeys(uint8_t k, bool pressed, char* c);
char lastKeyVal = '\n';
int _backlight = -1;
uint8_t _brightness;
uint8_t _irq;
bool symbol_key_pressed = false;
bool cap_key_pressed = false;
bool alt_key_pressed = false;
bool alt_combo_used = false;
bool repeat_function = true;
bool lastState = false;
KeyboardReadCallback cb = NULL;
GpioEventCallback gpio_cb = NULL;
BacklightCallback bl_cb = NULL;
KeyboardRawCallback raw_cb = NULL;
uint32_t lastPressedTime = 0;
const LilyGoKeyboardConfigure_t* _config;
};
#endif