Skip to content

Commit

Permalink
messing up with fn main
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotito committed Oct 3, 2023
1 parent eb8af46 commit 7adbaa1
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,54 @@
use fpt::lr35902::LR35902;

fn main() {
let mut lr = LR35902::new();
let lr: Box<LR35902> = Box::from(LR35902::new());

loop {
lr.step();
}
let the_thing = thread::spawn(move || {
let mut loop_cycle: u64 = 0;
loop {
loop_cycle += 1;
println!("---[Loop cycle: {:#04}]---", loop_cycle);
lr.step();
println!();
}
});

the_loop(&lr);
the_thing.join().unwrap();
}

fn the_loop<'a>(lr: &'a LR35902) {
let event_loop: EventLoop<()> = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();

event_loop.run(move |event, _, control_flow| {
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => {
println!("The close button was pressed; stopping");
control_flow.set_exit();
}
Event::MainEventsCleared => {
// Application update code.
// lr35902.step();

// Queue a RedrawRequested event.
//
// You only need to call this if you've determined that you need to redraw, in
// applications which do not always need to. Applications that redraw continuously
// can just render here instead.
window.request_redraw();
}
Event::RedrawRequested(_) => {
// Redraw the application.
//
// It's preferable for applications that do not render continuously to render in
// this event rather than in MainEventsCleared, since rendering in here allows
// the program to gracefully handle redraws requested by the OS.
}
_ => (),
}
});
}

0 comments on commit 7adbaa1

Please sign in to comment.