Skip to content

ledmatrix: Enable sleep pin #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions ledmatrix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ fn main() -> ! {
// INTB. Currently ignoring
pins.intb.into_floating_input();

let sleep = pins.sleep.into_pull_down_input();

let i2c = bsp::hal::I2C::i2c1(
pac.I2C1,
pins.gpio26.into_mode::<gpio::FunctionI2C>(),
Expand Down Expand Up @@ -216,17 +214,31 @@ fn main() -> ! {

let mut startup_percentage = Some(0);

// Detect whether the sleep pin is connected
// Early revisions of the hardware didn't have it wired up, if that is the
// case we have to ignore its state.
let mut sleep_present = false;
let sleep = pins.sleep.into_pull_up_input();
if sleep.is_low().unwrap() {
sleep_present = true;
}
let sleep = sleep.into_pull_down_input();
if sleep.is_high().unwrap() {
sleep_present = true;
}

loop {
// TODO: Current hardware revision does not have the sleep pin wired up :(
// Go to sleep if the host is sleeping
let _host_sleeping = sleep.is_low().unwrap();
//handle_sleep(
// host_sleeping,
// &mut state,
// &mut matrix,
// &mut delay,
// &mut led_enable,
//);
if sleep_present {
// Go to sleep if the host is sleeping
let host_sleeping = sleep.is_low().unwrap();
handle_sleep(
host_sleeping,
&mut state,
&mut matrix,
&mut delay,
&mut led_enable,
);
}

// Handle period display updates. Don't do it too often
if timer.get_counter().ticks() > prev_timer + state.animation_period {
Expand Down