From b02f1563ae3a61118c35d50e0be724b9c9e13eff Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 5 Jan 2026 08:56:38 +0800 Subject: [PATCH] don't put pin snapping into ws2812 implementation the pin snapping makes the application not composable with other applications that don't use the exact same snapping mode. --- libs/bio-lib/src/ws2812.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/bio-lib/src/ws2812.rs b/libs/bio-lib/src/ws2812.rs index 621a9dab2..8d4c90a95 100644 --- a/libs/bio-lib/src/ws2812.rs +++ b/libs/bio-lib/src/ws2812.rs @@ -46,7 +46,7 @@ impl Drop for Ws2812 { } impl Ws2812 { - pub fn new(variant: LedVariant, bio_pin: u5) -> Result { + pub fn new(variant: LedVariant, bio_pin: u5, io_mode: Option) -> Result { let mut bio_ss = Bio::new(); // claim core resource and initialize it let resource_grant = bio_ss.claim_resources(&Ws2812::resource_spec())?; @@ -64,8 +64,14 @@ impl Ws2812 { // now configure the claimed resource let mut io_config = IoConfig::default(); io_config.mapped = 1 << bio_pin.as_u32(); + // snap the outputs to the quantum of the configured core - io_config.snap_outputs = Some(resource_grant.cores[0].into()); + // don't use this - it causes ws2812 to not be compatible with other applications, e.g. + // captouch. The main drawback is the timing is every so slightly off but it seems + // within tolerance. + // io_config.snap_outputs = Some(resource_grant.cores[0].into()); + + io_config.mode = io_mode.unwrap_or(IoConfigMode::Overwrite); bio_ss.setup_io_config(io_config).unwrap(); // safety: fifo1 and fifo2 are stored in the Ws2812 object so they aren't Drop'd before the object is