Link protocol v2, ESP-NOW leg, gauge tunables + tuning screen; remove Home screen
Protocol v2 (shared header, byte-identical with the 1.3 repo): - typed DATA/CONFIG frames: 0xAA | ver | type | len | payload | XOR | 0x55 - gear split into lever (P/R/N/D/S/M) + target/engaged nibbles, engine rpm, alert bitmap decided here from tunable thresholds, link_config_t tunables - docs/UART_PROTOCOL.md rewritten for v2 Controller A modules: - tunables: gauge calibration + alert thresholds in NVS, 'cfg' serial console, bench override (never persisted) - espnow_link: every frame also broadcast on ESP-NOW ch 1; radio stays in STA (WiFiManager no longer powers it off) - uart_manager: DATA at 5 Hz + CONFIG on change/5 s on both transports - can_driver: publishes gear pieces and rpm, evaluates alerts - tuning_screen: hand-coded Gauge Tuning page (swipe right from Driveline), -/+ rows, enable switches, override sliders, Driveline/Defaults buttons UI: SquareLine Home screen (3 meters + battery) and meters_manager removed; Driveline is the boot screen; Settings back-gesture calls app_show_driveline(). tools/fix_penv_deps.ps1: repairs the shared PlatformIO penv after a 1.3 build. Bench-verified with Controller B: both transports alive, dedupe, override rpm 2000 -> 133.3 Hz tach output. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Tunables Module
|
||||
*
|
||||
* Owns the link_config_t that Controller A pushes to Controller B: Patrol gauge
|
||||
* calibration (tach pulses/rev, coolant PWM law) and the alert thresholds A
|
||||
* evaluates. Persisted in NVS. Editable at runtime over the USB serial console
|
||||
* ("cfg help") until a settings-screen UI exists.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "protocol/automotive_data.h"
|
||||
|
||||
namespace Tunables {
|
||||
|
||||
/**
|
||||
* Load from NVS (or defaults if absent / size mismatch). Call after Serial.begin().
|
||||
*/
|
||||
void init();
|
||||
|
||||
/**
|
||||
* Snapshot of the current configuration (thread-safe copy).
|
||||
*/
|
||||
link_config_t get();
|
||||
|
||||
/**
|
||||
* Current cfg_version. Increments on every change; the UART manager re-sends
|
||||
* a CONFIG frame when it sees a new value.
|
||||
*/
|
||||
uint8_t version();
|
||||
|
||||
/**
|
||||
* Replace the whole configuration (bumps cfg_version, saves to NVS).
|
||||
*/
|
||||
void set(const link_config_t& cfg);
|
||||
|
||||
/**
|
||||
* Reset to link_config_defaults() and save.
|
||||
*/
|
||||
void resetDefaults();
|
||||
|
||||
/**
|
||||
* Set the bench override (bumps cfg_version so it is pushed to B, but NEVER
|
||||
* saved to NVS - a reboot must not leave the gauges pinned to a test value).
|
||||
*/
|
||||
void setOverride(uint8_t mode, uint16_t rpm, uint8_t duty);
|
||||
|
||||
/**
|
||||
* Execute one console command line ("cfg show", "cfg set tach_ppr 4", ...).
|
||||
* @return true if the line was a recognised command
|
||||
*/
|
||||
bool handleCommand(const char* line);
|
||||
|
||||
/**
|
||||
* Non-blocking: read pending bytes from Serial, dispatch complete lines to
|
||||
* handleCommand(). Call from loop().
|
||||
*/
|
||||
void pollSerial();
|
||||
|
||||
} // namespace Tunables
|
||||
Reference in New Issue
Block a user