Get simulator to work, adjust Pi version

This commit is contained in:
Felix Suchert 2023-05-29 15:02:00 +02:00
parent a82d03c7b2
commit 933ac7f9bf
Signed by: feliix42
GPG key ID: 24363525EA0E8A99
2 changed files with 18 additions and 10 deletions

View file

@ -88,21 +88,22 @@ fn main() -> Result<(), std::io::Error> {
let display = Display::new(controller, config); let display = Display::new(controller, config);
let mut display = GraphicDisplay::new(display, &mut black_buffer, &mut red_buffer); 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 let mut state = ApplicationState::default();
// header.
loop {
display.reset(&mut delay).expect("error resetting display");
println!("Reset and initialised");
let one_minute = Duration::from_secs(60); 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); 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"); display.update(&mut delay).expect("error updating display");
println!("Update..."); println!("Update...");
// select next screen already
state.advance_screen();
println!("Finished - going to sleep"); println!("Finished - going to sleep");
display.deep_sleep()?; display.deep_sleep()?;

View file

@ -1,5 +1,5 @@
use embedded_graphics::prelude::*; use embedded_graphics::prelude::*;
use embedded_graphics_simulator::{OutputSettings, SimulatorDisplay, Window}; use embedded_graphics_simulator::{OutputSettings, SimulatorDisplay, SimulatorEvent, Window};
use ssd1675::Color; use ssd1675::Color;
use inky_ticker::ApplicationState; use inky_ticker::ApplicationState;
@ -13,9 +13,10 @@ fn main() -> Result<(), core::convert::Infallible> {
let mut state = ApplicationState::default(); let mut state = ApplicationState::default();
// switch between states every few minutes // 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"); display.clear(Color::White).expect("failed to clear screen");
println!("Populating screen"); println!("Populating screen");
@ -29,6 +30,12 @@ fn main() -> Result<(), core::convert::Infallible> {
println!("Going to sleep"); println!("Going to sleep");
state.advance_screen(); state.advance_screen();
if window.events().any(|e| e == SimulatorEvent::Quit) {
break 'running;
}
std::thread::sleep(minute); std::thread::sleep(minute);
} }
Ok(())
} }