From 17d2aa134d1c7ac063316b6836f739976418f9d9 Mon Sep 17 00:00:00 2001 From: Me Here Date: Sun, 31 May 2026 21:16:34 -0500 Subject: [PATCH] pm-kit: diagnostic display pattern + flip_horizontal (fix mirror) Replace clear() with same-path full-screen fill, add a 4-edge red border, four distinct corner markers (TL green / TR yellow / BL cyan / BR magenta) and a TL label, to pin down rotation/mirror/size from one flash. Apply flip_horizontal to match the panel's MADCTL MX bit (CircuitPython uses 0x48). Co-Authored-By: Claude Opus 4.8 (1M context) --- rust/pm-kit/src/main.rs | 46 ++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/rust/pm-kit/src/main.rs b/rust/pm-kit/src/main.rs index 94c2b42..9d4393e 100644 --- a/rust/pm-kit/src/main.rs +++ b/rust/pm-kit/src/main.rs @@ -11,7 +11,7 @@ use embedded_graphics::{ mono_font::{ascii::FONT_10X20, MonoTextStyle}, pixelcolor::Rgb565, prelude::*, - primitives::{PrimitiveStyle, Rectangle}, + primitives::{PrimitiveStyle, PrimitiveStyleBuilder, Rectangle}, text::Text, }; use embedded_hal::delay::DelayNs; @@ -81,20 +81,46 @@ fn main() -> ! { .display_size(WIDTH, HEIGHT) .color_order(ColorOrder::Bgr) .invert_colors(ColorInversion::Inverted) - .orientation(Orientation::new()) + .orientation(Orientation::new().flip_horizontal()) // panel wants MX set (matches CircuitPython MADCTL 0x48) .init(&mut timer) .unwrap(); - // background - display.clear(Rgb565::new(2, 4, 8)).unwrap(); - // a panel + label so we can see SPI + the graphics stack working - Rectangle::new(Point::new(20, 60), Size::new((WIDTH - 40) as u32, 140)) - .into_styled(PrimitiveStyle::with_fill(Rgb565::new(2, 40, 50))) + let w = WIDTH as i32; + let h = HEIGHT as i32; + let m = 36; // marker size + + // Full-screen fill via the SAME draw path as the shapes (clear() left snow last time). + Rectangle::new(Point::zero(), Size::new(WIDTH as u32, HEIGHT as u32)) + .into_styled(PrimitiveStyle::with_fill(Rgb565::new(0, 0, 12))) .draw(&mut display) .unwrap(); - let title = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE); - Text::new("PM-KIT", Point::new(40, 110), title).draw(&mut display).unwrap(); - Text::new("RUST OK", Point::new(40, 150), title).draw(&mut display).unwrap(); + // Red 8px border on all four edges — if any edge is missing, the addressed area != panel. + Rectangle::new(Point::zero(), Size::new(WIDTH as u32, HEIGHT as u32)) + .into_styled( + PrimitiveStyleBuilder::new() + .stroke_color(Rgb565::RED) + .stroke_width(8) + .build(), + ) + .draw(&mut display) + .unwrap(); + // Distinct corner markers so orientation/mirror is unambiguous. + let ms = Size::new(m as u32, m as u32); + for (x, y, c) in [ + (0, 0, Rgb565::GREEN), // top-left + (w - m, 0, Rgb565::YELLOW), // top-right + (0, h - m, Rgb565::CYAN), // bottom-left + (w - m, h - m, Rgb565::MAGENTA), // bottom-right + ] { + Rectangle::new(Point::new(x, y), ms) + .into_styled(PrimitiveStyle::with_fill(c)) + .draw(&mut display) + .unwrap(); + } + // Labels: "TL" near origin, big "PMK" centred. + let label = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE); + Text::new("TL", Point::new(44, 28), label).draw(&mut display).unwrap(); + Text::new("PMK", Point::new(w / 2 - 30, h / 2), label).draw(&mut display).unwrap(); loop { led.set_high().unwrap();