touch: P4 antenna — gate the legacy auto mode behind the same warning

Auto was still one tap away with no prompt, which contradicts the safety model
in b066c37: the legacy per-TX toggle writes the external level on EVERY single
transmit, so it keys the PA into the MMCX socket more often than "External"
does, not less. Both non-internal modes now require an explicit confirmation,
with wording that says what each one actually does to the transmit path.

Internal stays promptless (it is the safe state), and the revert-then-reapply
shape is unchanged, so a dismissed dialog still leaves the UI and the hardware
where they were. The pending mode moves into a static because showConfirm takes
a bare callback with no user data.

Verified on the device (T-Display P4, MAC ...e1:c2:a7): clean boot, only
rst:0x1 (POWERON) in the log, "[XL9535] power-on sequence done" so the antenna
park runs, and "[C6-AT] SNTP -> rtc 1785412930" decoding to 2026-07-30
12:02:10 UTC, which also confirms the ClockFloorRTC system-clock mirror from
fe87ff0 firing on real hardware.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kaj Schittecat
2026-07-30 14:02:52 +02:00
co-authored by Claude Opus 4.8
parent b066c379c0
commit a3550d2190
+28 -16
View File
@@ -9556,29 +9556,41 @@ static void radioScopeDirectToggleCb(lv_event_t* e) {
// what kills a PA, so the safe state has to be the one you get for free after a power cycle,
// and picking the external antenna has to be a fresh, explicit decision each time.
static lv_obj_t* s_p4_ant_dd = nullptr; // showConfirm takes a bare callback, so stash the widget
static uint8_t s_p4_ant_pending = Xl9535::ANT_INTERNAL;
static void radioP4AntennaExternalApply() {
xl9535.setAntennaMode(Xl9535::ANT_EXTERNAL); // takes effect on the very next transmit
if (s_p4_ant_dd) lv_dropdown_set_selected(s_p4_ant_dd, Xl9535::ANT_EXTERNAL);
if (g_lv.task) g_lv.task->showAlert(TR("External antenna selected"), 1200);
static void radioP4AntennaConfirmApply() {
xl9535.setAntennaMode(s_p4_ant_pending); // takes effect on the very next transmit
if (s_p4_ant_dd) lv_dropdown_set_selected(s_p4_ant_dd, s_p4_ant_pending);
if (g_lv.task) {
g_lv.task->showAlert(s_p4_ant_pending == Xl9535::ANT_EXTERNAL ? TR("External antenna selected")
: TR("Per-transmit switching on"), 1200);
}
}
static void radioP4AntennaSelectCb(lv_event_t* e) {
if (lv_event_get_code(e) != LV_EVENT_VALUE_CHANGED) return;
lv_obj_t* dd = lv_event_get_target(e);
const uint8_t m = (uint8_t)lv_dropdown_get_selected(dd);
if (m == Xl9535::ANT_EXTERNAL) {
// Revert the widget FIRST and only re-select it from the confirm handler: showConfirm has no
// cancel callback, so a dismissed dialog must leave both the UI and the hardware on internal.
s_p4_ant_dd = dd;
lv_dropdown_set_selected(dd, xl9535.antennaMode());
showConfirm(TR("Switch to the external antenna?\n\nMake sure an antenna is actually connected "
"to the MMCX socket first. Transmitting with nothing attached can damage the "
"radio.\n\nResets to the on-board antenna on every reboot."),
TR("Switch"), radioP4AntennaExternalApply);
return;
}
xl9535.setAntennaMode(m);
if (m == Xl9535::ANT_INTERNAL) { xl9535.setAntennaMode(m); return; } // always safe, no prompt
// BOTH other modes put the transmitter on the external MMCX: external pins it there, and auto
// (the legacy per-TX toggle) switches to it for every single send — so auto is if anything the
// worse of the two, since it keys the PA into that connector on every transmit rather than only
// while deliberately selected. Neither may be entered without an explicit confirmation.
// Revert the widget FIRST and only re-select from the confirm handler: showConfirm has no cancel
// callback, so a dismissed dialog must leave both the UI and the hardware where they were.
s_p4_ant_dd = dd;
s_p4_ant_pending = m;
lv_dropdown_set_selected(dd, xl9535.antennaMode());
showConfirm(m == Xl9535::ANT_EXTERNAL
? TR("Switch to the external antenna?\n\nMake sure an antenna is actually connected "
"to the MMCX socket first. Transmitting with nothing attached can damage the "
"radio.\n\nResets to the on-board antenna on every reboot.")
: TR("Turn on legacy per-transmit switching?\n\nThis is a diagnostic mode. It sends "
"on the external MMCX socket and listens on the on-board antenna, so it needs "
"an antenna fitted and it will report a weak outbound signal.\n\nResets to the "
"on-board antenna on every reboot."),
TR("Switch"), radioP4AntennaConfirmApply);
}
#endif
#if defined(HELTEC_LORA_V4_TFT)