Update deps

This commit is contained in:
2023-12-16 16:43:00 +01:00
parent 8066837cc9
commit 607e5b02ef
16 changed files with 469 additions and 3988 deletions

View File

@ -1,11 +1,13 @@
use embassy_rp::{
bind_interrupts,
peripherals::{UART0, USB},
peripherals::{PIO0, PIO1, UART0, USB},
};
bind_interrupts! {
pub struct Irqs {
UART0_IRQ => embassy_rp::uart::BufferedInterruptHandler<UART0>;
USBCTRL_IRQ => embassy_rp::usb::InterruptHandler<USB>;
PIO0_IRQ_0 => embassy_rp::pio::InterruptHandler<PIO0>;
PIO1_IRQ_0 => embassy_rp::pio::InterruptHandler<PIO1>;
}
}

View File

@ -21,6 +21,7 @@ const MIN_IDLE_BRIGHTESS: f32 = 0.05;
#[derive(Clone, Copy)]
enum LightState {
Solid(Rgb),
#[allow(dead_code)]
SolidThenFade {
color: Rgb,
solid_until: Instant,
@ -68,8 +69,12 @@ async fn tick(state: &'static State, lights: &mut [LightState; SWITCH_COUNT]) {
.lights
.update(|rgbs| {
for (button, light) in lights.iter_mut().enumerate() {
let Some(&led_id) = state.led_map.get(button) else { continue; };
let Some(rgb) = rgbs.get_mut(led_id) else { continue; };
let Some(&led_id) = state.led_map.get(button) else {
continue;
};
let Some(rgb) = rgbs.get_mut(led_id) else {
continue;
};
match &*light {
LightState::None => {}
@ -115,7 +120,9 @@ async fn idle_animation(state: &'static State) {
};
for (n, &i) in state.led_map.iter().enumerate() {
let Some(light) = lights.get_mut(i) else { continue };
let Some(light) = lights.get_mut(i) else {
continue;
};
let [r, g, b] = wheel(
(n as u64 * IDLE_ANIMATION_KEY_OFFSET + tick * IDLE_ANIMATION_SPEED) as u8,
)
@ -190,6 +197,8 @@ async fn handle_event(
return;
}
let Some(light) = lights.get_mut(event.source_button) else { return; };
let Some(light) = lights.get_mut(event.source_button) else {
return;
};
*light = rgb;
}

View File

@ -5,7 +5,7 @@ use crc_any::CRCu16;
use embassy_executor::Spawner;
use embassy_rp::peripherals::{PIN_0, PIN_1, UART0};
use embassy_rp::uart::{self, BufferedUart, DataBits, Parity, StopBits};
use embedded_io::asynch::{Read, Write};
use embedded_io_async::{Read, Write};
use futures::{select_biased, FutureExt};
use heapless::Vec;
use serde::{Deserialize, Serialize};

View File

@ -14,6 +14,7 @@ struct State {
device_descriptor: [u8; 256],
config_descriptor: [u8; 256],
bos_descriptor: [u8; 256],
msos_descriptor: [u8; 256],
control_buf: [u8; 64],
}
@ -38,6 +39,7 @@ pub fn builder(usb: USB) -> Builder<'static, Driver<'static, USB>> {
device_descriptor: [0; 256],
config_descriptor: [0; 256],
bos_descriptor: [0; 256],
msos_descriptor: [0; 256],
control_buf: [0; 64],
});
@ -64,6 +66,7 @@ pub fn builder(usb: USB) -> Builder<'static, Driver<'static, USB>> {
&mut state.device_descriptor,
&mut state.config_descriptor,
&mut state.bos_descriptor,
&mut state.msos_descriptor,
&mut state.control_buf,
)
}

View File

@ -1,6 +1,6 @@
use embassy_rp::dma::{self, AnyChannel};
use embassy_rp::interrupt::typelevel::Binding;
use embassy_rp::pio::{self, FifoJoin, Instance, Pio, PioPin, ShiftConfig, ShiftDirection};
use embassy_rp::relocate::RelocatedProgram;
use embassy_rp::{Peripheral, PeripheralRef};
use fixed::FixedU32;
@ -14,10 +14,11 @@ pub struct Ws2812<P: pio::Instance + 'static> {
impl<P: Instance> Ws2812<P> {
pub fn new(
pio: impl Peripheral<P = P> + 'static,
irqs: impl Binding<P::Interrupt, pio::InterruptHandler<P>>,
dma: impl dma::Channel,
pin: impl PioPin,
) -> Self {
let mut pio = Pio::new(pio);
let mut pio = Pio::new(pio, irqs);
let mut sm = pio.sm0;
// prepare the PIO program
let side_set = ::pio::SideSet::new(false, 1, false);
@ -46,8 +47,8 @@ impl<P: Instance> Ws2812<P> {
let prg = a.assemble_with_wrap(wrap_source, wrap_target);
let relocated_prg = RelocatedProgram::new(&prg);
let loaded_prg = pio.common.load_program(&relocated_prg);
//let relocated_prg = RelocatedProgram::new(&prg);
let loaded_prg = pio.common.load_program(&prg);
// Clock config
// TODO CLOCK_FREQ should come from embassy_rp