-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
} | ||
_ => (), | ||
} | ||
}); | ||
} |