Skip to content

Commit e057880

Browse files
committed
running version
1 parent b6fd7da commit e057880

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/main.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
extern crate alloc;
55
use alloc::boxed::Box;
6-
use embedded_hal_bus::spi::NoDelay; // no longer used in our type alias
6+
77
use core::fmt::Write;
88
use embedded_hal::delay::DelayNs;
99
use embedded_graphics::{
@@ -26,20 +26,21 @@ use esp_hal::{
2626
use embedded_hal_bus::spi::ExclusiveDevice;
2727
use esp_println::{logger::init_logger_from_env, println};
2828
use log::info;
29-
use mipidsi::interface::SpiInterface;
30-
use mipidsi::{models::ILI9486Rgb565, Builder};
29+
use mipidsi::{interface::SpiInterface, options::ColorInversion};
30+
31+
use mipidsi::{models::ST7789, Builder};
3132
// Bevy ECS (no_std) imports:
3233
use bevy_ecs::prelude::*;
3334

3435
// --- Type Alias for the Concrete Display ---
35-
// Now we specify that the SPI interface uses Delay (not NoDelay).
36+
// Now we specify that the SPI interface uses Delay.
3637
type MyDisplay = mipidsi::Display<
3738
SpiInterface<
3839
'static,
3940
ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, Delay>,
4041
Output<'static>
4142
>,
42-
ILI9486Rgb565,
43+
ST7789,
4344
Output<'static>
4445
>;
4546

@@ -102,6 +103,7 @@ fn draw_grid<D: DrawTarget<Color = Rgb565>>(
102103
grid: &[[bool; WIDTH]; HEIGHT],
103104
) -> Result<(), D::Error> {
104105
let border_color = Rgb565::new(230, 230, 230);
106+
105107
for (y, row) in grid.iter().enumerate() {
106108
for (x, &cell) in row.iter().enumerate() {
107109
if cell {
@@ -216,23 +218,27 @@ fn main() -> ! {
216218
let mut display_delay = Delay::new();
217219
display_delay.delay_ns(500_000u32);
218220

219-
// Reset pin: GPIO21.
221+
// Reset pin: GPIO21. Per BSP, reset is active low.
220222
let reset = Output::new(
221223
peripherals.GPIO21,
222-
Level::High,
223-
OutputConfig::default().with_drive_mode(DriveMode::OpenDrain),
224+
Level::Low, // match BSP: lcd_reset_pin! creates with Level::Low.
225+
OutputConfig::default(),
224226
);
225227
// Initialize the display using mipidsi's builder.
226-
let display: MyDisplay = Builder::new(ILI9486Rgb565, di)
228+
let mut display: MyDisplay = Builder::new(ST7789, di)
227229
.reset_pin(reset)
230+
.display_size(172, 320)
231+
.invert_colors(ColorInversion::Inverted)
228232
.init(&mut display_delay)
229233
.unwrap();
230234

231-
// Backlight on GPIO22.
232-
let mut backlight = Output::new(peripherals.GPIO22, Level::High, OutputConfig::default());
235+
display.clear(Rgb565::BLUE).unwrap();
236+
237+
// Backlight on GPIO22: create pin with initial low then set high.
238+
let mut backlight = Output::new(peripherals.GPIO22, Level::Low, OutputConfig::default());
233239
backlight.set_high();
234240

235-
info!("Hello Conway with Bevy ECS!");
241+
info!("Display initialized");
236242

237243
// --- Initialize Game Resources ---
238244
let mut game = GameOfLifeResource::default();

0 commit comments

Comments
 (0)