Skip to content

Commit 04aef1d

Browse files
committed
esp32-c3-lcdkit - fix resolution
1 parent 743616f commit 04aef1d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

esp32-c3-lcdkit/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mipidsi = { git = "https://github.com/almindor/mipidsi.git", branch = "master" }
2727
panic-halt = "0.2"
2828
shared-bus = { version = "0.3.0" }
2929
spooky-core = { path = "../spooky-core", default-features = false, features = ["static_maze"]}
30-
spooky-embedded = { path = "../spooky-embedded", default-features = false, features = [ "static_maze" ] }
30+
spooky-embedded = { path = "../spooky-embedded", default-features = false, features = [ "static_maze", "resolution_240x240" ] }
3131
# rotary-encoder-embedded = "0.2.0"
3232
# rotary-encoder-embedded = { path = "../../rotary-encoder-embedded" }
3333
rotary-encoder-embedded = { git = "https://github.com/georgik/rotary-encoder-embedded.git", branch = "feature/poll" }

esp32-c3-lcdkit/src/main.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ use hal::{
3535
IO,
3636
};
3737

38+
use spooky_embedded::{
39+
embedded_display::{LCD_H_RES, LCD_V_RES, LCD_MEMORY_SIZE, LCD_PIXELS},
40+
controllers::{accel::AccelMovementController, composites::accel_composite::AccelCompositeController}
41+
};
42+
3843
mod app;
3944

4045
mod lcdkit_composite_controller;
@@ -129,9 +134,6 @@ fn main() -> ! {
129134
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
130135
// https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c3/esp32-c3-lcdkit/user_guide.html#gpio-allocation
131136

132-
let lcd_h_res = 240;
133-
let lcd_v_res = 240;
134-
135137
let lcd_sclk = io.pins.gpio1;
136138
let lcd_mosi = io.pins.gpio0;
137139
let lcd_miso = io.pins.gpio4;
@@ -168,7 +170,7 @@ fn main() -> ! {
168170

169171
println!("SPI ready");
170172

171-
let di = spi_dma_displayinterface::new_no_cs(lcd_h_res * lcd_v_res * 2, spi, lcd_dc);
173+
let di = spi_dma_displayinterface::new_no_cs(LCD_MEMORY_SIZE, spi, lcd_dc);
172174

173175
// ESP32-S3-BOX display initialization workaround: Wait for the display to power up.
174176
// If delay is 250ms, picture will be fuzzy.
@@ -246,8 +248,8 @@ fn main() -> ! {
246248
use spooky_core::{engine::Engine, spritebuf::SpriteBuf, universe::Universe};
247249
use embedded_graphics_framebuf::FrameBuf;
248250
use embedded_graphics::prelude::RgbColor;
249-
let mut data = [Rgb565::BLACK; 240 * 240];
250-
let fbuf = FrameBuf::new(&mut data, 240, 240);
251+
let mut data = [Rgb565::BLACK; LCD_PIXELS];
252+
let fbuf = FrameBuf::new(&mut data, LCD_H_RES as usize, LCD_V_RES as usize);
251253
let spritebuf = SpriteBuf::new(fbuf);
252254

253255
let engine = Engine::new(spritebuf, Some(seed_buffer));
@@ -315,7 +317,7 @@ fn main() -> ! {
315317

316318
let pixel_iterator = universe.render_frame().get_pixel_iter();
317319
// -1 for some reason is necessary otherwise the display is skewed
318-
let _ = display.set_pixels(0, 0, (lcd_v_res-1) as u16, lcd_h_res as u16, pixel_iterator);
320+
let _ = display.set_pixels(0, 0, LCD_V_RES-1, LCD_H_RES, pixel_iterator);
319321

320322
increment_frame_counter();
321323

0 commit comments

Comments
 (0)