feat(status): blink the on-board LED as a heartbeat

Also moves the encoder and button onto XIAO ESP32C6 pads: GPIO4/5/6 are
JTAG pins and are not broken out on this board.
This commit is contained in:
Matt Spencer committed 2026-10-17 16:08:30 +01:00
1 parent ebc2f3be7a
commit 74b3a4a06b
4 files changed
+42 -6

No files matched your search

+13 -3
View File
@@ -4,6 +4,7 @@
mod config;
mod encoder;
mod light;
mod status;
mod strip;
mod zigbee_stack;
@@ -12,6 +13,9 @@ use esp_alloc as _;
use esp_backtrace as _;
use esp_hal::gpio::Input;
use esp_hal::gpio::InputConfig;
use esp_hal::gpio::Level;
use esp_hal::gpio::Output;
use esp_hal::gpio::OutputConfig;
use esp_hal::gpio::Pull;
use esp_hal::rmt::Rmt;
use esp_hal::time::Rate;
@@ -55,15 +59,20 @@ async fn main(spawner: embassy_executor::Spawner) -> ! {
let rmt = Rmt::new(peripherals.RMT, rmt_freq)
.expect("init RMT")
.into_async();
// XIAO ESP32C6 pads: D2, D3, D4, D5. GPIO4/5/6 are JTAG and are not
// broken out on this board; GPIO3 and GPIO14 drive the antenna switch.
let strip = Strip::new(WS2812B_TIMING, rmt.channel0, peripherals.GPIO2, rmt_freq)
.expect("configure WS2812B adapter");
// the encoder's common pin is grounded, so both phases and the switch idle
// high and are driven low; the pull-ups make an open contact well defined
let pull_up = InputConfig::default().with_pull(Pull::Up);
let encoder_a = Input::new(peripherals.GPIO4, pull_up);
let encoder_b = Input::new(peripherals.GPIO5, pull_up);
let button = Input::new(peripherals.GPIO6, pull_up);
let encoder_a = Input::new(peripherals.GPIO21, pull_up);
let encoder_b = Input::new(peripherals.GPIO22, pull_up);
let button = Input::new(peripherals.GPIO23, pull_up);
// on-board user LED, starting dark
let led = Output::new(peripherals.GPIO15, Level::High, OutputConfig::default());
// the stack owns persistence: the information bases are restored here and
// written back whenever the stack changes them
@@ -81,6 +90,7 @@ async fn main(spawner: embassy_executor::Spawner) -> ! {
storage,
));
spawner.spawn(status::heartbeat_task(led).expect("spawn heartbeat_task"));
spawner.spawn(light::render_task(strip).expect("spawn render_task"));
spawner.spawn(encoder::encoder_task(encoder_a, encoder_b).expect("spawn encoder_task"));
spawner.spawn(encoder::button_task(button).expect("spawn button_task"));