Skip to content
Snippets Groups Projects
Commit 49d648ed authored by zdmx's avatar zdmx :crab:
Browse files

implement badge link switching

parent f6adeba4
No related branches found
No related tags found
No related merge requests found
use hal::{i2c::I2C, peripherals::I2C0};
use port_expander::{Max7321, dev::max7321::Driver};
use shared_bus::{I2cProxy, XtensaMutex, NullMutex};
pub mod badgenet; pub mod badgenet;
mod switch;
pub struct BadgeLink; pub struct BadgeLink {
port_expander: Max7321<NullMutex<Driver<I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>>>>
}
impl BadgeLink {
pub fn new(i2c: I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>) -> Self {
let mut port_expander = port_expander::Max7321::new(i2c, true, true, true, false);
Self {
port_expander
}
}
pub fn left_audio(&mut self) {
let mut pes = self.port_expander.split();
pes.p3.set_low();
pes.p4.set_low();
}
pub fn left_badgelink(&mut self) {
let mut pes = self.port_expander.split();
pes.p3.set_high();
pes.p4.set_high();
}
pub fn right_audio(&mut self) {
let mut pes = self.port_expander.split();
pes.p5.set_low();
pes.p6.set_low();
}
pub fn right_badgelink(&mut self) {
let mut pes = self.port_expander.split();
pes.p5.set_high();
pes.p6.set_high();
}
}
use self::badgelink::BadgeLink;
use self::display::Display; use self::display::Display;
use self::leds::Leds; use self::leds::Leds;
...@@ -7,16 +8,16 @@ pub mod display; ...@@ -7,16 +8,16 @@ pub mod display;
pub mod imu; pub mod imu;
pub mod input; pub mod input;
pub mod leds; pub mod leds;
pub mod peripherals;
pub mod sdcard; pub mod sdcard;
pub struct Flow3r { pub struct Flow3r {
pub display: Display, pub display: Display,
pub leds: Leds, pub leds: Leds,
pub badgelink: BadgeLink,
} }
impl Flow3r { impl Flow3r {
pub fn new(display: Display, leds: Leds) -> Self { pub fn new(display: Display, leds: Leds, badgelink: BadgeLink) -> Self {
Self { display, leds } Self { display, leds, badgelink }
} }
} }
#[embassy_executor::task]
pub async fn charging_status_manager() -> ! {
loop {}
}
mod charging;
...@@ -21,7 +21,7 @@ use crate::flow3r::{ ...@@ -21,7 +21,7 @@ use crate::flow3r::{
display::{display_refresh, Display}, display::{display_refresh, Display},
input::input_controller, input::input_controller,
leds::init_leds, leds::init_leds,
Flow3r, Flow3r, badgelink::BadgeLink,
}; };
use crate::main; use crate::main;
...@@ -161,7 +161,9 @@ async fn init_runtime() { ...@@ -161,7 +161,9 @@ async fn init_runtime() {
let rng = RNG.init(Rng::new(peripherals.RNG)); let rng = RNG.init(Rng::new(peripherals.RNG));
let flow3r = Flow3r::new(display, leds); let badgelink = BadgeLink::new(i2c_busmanager.acquire_i2c());
let flow3r = Flow3r::new(display, leds, badgelink);
let spawner = Spawner::for_current_executor().await; let spawner = Spawner::for_current_executor().await;
spawner spawner
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment