t096: shared PWM brightness for the heartbeat/TX LED (unpersisted)

Single LED (P0.28) doubles as heartbeat, message flash, shutdown flash
and LoRa TX indicator, all sharing the same physical pin. Adds one PWM
channel on that pin (heartbeat-pwm-led/lora-tx-pwm-led aliases) and a
single 0-100 brightness knob (get/set led) covering every one of those
events at once, deliberately RAM-only: resets to a 10% default on every
reboot regardless of CLI changes made in a previous session. The
existing persisted on/off gate (set leds on|off) is untouched.

Boards without heartbeat-pwm-led/lora-tx-pwm-led aliases keep their
current plain-GPIO behavior unchanged.
This commit is contained in:
ZephCore T096
2026-10-08 18:26:59 +02:00
parent 290b0c26b0
commit 2eb8a8e5b7
8 changed files with 210 additions and 27 deletions
+16
View File
@@ -994,6 +994,11 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, const char* command, cha
CLI_HAS_HB_LED ? "" : " (no heartbeat LED on this board)");
} else if (memcmp(config, "leds", 4) == 0) {
snprintf(reply, CLI_REPLY_SIZE, "> %s", _prefs->leds_disabled ? "off" : "on");
} else if (memcmp(config, "led", 3) == 0) {
/* Shared heartbeat/TX brightness, RAM-only — see led_gate.h.
* Checked after "leds" above so "leds" itself never falls
* through to this shorter prefix. */
snprintf(reply, CLI_REPLY_SIZE, "> %u%%", (unsigned)zephcore_led_brightness_pct());
#ifndef ZEPHCORE_REPEATER
} else if (memcmp(config, "buzzer", 6) == 0) {
uint8_t mode = zephcore_buzzer_mode_from_prefs(_prefs->buzzer_quiet);
@@ -1276,6 +1281,17 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, const char* command, cha
savePrefs();
strcpy(reply, "OK");
}
} else if (memcmp(config, "led ", 4) == 0) {
/* Brightness only, on/off stays on "set leds" above. RAM-only —
* no savePrefs() call here on purpose, see led_gate.h. Checked
* after "leds " so that command never falls through here. */
int pct = atoi(&config[4]);
if (pct < 0 || pct > 100) {
strcpy(reply, "Error: must be 0-100");
} else {
zephcore_led_set_brightness_pct((uint8_t)pct);
snprintf(reply, CLI_REPLY_SIZE, "OK - led=%d%%", pct);
}
#ifndef ZEPHCORE_REPEATER
} else if (memcmp(config, "buzzer ", 7) == 0) {
/* 0 = silent, 1 = sound + vibration, 2 = vibration only,