mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
Settings screen (UI_HAS_JOYSTICK_UPDOWN build variant): - Display brightness (5 levels, contrast curve tuned for SH1106 non-linearity) - Buzzer on/off (respected at startup, no more forced unmute) - TX power (2–22 dBm) - Auto-off delay (5s / 15s / 30s / 60s / never) - GPS update interval (off / 30s / 1min / 5min / 15min / 30min) - Timezone offset (UTC-12..+14) for clock screen - Low battery auto-shutdown threshold (off / 3.0–3.5V, default 3.4V) - Battery display mode (icon / % / voltage) Battery: - EMA filter (alpha=0.2) on ADC readings to smooth voltage spikes from uneven load - Battery % calculated using low_batt_mv as 0% anchor - Mute icon repositions dynamically based on battery display width Clock screen on HomeScreen showing time/date with timezone support. Build: - _settings variants added for USB and BLE companion radio builds - Automatic UF2 generation on every build via create-uf2.py post-script - UI_HAS_JOYSTICK_UPDOWN flag guards joystick_up/down to avoid breaking other boards Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#include <Arduino.h>
|
|
#include "target.h"
|
|
#include <helpers/ArduinoHelpers.h>
|
|
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
|
|
|
WioTrackerL1Board board;
|
|
|
|
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);
|
|
|
|
VolatileRTCClock fallback_clock;
|
|
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
|
|
|
#ifdef ENV_INCLUDE_GPS
|
|
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
|
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
|
#else
|
|
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
|
#endif
|
|
|
|
#ifdef DISPLAY_CLASS
|
|
DISPLAY_CLASS display;
|
|
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, false);
|
|
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
|
|
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
|
|
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
|
|
#ifdef UI_HAS_JOYSTICK_UPDOWN
|
|
MomentaryButton joystick_up(JOYSTICK_UP, 1000, true, false, false);
|
|
MomentaryButton joystick_down(JOYSTICK_DOWN, 1000, true, false, false);
|
|
#endif
|
|
#endif
|
|
|
|
bool radio_init() {
|
|
rtc_clock.begin(Wire);
|
|
|
|
return radio.std_init(&SPI);
|
|
}
|
|
|
|
uint32_t radio_get_rng_seed() {
|
|
return radio.random(0x7FFFFFFF);
|
|
}
|
|
|
|
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
|
radio.setFrequency(freq);
|
|
radio.setSpreadingFactor(sf);
|
|
radio.setBandwidth(bw);
|
|
radio.setCodingRate(cr);
|
|
}
|
|
|
|
void radio_set_tx_power(int8_t dbm) {
|
|
radio.setOutputPower(dbm);
|
|
}
|
|
|
|
mesh::LocalIdentity radio_new_identity() {
|
|
RadioNoiseListener rng(radio);
|
|
return mesh::LocalIdentity(&rng); // create new random identity
|
|
}
|
|
|