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
@@ -80,4 +80,20 @@
low-power-enable;
};
};
/* Heartbeat/TX LED, PWM path (see heltec_t096_nrf52840.dts, pwm_led_white).
* Same P0.28 net as the plain gpio-leds node — free in pinctrl, no
* other peripheral claims it. */
pwm0_default: pwm0_default {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 28)>;
};
};
pwm0_sleep: pwm0_sleep {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 0, 28)>;
low-power-enable;
};
};
};
@@ -15,6 +15,7 @@
#include <zephyr/dt-bindings/lora/sx126x.h>
#include <zephyr/dt-bindings/adc/nrf-saadc.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include "heltec_t096_nrf52840-pinctrl.dtsi"
/ {
@@ -34,6 +35,16 @@
aliases {
led0 = &led_white;
lora-tx-led = &led_white;
/* Same physical LED (P0.28) as led0/lora-tx-led above, reached
* through the PWM peripheral instead of a raw GPIO write. Both
* ui_common.c (heartbeat/message/shutdown) and ZephyrBoard.cpp
* (LoRa TX flash) prefer this alias over the plain GPIO one when
* it exists, so every event that used to hit led_white now goes
* through the shared brightness in helpers/led_gate.h instead —
* deliberately one dimmer for the whole LED, not a separate
* heartbeat-only control (see helpers/led_gate.h). */
heartbeat-pwm-led = &pwm_led_white;
lora-tx-pwm-led = &pwm_led_white;
sw0 = &user_button;
lora0 = &lora;
watchdog0 = &wdt0;
@@ -51,6 +62,20 @@
};
};
pwmleds {
compatible = "pwm-leds";
/* Same P0.28 net as led_white above, driven by PWM0 channel 0
* instead. Declaring both DT nodes for one pin is an established
* pattern in this project (Heltec V4.3 does the same for its own
* LED) — only one of the two code paths is ever compiled in for a
* given purpose, selected by which alias exists. */
pwm_led_white: pwm_led_gpio28 {
label = "White PWM LED";
pwms = <&pwm0 0 PWM_MSEC(10) PWM_POLARITY_NORMAL>;
};
};
buttons: buttons {
compatible = "gpio-keys";
@@ -276,6 +301,14 @@
status = "okay";
};
/* Drives the shared heartbeat/TX LED (P0.28) via pwm_led_white above. */
&pwm0 {
status = "okay";
pinctrl-0 = <&pwm0_default>;
pinctrl-1 = <&pwm0_sleep>;
pinctrl-names = "default", "sleep";
};
&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
@@ -10,6 +10,9 @@ CONFIG_HW_STACK_PROTECTION=y
# Enable GPIO
CONFIG_GPIO=y
# Enable PWM (shared heartbeat/TX LED brightness)
CONFIG_PWM=y
# Enable UART driver
CONFIG_SERIAL=y