Files
pyxis/lib/tdeck_ui/UI/LXMF/StatusScreen.h
T
Torlando 28ea218a18 refactor(settings): move status readouts to Status screen, reorganize by use
Settings held live status (GPS fix, storage/RAM/identity) that belongs
on the Status screen, plus a per-second tick() doing SPI flash stat
reads and label churn mid-scroll — the main cause of laggy scrolling.

- GPS section (sats/location/altitude/HDOP/time) -> StatusScreen
- System Info (firmware build, storage, RAM) -> StatusScreen, with
  storage/RAM stat reads throttled to ~5s and stack-buffer snprintfs
  instead of Arduino String concatenation
- Settings gains a Status link row (trackball-reachable) that opens
  Route::STATUS; the per-second SettingsScreen tick/refresh is deleted
- Reordered sections by frequency of use: General (name/brightness/
  timeout/kb-light), Notifications, Network (now includes the
  TCP/Auto/BLE interface switches), Radio (LoRa + params), Delivery,
  Advanced, DANGER: Transport Mode (still final)
- Identity/LXMF hashes shown in Settings were truncated duplicates of
  the Status screen's full display; removed
- main.cpp publishes firmware build + GPS to the Status screen
- Contract test for the storage readout follows the code to StatusScreen
2026-09-04 04:56:07 +00:00

220 lines
5.9 KiB
C++

// Copyright (c) 2024 microReticulum contributors
// SPDX-License-Identifier: MIT
#ifndef UI_LXMF_STATUSSCREEN_H
#define UI_LXMF_STATUSSCREEN_H
#ifdef ARDUINO
#include <Arduino.h>
#include <lvgl.h>
#include <functional>
#include <vector>
#include <microReticulum/Bytes.h>
#include <microReticulum/Identity.h>
// Forward declaration
class TinyGPSPlus;
namespace UI {
namespace LXMF {
/**
* Status Screen
*
* Shows network and identity information:
* - Identity hash
* - LXMF delivery destination hash
* - WiFi status and IP
* - RNS connection status
* - GPS fix (satellites, location, altitude, HDOP, time)
* - System (firmware build, storage, RAM)
*
* Layout:
* ┌─────────────────────────────────────┐
* │ ← Status │ 32px header
* ├─────────────────────────────────────┤
* │ Identity: │
* │ a1b2c3d4e5f6... │
* │ │
* │ LXMF Address: │
* │ f7e8d9c0b1a2... │
* │ │
* │ WiFi: Connected │
* │ IP: 192.168.1.100 │
* │ RSSI: -65 dBm │
* │ │
* │ RNS: Connected │
* └─────────────────────────────────────┘
*/
class StatusScreen {
public:
using BackCallback = std::function<void()>;
using ShareCallback = std::function<void()>;
using RadioActivityCallback = std::function<void()>;
/**
* Create status screen
* @param parent Parent LVGL object
*/
StatusScreen(lv_obj_t* parent = nullptr);
/**
* Destructor
*/
~StatusScreen();
/**
* Set identity hash to display
* @param hash The identity hash
*/
void set_identity_hash(const RNS::Bytes& hash);
/**
* Set LXMF delivery destination hash
* @param hash The delivery destination hash
*/
void set_lxmf_address(const RNS::Bytes& hash);
/**
* Set RNS connection status
* @param connected Whether connected to RNS server
* @param server_name Server hostname
*/
void set_rns_status(bool connected, const String& server_name = "");
/**
* Set the GPS receiver for live fix readouts
*/
void set_gps(TinyGPSPlus* gps);
/**
* Set the exact running firmware build string (e.g. "v0.3.7 [ota_0]")
*/
void set_firmware_version(const String& version);
/**
* Set propagation node display string
* @param display Formatted string like "Auto (NodeName)" or "None"
*/
void set_propagation_node(const String& display);
/**
* BLE peer summary for display (matches BLEInterface::PeerSummary)
*/
struct BLEPeerInfo {
char identity[14]; // First 12 hex chars + null
char mac[18]; // "AA:BB:CC:DD:EE:FF" format
int8_t rssi;
};
static constexpr size_t MAX_BLE_PEERS = 8;
/**
* Set BLE peer info for display
* @param peers Array of peer summaries
* @param count Number of peers
*/
void set_ble_info(const BLEPeerInfo* peers, size_t count);
/**
* Refresh WiFi and connection status
*/
void refresh();
/**
* Set callback for back button
* @param callback Function to call when back is pressed
*/
void set_back_callback(BackCallback callback);
/**
* Set callback for share button
* @param callback Function to call when share is pressed
*/
void set_share_callback(ShareCallback callback);
/** Open the dedicated current-channel Radio Activity screen. */
void set_radio_activity_callback(RadioActivityCallback callback);
/**
* Show the screen
*/
void show();
/**
* Hide the screen
*/
void hide();
/**
* Get the root LVGL object
*/
lv_obj_t* get_object();
private:
lv_obj_t* _screen;
lv_obj_t* _header;
lv_obj_t* _content;
lv_obj_t* _btn_back;
lv_obj_t* _btn_share;
lv_obj_t* _btn_radio_activity;
// Labels for dynamic content
lv_obj_t* _label_uptime;
lv_obj_t* _label_identity_value;
lv_obj_t* _label_lxmf_value;
lv_obj_t* _label_wifi_status;
lv_obj_t* _label_wifi_ip;
lv_obj_t* _label_wifi_rssi;
lv_obj_t* _label_rns_status;
lv_obj_t* _label_prop_node;
// GPS readout labels (read-only)
lv_obj_t* _label_gps_sats;
lv_obj_t* _label_gps_coords;
lv_obj_t* _label_gps_alt;
lv_obj_t* _label_gps_hdop;
lv_obj_t* _label_gps_time;
// System readout labels (read-only)
lv_obj_t* _label_firmware;
lv_obj_t* _label_storage;
lv_obj_t* _label_ram;
// BLE peer labels (pre-allocated, hidden when unused)
lv_obj_t* _label_ble_header;
lv_obj_t* _label_ble_peers[MAX_BLE_PEERS]; // Each shows identity + rssi + mac
RNS::Bytes _identity_hash;
RNS::Bytes _lxmf_address;
bool _rns_connected;
String _rns_server;
String _prop_node_display;
String _firmware_version;
TinyGPSPlus* _gps;
uint32_t _last_heavy_ms; // throttles storage/RAM stat reads in update_labels()
// BLE peer data (cached for display)
BLEPeerInfo _ble_peers[MAX_BLE_PEERS];
size_t _ble_peer_count;
BackCallback _back_callback;
ShareCallback _share_callback;
RadioActivityCallback _radio_activity_callback;
void create_header();
void create_content();
void update_labels();
void update_gps_labels();
void update_system_labels();
static void on_back_clicked(lv_event_t* event);
static void on_share_clicked(lv_event_t* event);
static void on_radio_activity_clicked(lv_event_t* event);
};
} // namespace LXMF
} // namespace UI
#endif // ARDUINO
#endif // UI_LXMF_STATUSSCREEN_H