mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-10-16 01:49:59 +00:00
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:
@@ -74,3 +74,21 @@ void zephcore_led_radio_hold_pin(bool held)
|
||||
{
|
||||
atomic_set(&s_radio_holds_pin, held ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Same cross-thread readers/writers as the gate above (heartbeat work queue,
|
||||
* TX path, CLI) — atomic for the same reason. RAM-only on purpose: no
|
||||
* savePrefs() call anywhere near this, see led_gate.h. */
|
||||
static atomic_t s_led_brightness_pct = ATOMIC_INIT(ZEPHCORE_LED_DEFAULT_BRIGHTNESS_PCT);
|
||||
|
||||
uint8_t zephcore_led_brightness_pct(void)
|
||||
{
|
||||
return (uint8_t)atomic_get(&s_led_brightness_pct);
|
||||
}
|
||||
|
||||
void zephcore_led_set_brightness_pct(uint8_t pct)
|
||||
{
|
||||
if (pct > 100) {
|
||||
pct = 100;
|
||||
}
|
||||
atomic_set(&s_led_brightness_pct, pct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user