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) <noreply@anthropic.com>
This commit is contained in:
Me Here 2026-05-31 21:16:34 -05:00
parent 35726b57ac
commit 17d2aa134d

View file

@ -11,7 +11,7 @@ use embedded_graphics::{
mono_font::{ascii::FONT_10X20, MonoTextStyle}, mono_font::{ascii::FONT_10X20, MonoTextStyle},
pixelcolor::Rgb565, pixelcolor::Rgb565,
prelude::*, prelude::*,
primitives::{PrimitiveStyle, Rectangle}, primitives::{PrimitiveStyle, PrimitiveStyleBuilder, Rectangle},
text::Text, text::Text,
}; };
use embedded_hal::delay::DelayNs; use embedded_hal::delay::DelayNs;
@ -81,20 +81,46 @@ fn main() -> ! {
.display_size(WIDTH, HEIGHT) .display_size(WIDTH, HEIGHT)
.color_order(ColorOrder::Bgr) .color_order(ColorOrder::Bgr)
.invert_colors(ColorInversion::Inverted) .invert_colors(ColorInversion::Inverted)
.orientation(Orientation::new()) .orientation(Orientation::new().flip_horizontal()) // panel wants MX set (matches CircuitPython MADCTL 0x48)
.init(&mut timer) .init(&mut timer)
.unwrap(); .unwrap();
// background let w = WIDTH as i32;
display.clear(Rgb565::new(2, 4, 8)).unwrap(); let h = HEIGHT as i32;
// a panel + label so we can see SPI + the graphics stack working let m = 36; // marker size
Rectangle::new(Point::new(20, 60), Size::new((WIDTH - 40) as u32, 140))
.into_styled(PrimitiveStyle::with_fill(Rgb565::new(2, 40, 50))) // 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) .draw(&mut display)
.unwrap(); .unwrap();
let title = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE); // Red 8px border on all four edges — if any edge is missing, the addressed area != panel.
Text::new("PM-KIT", Point::new(40, 110), title).draw(&mut display).unwrap(); Rectangle::new(Point::zero(), Size::new(WIDTH as u32, HEIGHT as u32))
Text::new("RUST OK", Point::new(40, 150), title).draw(&mut display).unwrap(); .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 { loop {
led.set_high().unwrap(); led.set_high().unwrap();