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:
parent
35726b57ac
commit
17d2aa134d
1 changed files with 36 additions and 10 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue