Skip to content

Commit 470b485

Browse files
committed
add update_nb function
1 parent 7c249c7 commit 470b485

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Added
1010

1111
- **(breaking)** [#71](https://github.com/embedded-graphics/simulator/pull/71) Added support for non-square pixels.
12+
- [#72](https://github.com/embedded-graphics/simulator/pull/72) Added non-blocking `Window::update_nb` function.
1213

1314
### Fixed
1415

src/window/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ impl Window {
7575
}
7676
}
7777

78-
/// Updates the window.
79-
pub fn update<C>(&mut self, display: &SimulatorDisplay<C>)
78+
/// Updates the window and returns
79+
pub fn update_nb<C>(&mut self, display: &SimulatorDisplay<C>)
8080
where
8181
C: PixelColor + Into<Rgb888> + From<Rgb888>,
8282
{
@@ -164,7 +164,14 @@ impl Window {
164164
framebuffer.draw_display(display, Point::zero(), &self.output_settings);
165165
sdl_window.update(framebuffer);
166166
}
167+
}
167168

169+
/// Updates the window and blocks until the next frame
170+
pub fn update<C>(&mut self, display: &SimulatorDisplay<C>)
171+
where
172+
C: PixelColor + Into<Rgb888> + From<Rgb888>,
173+
{
174+
self.update_nb(display);
168175
self.fps_limiter.sleep();
169176
}
170177

0 commit comments

Comments
 (0)