-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
screen size hardcoded and does not change with orientation #8
Comments
Suggested fix (requires change from #7): diff --git a/src/graphics.rs b/src/graphics.rs
index ad51121..8854d96 100644
--- a/src/graphics.rs
+++ b/src/graphics.rs
@@ -95,21 +95,10 @@ where
}
fn clear(&mut self, color: Self::Color) -> Result<(), Self::Error>
- where
- Self: Sized,
{
- let fb_size = self.model.framebuffer_size();
- let pixel_count = usize::from(fb_size.0) * usize::from(fb_size.1);
- let colors = core::iter::repeat(color).take(pixel_count); // blank entire HW RAM contents
-
- match self.orientation {
- Orientation::Portrait | Orientation::PortraitSwapped => {
- self.set_pixels(0, 0, 319, 479, colors)
- }
- Orientation::Landscape | Orientation::LandscapeSwapped => {
- self.set_pixels(0, 0, 479, 319, colors)
- }
- }
+ let size = self.size();
+ let area = Rectangle::new(Point::new(0, 0), size);
+ self.fill_solid(&area, color)
}
}
@@ -121,6 +110,10 @@ where
{
fn size(&self) -> Size {
let ds = self.model.display_size();
- Size::new(u32::from(ds.0), u32::from(ds.1))
+ let (width, height) = match self.orientation {
+ Orientation::Portrait => (ds.0, ds.1),
+ Orientation::Landscape => (ds.1, ds.0)
+ };
+ Size::new(u32::from(width), u32::from(height))
}
} For the clear call, was wondering the the |
Fixes almindor#7 Fixes almindor#8
The framebuffer size was used for displays that have bigger draw area than display area (e.g. scrollable hidden area). Clear is supposed to clear the whole thing. Wouldn't your version clear just the visible part? |
Have a look at the code I am replacing. It is somewhat confusing actually, it uses Also Lines 57 to 59 in 1b7d8e2
/// Size of the display framebuffer as `(width, height)`
fn framebuffer_size(&self) -> (u16, u16) {
self.display_size()
} I replaced the The benefit of using the |
Also I note this implements the https://docs.rs/embedded-graphics/0.7.1/embedded_graphics/geometry/trait.OriginDimensions.html |
Fixes almindor#7 Fixes almindor#8
Fixes almindor#7 Fixes almindor#8
Fixes almindor#7 Fixes almindor#8
Fixes almindor#7 Fixes almindor#8
Screen size is hard-coded and should vary depending on the orientation settings.
The text was updated successfully, but these errors were encountered: