From 5a38ef7f78c0982c92e8c37fa42d00d12b292d73 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Wed, 29 May 2024 23:16:28 +0200 Subject: [PATCH] Remove deprecated neopixel files --- lib/src/lib.rs | 1 - lib/src/neopixel.pio | 11 ---- lib/src/neopixel.rs | 122 ------------------------------------------ lib/src/neopixel2.pio | 8 --- 4 files changed, 142 deletions(-) delete mode 100644 lib/src/neopixel.pio delete mode 100644 lib/src/neopixel.rs delete mode 100644 lib/src/neopixel2.pio diff --git a/lib/src/lib.rs b/lib/src/lib.rs index f135046..3ec2ba0 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -31,7 +31,6 @@ pub mod keys; pub mod layer; pub mod layout; pub mod logger; -pub mod neopixel; pub mod rgb; pub mod rtt; pub mod serial_proto; diff --git a/lib/src/neopixel.pio b/lib/src/neopixel.pio deleted file mode 100644 index 07bb991..0000000 --- a/lib/src/neopixel.pio +++ /dev/null @@ -1,11 +0,0 @@ -.program ws2812 -.side_set 1 -.wrap_target -bitloop: - out x 1 side 0 [6]; Drive low. Side-set still takes place before instruction stalls. - jmp !x do_zero side 1 [3]; Branch on the bit we shifted out previous delay. Drive high. - do_one: - jmp bitloop side 1 [4]; Continue driving high, for a one (long pulse) - do_zero: - nop side 0 [4]; Or drive low, for a zero (short pulse) -.wrap diff --git a/lib/src/neopixel.rs b/lib/src/neopixel.rs deleted file mode 100644 index eb53ef8..0000000 --- a/lib/src/neopixel.rs +++ /dev/null @@ -1,122 +0,0 @@ -/* -use embassy_rp::{ - gpio::{AnyPin, Drive, SlewRate}, - peripherals::{DMA_CH0, PIO0}, - pio::{FifoJoin, PioPeripheral, PioStateMachine, ShiftDirection}, - pio_instr_util, - relocate::RelocatedProgram, - PeripheralRef, -}; -use embassy_time::{Duration, Timer}; - -#[embassy_executor::task] -pub async fn test(pio: PIO0, pin: AnyPin, dma: DMA_CH0) { - let (_common, mut sm, ..) = pio.split(); - let mut dma = PeripheralRef::new(dma); - - let pio_program = pio_proc::pio_file!("src/neopixel.pio"); - - let relocated = RelocatedProgram::new(&pio_program.program); - sm.write_instr(relocated.origin() as usize, relocated.code()); - pio_instr_util::exec_jmp(&mut sm, relocated.origin()); - - let pin = sm.make_pio_pin(pin); - sm.set_set_pins(&[&pin]); - sm.set_sideset_base_pin(&pin); - sm.set_sideset_count(1); - - // Clock config - // TODO CLOCK_FREQ should come from embassy_rp - const CLOCK_FREQ: u32 = 125_000_000; - const WS2812_FREQ: u32 = 800_000; - const CYCLES_PER_BIT: u32 = 16; - - let bit_freq = WS2812_FREQ * CYCLES_PER_BIT; - let mut int = CLOCK_FREQ / bit_freq; - let rem = CLOCK_FREQ - (int * bit_freq); - let frac = (rem * 256) / bit_freq; - // 65536.0 is represented as 0 in the pio's clock divider - if int == 65536 { - int = 0; - } - sm.set_clkdiv((int << 8) | frac); - let pio::Wrap { source, target } = relocated.wrap(); - sm.set_wrap(source, target); - - sm.set_autopull(true); - sm.set_fifo_join(FifoJoin::TxOnly); - sm.set_pull_threshold(8); // 24? - sm.set_out_shift_dir(ShiftDirection::Left); - - sm.set_enable(true); - - log::info!("wrap: {:?}", sm.get_wrap()); - log::info!("addr: {:?}", sm.get_addr()); - log::info!("sideset_base: {:?}", sm.get_sideset_base()); - log::info!("sideset_count: {:?}", sm.get_sideset_count()); - log::info!("in_base: {:?}", sm.get_in_base()); - log::info!("jmp_pin: {:?}", sm.get_jmp_pin()); - log::info!("set_range: {:?}", sm.get_set_range()); - log::info!("out_range: {:?}", sm.get_out_range()); - log::info!("pull_threshold: {:?}", sm.get_pull_threshold()); - log::info!("push_threshold: {:?}", sm.get_push_threshold()); - - //sm = rp2pio.StateMachine( - // assembled, - // frequency=12_800_000, # to get appropriate sub-bit times in PIO program - // first_sideset_pin=NEOPIXEL, - // auto_pull=True, - // out_shift_right=False, - // pull_threshold=8, - //) - - loop { - log::info!("sending dma"); - - sm.dma_push(dma.reborrow(), &[0x0a, 0x00, 0x00]).await; - Timer::after(Duration::from_millis(500)).await; - sm.dma_push(dma.reborrow(), &[0x00, 0x0a, 0x00]).await; - Timer::after(Duration::from_millis(500)).await; - sm.dma_push(dma.reborrow(), &[0x00, 0x00, 0x0a]).await; - Timer::after(Duration::from_millis(500)).await; - - //sm0.set_enable(true); - } -} - -#[embassy_executor::task] -pub async fn test_blink(pio: PIO0, pin: AnyPin) { - log::info!("test blink hehe"); - let (_, mut sm, ..) = pio.split(); - // Setup sm2 - - // blink - let prg = pio_proc::pio_file!("src/blink.pio"); - - let relocated = RelocatedProgram::new(&prg.program); - let out_pin = sm.make_pio_pin(pin); - let pio_pins = [&out_pin]; - sm.set_set_pins(&pio_pins); - sm.set_set_range(25, 1); - - sm.write_instr(relocated.origin() as usize, relocated.code()); - pio_instr_util::exec_jmp(&mut sm, relocated.origin()); - // sm.set_clkdiv((65535 << 8) + 255 as u32); - // sm.set_clkdiv(0); - - let pio::Wrap { source, target } = relocated.wrap(); - sm.set_wrap(source, target); - - // sm.set_clkdiv((125e6 / 20.0 / 2e2 * 256.0) as u32); - sm.set_enable(true); - // sm.wait_push().await as i32; - // sm.push_tx(1); - sm.wait_push(125_000_000).await; - log::info!("started"); - - loop { - sm.wait_irq(3).await; - log::info!("did it!"); - } -} -*/ diff --git a/lib/src/neopixel2.pio b/lib/src/neopixel2.pio deleted file mode 100644 index 6c858aa..0000000 --- a/lib/src/neopixel2.pio +++ /dev/null @@ -1,8 +0,0 @@ -.program ws2812 -.origin 0 -.wrap_target - out x 1 - set pins,1 [1] - mov pins,x [1] - set pins,0 -.wrap