Closed rfuest closed 5 months ago
If you want to try the new offset code yourself, here is how I test the code without having a lot of smaller displays with different offsets:
// Initialize the full screen display
let mut tft = Builder::ili9341_rgb565(tft_di)
.with_orientation(Orientation::default())
.init(&mut delay, Some(interfaces.tft_reset))
.ok()
.unwrap();
let offset = Point::new(10, 40);
let size = Size::new(135, 240);
// Draw a border around the area which would be used
// by a smaller display with the given size/offset
tft.clear(Gray8::new(64).into()).unwrap();
Rectangle::new(offset, size)
.into_styled(
PrimitiveStyleBuilder::new()
.stroke_color(Rgb565::MAGENTA)
.stroke_width(1)
.stroke_alignment(StrokeAlignment::Outside)
.build(),
)
.draw(&mut tft)
.unwrap();
// Reinitialize the display with the smaller size and offset
let (tft_di, _m, reset) = tft.release();
let mut tft = Builder::ili9341_rgb565(tft_di)
.with_display_size(size.width as u16, size.height as u16)
.with_display_offset(offset.x as u16, offset.y as u16)
.init(&mut delay, reset)
.ok()
.unwrap();
// Draw the test image, which should always be displayed inside the magenta border,
// regardless of the orientation setting
let test_image = TestImage::new();
test_image.draw(&mut tft).unwrap();
@rfuest how are we here? Do you still plan to finish this?
I didn't have time to finish this since I crated the PR and I'm not sure when I'll get to fix the remaining issues. But I think that removing the window_offset_handler
is important to support different display sizes and this should be merged.
I didn't have time to finish this since I crated the PR and I'm not sure when I'll get to fix the remaining issues. But I think that removing the
window_offset_handler
is important to support different display sizes and this should be merged.
Agreed, I'll see what I can do here. I'm also pretty short on time lately but I'd love to get this finished so we can consider the Model refactor for the next major release.
I've marked the PR as ready for review. I would still like to get the last two remaining TODO items finished, but I think they are better handled in another PR and there might be some overlap with #81.
This PR adds the
Orientation
andRotation
types, which were originally intended to be added to thedisplay-driver-hal
crate. I don't think that crate will be released any time soon, because there didn't seem to be any interest from other driver authors. But I think the new types are easier to use and we can still extract them into another crate later.There was at least one orientation which didn't work correctly in the previous implementation, which should be fixed now. I don't remember the details, but I think one orientation was mirrored, even without setting the boolean mirrored flag.
I also decided to remove the
window_offset_handler
as a part of these changes, because I had to modify the code anyway. Instead of a handler there are now two settings, one for the display size and one for the offset. The framebuffer size is constant for every controller and is now a newconst
in theModel
trait.The PR is marked as a draft at the moment, because I still need to tweak/test a few things:
SetScrollArea
framebuffer_size - display_size / 2
default_options
? This would require separate struct/traits for models and controller, like I suggested in #53.