Get simulator to work, adjust Pi version
This commit is contained in:
parent
a82d03c7b2
commit
933ac7f9bf
2 changed files with 18 additions and 10 deletions
|
@ -88,21 +88,22 @@ fn main() -> Result<(), std::io::Error> {
|
|||
let display = Display::new(controller, config);
|
||||
let mut display = GraphicDisplay::new(display, &mut black_buffer, &mut red_buffer);
|
||||
|
||||
// Main loop. Displays CPU temperature, uname, and uptime every minute with a red Raspberry Pi
|
||||
// header.
|
||||
loop {
|
||||
display.reset(&mut delay).expect("error resetting display");
|
||||
println!("Reset and initialised");
|
||||
let mut state = ApplicationState::default();
|
||||
let one_minute = Duration::from_secs(60);
|
||||
|
||||
// Main loop. updates the screen after a fixed time interval with the next screen
|
||||
loop {
|
||||
display.reset(&mut delay).expect("error resetting display");
|
||||
display.clear(Color::White);
|
||||
println!("Clear");
|
||||
|
||||
inky_ticker::populate(&mut display);
|
||||
inky_ticker::populate(&mut display, &mut state);
|
||||
|
||||
display.update(&mut delay).expect("error updating display");
|
||||
println!("Update...");
|
||||
|
||||
// select next screen already
|
||||
state.advance_screen();
|
||||
|
||||
println!("Finished - going to sleep");
|
||||
display.deep_sleep()?;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use embedded_graphics::prelude::*;
|
||||
use embedded_graphics_simulator::{OutputSettings, SimulatorDisplay, Window};
|
||||
use embedded_graphics_simulator::{OutputSettings, SimulatorDisplay, SimulatorEvent, Window};
|
||||
use ssd1675::Color;
|
||||
use inky_ticker::ApplicationState;
|
||||
|
||||
|
@ -13,9 +13,10 @@ fn main() -> Result<(), core::convert::Infallible> {
|
|||
let mut state = ApplicationState::default();
|
||||
|
||||
// switch between states every few minutes
|
||||
let minute = std::time::Duration::from_secs(60);
|
||||
let minute = std::time::Duration::from_secs(20);
|
||||
println!("Screen will alter every {} seconds", minute.as_secs());
|
||||
|
||||
loop {
|
||||
'running: loop {
|
||||
display.clear(Color::White).expect("failed to clear screen");
|
||||
|
||||
println!("Populating screen");
|
||||
|
@ -29,6 +30,12 @@ fn main() -> Result<(), core::convert::Infallible> {
|
|||
println!("Going to sleep");
|
||||
|
||||
state.advance_screen();
|
||||
|
||||
if window.events().any(|e| e == SimulatorEvent::Quit) {
|
||||
break 'running;
|
||||
}
|
||||
std::thread::sleep(minute);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue