Browse Source

made it compile properly with new rp-hal

master
Weird Constructor 11 months ago
parent
commit
61cdc02d76
  1. 2
      ws2812_bl_ctrl/Cargo.toml
  2. 19
      ws2812_bl_ctrl/src/main.rs
  3. 4
      ws2812_bl_ctrl/ws2812-pio-rs/Cargo.toml
  4. 2
      ws2812_bl_ctrl/ws2812-pio-rs/src/lib.rs

2
ws2812_bl_ctrl/Cargo.toml

@ -17,7 +17,7 @@ defmt-rtt = "0.2.0"
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
#rp2040-hal = { git = "https://github.com/rp-rs/rp-hal", branch="main", features=["rt"] }
rp2040-boot2 = { git = "https://github.com/rp-rs/rp2040-boot2-rs", branch="main" }
#rp2040-boot2 = { git = "https://github.com/rp-rs/rp2040-boot2-rs", branch="main" }
rp-pico = { git = "https://github.com/rp-rs/rp-hal.git", branch="main" }
smart-leds = "0.3.0"

19
ws2812_bl_ctrl/src/main.rs

@ -23,9 +23,9 @@ use rp_pico::hal::pio::PIOExt;
use smart_leds::{brightness, SmartLedsWrite, RGB8};
use ws2812_pio::Ws2812;
#[link_section = ".boot2"]
#[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
//#[link_section = ".boot2"]
//#[used]
//pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
const LEN : usize = 100;
@ -212,6 +212,8 @@ pub fn rd_val(code: &[u8], led_idx: u16, r: u32) -> Result<(u32, usize), ()> {
// ; /l06 %r02 +r01 !
pub fn exec_wledcode(dt: f32, code: &[u8], strip: &mut [RGB8]) -> Result<(), ()> {
let mut regs : [(f32, f32, f32); 256] = [(0.0, 0.0, 0.0); 256];
let mut stack : [u32; 256] = [0; 256];
let mut stack_ptr = 0;
let mut rp = 0;
let mut pc : usize = 0;
@ -283,12 +285,21 @@ pub fn exec_wledcode(dt: f32, code: &[u8], strip: &mut [RGB8]) -> Result<(), ()>
pc += len;
r = a / b;
},
b'^' => {
stack[stack_ptr] = r;
if stack_ptr < 255 { stack_ptr += 1 }
},
b'.' => {
r = stack[stack_ptr];
if stack_ptr > 0 { stack_ptr -= 1; }
},
b'r' => {
let (new_r, len) = rd_val(&code[pc..], led_idx, r)?;
r = new_r;
pc += len;
},
_ => { },
_ => {
},
}
}

4
ws2812_bl_ctrl/ws2812-pio-rs/Cargo.toml

@ -1,6 +1,6 @@
[package]
name = "ws2812-pio"
version = "0.1.0"
version = "0.2.0"
edition = "2018"
license = "Apache-2.0"
description = "Driver implementation for the WS2812 smart LED using the RP2040's PIO peripheral."
@ -10,8 +10,8 @@ repository = "https://github.com/ithinuel/ws2812-pio-rs/"
[dependencies]
embedded-hal = "0.2.5"
embedded-time = "0.12.0"
pio = "0.2.0"
rp2040-hal = { git = "https://github.com/rp-rs/rp-hal", branch="main", features=["rt"] }
pio = "0.1.0"
smart-leds-trait = "0.2.1"
nb = "1.0.0"
cortex-m = "0.7.3"

2
ws2812_bl_ctrl/ws2812-pio-rs/src/lib.rs

@ -104,7 +104,7 @@ where
a.jmp_with_delay_and_side_set(pio::JmpCondition::Always, &mut wrap_target, T2 - 1, 1);
a.bind(&mut do_zero);
// Do data bit = 0
a.nop_with_delay_and_side_set(T2 - 2, 0);
a.nop_with_delay_and_side_set(T2 - 1, 0);
a.bind(&mut wrap_source);
let program = a.assemble_with_wrap(wrap_source, wrap_target);

Loading…
Cancel
Save