From 85b10e726f3f6a7ee14a74b270515e1b48b44cf3 Mon Sep 17 00:00:00 2001 From: zdmx <hi@zdmx.me> Date: Thu, 31 Aug 2023 20:23:45 +0200 Subject: [PATCH] Fix some linter warnings --- src/demo_tasks.rs | 2 +- src/flow3r/badgelink/badgenet.rs | 7 +++---- src/flow3r/badgelink/mod.rs | 2 +- src/flow3r/captouch.rs | 30 +++++++++++++++--------------- src/flow3r/imu.rs | 6 +++--- src/flow3r/mod.rs | 4 ++-- src/flow3r/ui/main_menu.rs | 4 ++-- src/main.rs | 4 ++-- src/runtime.rs | 4 ++++ 9 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/demo_tasks.rs b/src/demo_tasks.rs index d4282c8..801450e 100644 --- a/src/demo_tasks.rs +++ b/src/demo_tasks.rs @@ -14,7 +14,7 @@ use embedded_graphics::{ }; use esp_backtrace as _; use esp_println::println; -use hal::{Rng, uart}; +use hal::{Rng}; use heapless::Vec; use smoltcp::wire::IpEndpoint; use tinybmp::Bmp; diff --git a/src/flow3r/badgelink/badgenet.rs b/src/flow3r/badgelink/badgenet.rs index 42c2fe1..2b45bc7 100644 --- a/src/flow3r/badgelink/badgenet.rs +++ b/src/flow3r/badgelink/badgenet.rs @@ -1,13 +1,12 @@ use embassy_executor::Spawner; -use embassy_net::{Config, Ipv6Address, Ipv6Cidr, Stack, StackResources, StaticConfigV6}; +use embassy_net::{Config, Stack, StackResources}; use embassy_net_badgelink::{Device, Runner, State}; use esp_println::println; use hal::{ efuse::Efuse, - peripherals::{UART0, UART1, UART2}, - Rng, Uart, + peripherals::{UART1, UART2}, Uart, }; -use heapless::Vec; + use static_cell::StaticCell; static STATE_LEFT: StaticCell<State<8, 8>> = StaticCell::new(); diff --git a/src/flow3r/badgelink/mod.rs b/src/flow3r/badgelink/mod.rs index ab584af..1dd05c2 100644 --- a/src/flow3r/badgelink/mod.rs +++ b/src/flow3r/badgelink/mod.rs @@ -1,4 +1,4 @@ -use hal::{i2c::I2C, peripherals::{I2C0, UART0, UART1}, Uart, Rng}; +use hal::{i2c::I2C, peripherals::{I2C0}}; use port_expander::{dev::max7321::Driver, Max7321}; use shared_bus::{I2cProxy, NullMutex, XtensaMutex}; diff --git a/src/flow3r/captouch.rs b/src/flow3r/captouch.rs index 9a7c977..282766f 100644 --- a/src/flow3r/captouch.rs +++ b/src/flow3r/captouch.rs @@ -93,24 +93,24 @@ impl Flow3rPetal { pub fn pressed(&self) -> bool { match self { Flow3rPetal::TOP { - number, + number: _, ccw, base, cw, } => ccw.pressed | base.pressed | cw.pressed, - Flow3rPetal::BOTTOM { number, base, tip } => base.pressed | tip.pressed, + Flow3rPetal::BOTTOM { number: _, base, tip } => base.pressed | tip.pressed, } } pub fn position(&self) -> i32 { match self { Flow3rPetal::TOP { - number, + number: _, ccw, base, cw, } => (ccw.raw as i32 + cw.raw as i32) / 2 - base.raw as i32, - Flow3rPetal::BOTTOM { number, base, tip } => base.raw as i32 + tip.raw as i32 / 2, + Flow3rPetal::BOTTOM { number: _, base, tip } => base.raw as i32 + tip.raw as i32 / 2, } } @@ -118,23 +118,23 @@ impl Flow3rPetal { match self { Flow3rPetal::TOP { number, - ccw, - base, - cw, + ccw: _, + base: _, + cw: _, } => *number, - Flow3rPetal::BOTTOM { number, base, tip } => *number, + Flow3rPetal::BOTTOM { number, base: _, tip: _ } => *number, } } - fn update(&mut self, pressed: &[bool], values: &[u16]) { + fn update(&mut self, pressed: &[bool], _values: &[u16]) { match self { Flow3rPetal::TOP { - number, + number: _, ccw, - base, - cw, + base: _, + cw: _, } => ccw.pressed = pressed[0], - Flow3rPetal::BOTTOM { number, base, tip } => todo!(), + Flow3rPetal::BOTTOM { number: _, base: _, tip: _ } => todo!(), } } } @@ -515,7 +515,7 @@ static PETAL_MAPPING_TOP: [(usize, PetalPosition); 12] = [ (6, PetalPosition::BASE), ]; -async fn update_petals_top(interrupts: u16, measurements: [u16; 12]) { +async fn update_petals_top(_interrupts: u16, measurements: [u16; 12]) { let mut petals = PETALS.lock().await; for (i, m) in PETAL_MAPPING_TOP.iter().enumerate() { let pressed = measurements[i] > 50000; @@ -575,7 +575,7 @@ static PETAL_MAPPPING_BOT: [(usize, PetalPosition); 12] = [ (2, PetalPosition::CW), ]; -async fn update_petals_bot(interrupts: u16, measurements: [u16; 12]) { +async fn update_petals_bot(_interrupts: u16, measurements: [u16; 12]) { let mut petals = PETALS.lock().await; for (i, m) in PETAL_MAPPPING_BOT.iter().enumerate() { let pressed = measurements[i] > 40000; diff --git a/src/flow3r/imu.rs b/src/flow3r/imu.rs index c6b012d..770745a 100644 --- a/src/flow3r/imu.rs +++ b/src/flow3r/imu.rs @@ -1,5 +1,5 @@ -use bmi270::{interface::I2cInterface, AuxData, AxisData, Bmi270, Error, PwrCtrl}; -use esp_println::println; +use bmi270::{interface::I2cInterface, AuxData, AxisData, Bmi270, Error}; + use hal::{i2c::I2C, peripherals::I2C0}; use shared_bus::{I2cProxy, XtensaMutex}; @@ -9,7 +9,7 @@ pub struct ImuHandler { impl ImuHandler { pub fn new(i2c: I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>) -> Self { - let mut bmi270 = Bmi270::new_i2c(i2c, bmi270::I2cAddr::Default, bmi270::Burst::Max); + let bmi270 = Bmi270::new_i2c(i2c, bmi270::I2cAddr::Default, bmi270::Burst::Max); /* if let Some(chip_id) = bmi270.get_chip_id().ok() { diff --git a/src/flow3r/mod.rs b/src/flow3r/mod.rs index 39f820e..a084d21 100644 --- a/src/flow3r/mod.rs +++ b/src/flow3r/mod.rs @@ -1,5 +1,5 @@ -use hal::{Uart, Rng}; -use hal::peripherals::{UART0, UART1}; +use hal::{Rng}; + use self::badgelink::BadgeLink; use self::badgelink::badgenet::{BadgenetUartLeft, BadgenetUartRight}; diff --git a/src/flow3r/ui/main_menu.rs b/src/flow3r/ui/main_menu.rs index dd602dd..99277b2 100644 --- a/src/flow3r/ui/main_menu.rs +++ b/src/flow3r/ui/main_menu.rs @@ -10,7 +10,7 @@ use hal::Rng; use static_cell::StaticCell; use crate::{ - demo_tasks::{display_demo, imu_demo, captouch_demo, badgelink_demo}, + demo_tasks::{display_demo, imu_demo, captouch_demo}, flow3r::{display::Display, input::InputHandler, imu::ImuHandler, badgelink::{badgenet::{BadgenetUartLeft, BadgenetUartRight}, BadgeLink}}, }; @@ -111,7 +111,7 @@ async fn play_transition_animation<'a>( } } -async fn start_current_app(app: &str, display: &mut Display, imu: &mut ImuHandler, badgelink: &mut BadgeLink, uart0: &'static mut BadgenetUartLeft, uart1: &'static mut BadgenetUartRight, rng: &'static mut Rng) -> (&'static mut BadgenetUartLeft, &'static mut BadgenetUartRight, &'static mut Rng) { +async fn start_current_app(app: &str, display: &mut Display, imu: &mut ImuHandler, _badgelink: &mut BadgeLink, uart0: &'static mut BadgenetUartLeft, uart1: &'static mut BadgenetUartRight, rng: &'static mut Rng) -> (&'static mut BadgenetUartLeft, &'static mut BadgenetUartRight, &'static mut Rng) { match app { "input_test" => {display_demo(display).await; (uart0, uart1, rng)} "imu_test" =>{imu_demo(display, imu).await; (uart0, uart1, rng)} diff --git a/src/main.rs b/src/main.rs index 357e55c..133466c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,9 +8,9 @@ mod demo_tasks; mod flow3r; mod runtime; -use demo_tasks::{draw_start_screen, badgelink_demo}; +use demo_tasks::{draw_start_screen}; use embassy_executor::Spawner; -use embassy_time::{Duration, Timer}; + use esp_backtrace as _; use flow3r::{ui::main_menu::main_menu, Flow3r}; diff --git a/src/runtime.rs b/src/runtime.rs index e57770a..ee8258c 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -92,6 +92,8 @@ async fn init_runtime() { let app_core_fn = APP_CORE_FN.init(start_app_core); let mut cpu_control = CpuControl::new(system.cpu_control); let _ = APP_CORE_GUARD.init(cpu_control.start_app_core(app_core_fn).unwrap()); + + println!("started second core"); // Async requires the GPIO interrupt to wake futures hal::interrupt::enable( @@ -231,6 +233,8 @@ async fn init_runtime() { )) .ok(); + println!("Init finished, handing over to main"); + // Hand over to main task spawner.spawn(main(flow3r)).ok(); /*spawner.spawn(test_pins_a(io.pins.gpio5)).unwrap(); -- GitLab