Skip to content

Commit 743616f

Browse files
authored
DMA optimization and refactoring (#67)
* optimized DMA * refactor code and remove duplicated code in many targets * esp32-devkit-rust - decrease freq for reading IMU, because of interference on clock pin
1 parent bce0bc0 commit 743616f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+569
-1530
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The ghost can find artifact "Walker" which allows him to pass throght the wall f
77
The ghost can use dynamite to clear wall in the vicinity. The ghost can use also Teleport spell to move to random place in the maze.
88
The Teleport spell requires some time to recharge. There are some not friendly spirits running around the maze, when collision occurs the ghost is teleported and loses five coins which are then send randomly back to the maze.
99

10-
![Spooky on ESP32-S3-BOX](assets/screenshot/esp32-spooky-s3-box.jpg)
10+
![Spooky on ESP32-S2-Kaluga](assets/screenshot/esp32-spooky-s2-kaluga.jpg)
1111

1212
### Creating similar custom ESP32 app from a template
1313

62.7 KB
Loading

esp-wrover-kit/Cargo.toml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spooky-wrover-kit"
3-
version = "0.8.0"
3+
version = "0.9.0"
44
authors = ["Juraj Michálek <[email protected]>"]
55
edition = "2021"
66
license = "MIT"
@@ -18,29 +18,12 @@ esp-println = { version = "0.7.0", features = ["esp32"] }
1818
[dependencies]
1919
esp-alloc = "0.3.0"
2020
embedded-graphics = "0.8.0"
21-
embedded-graphics-framebuf = { version = "0.3.0", git = "https://github.com/georgik/embedded-graphics-framebuf.git", branch = "feature/embedded-graphics-0.8" }
2221
embedded-hal = "0.2"
2322
display-interface = "0.4"
2423
display-interface-spi = "0.4"
2524
mipidsi = "0.7.1"
2625
panic-halt = "0.2"
2726
shared-bus = { version = "0.3.0" }
2827
spooky-core = { path = "../spooky-core", default-features = false, features = [ "static_maze" ] }
29-
spooky-embedded = { path = "../spooky-embedded", default-features = false, features = [ "static_maze" ] }
28+
spooky-embedded = { path = "../spooky-embedded", default-features = false, features = [ "esp32", "static_maze", "resolution_320x240" ] }
3029
spi-dma-displayinterface = { path = "../spi-dma-displayinterface", features = [ "esp32" ] }
31-
32-
[features]
33-
default = [ "esp_wrover_kit" ]
34-
35-
system_timer = []
36-
37-
button_controls = []
38-
imu_controls = []
39-
40-
esp32 = []
41-
esp32s2 = ["system_timer"]
42-
esp32s3 = []
43-
esp32c3 = ["system_timer"]
44-
45-
# Enable this feature in case you have an ESP32 Wrover Kit with ILI9341
46-
esp_wrover_kit = [ "esp32" ]

esp-wrover-kit/src/app.rs

Lines changed: 0 additions & 47 deletions
This file was deleted.

esp-wrover-kit/src/main.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#[global_allocator]
77
static ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty();
88

9-
// use display_interface_spi::SPIInterfaceNoCS;
10-
use spi_dma_displayinterface::spi_dma_displayinterface::SPIInterfaceNoCS;
9+
use spi_dma_displayinterface::spi_dma_displayinterface;
1110

1211
use esp_backtrace as _;
1312
use hal::{psram, prelude::*,
@@ -28,9 +27,13 @@ use embedded_graphics::{
2827
};
2928

3029
mod setup;
30+
use setup::{setup_button_keyboard, setup_movement_controller};
3131
mod types;
32-
mod app;
33-
use app::app_loop;
32+
33+
use spooky_embedded::{
34+
app::app_loop,
35+
embedded_display::{LCD_H_RES, LCD_V_RES, LCD_MEMORY_SIZE},
36+
};
3437

3538
use crate::types::ConfiguredPins;
3639

@@ -56,9 +59,6 @@ fn main() -> ! {
5659

5760
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
5861

59-
let lcd_h_res = 240;
60-
let lcd_v_res = 320;
61-
6262
let lcd_sclk = io.pins.gpio19;
6363
let lcd_mosi = io.pins.gpio23;
6464
let lcd_miso = io.pins.gpio25;
@@ -99,10 +99,10 @@ fn main() -> ! {
9999
DmaPriority::Priority0,
100100
));
101101

102-
let di = SPIInterfaceNoCS::new(spi, lcd_dc);
102+
let di = spi_dma_displayinterface::new_no_cs(LCD_MEMORY_SIZE, spi, lcd_dc);
103103

104104
let mut display = match mipidsi::Builder::ili9341_rgb565(di)
105-
.with_display_size(lcd_h_res as u16, lcd_v_res as u16)
105+
.with_display_size(LCD_H_RES, LCD_V_RES)
106106
.with_orientation(mipidsi::Orientation::Landscape(false))
107107
.with_color_order(mipidsi::ColorOrder::Bgr)
108108
.init(&mut delay, Some(lcd_reset)) {
@@ -122,6 +122,10 @@ fn main() -> ! {
122122
let mut seed_buffer = [1u8; 32];
123123
rng.read(&mut seed_buffer).unwrap();
124124

125-
app_loop(&mut display, lcd_h_res, lcd_v_res, configured_pins, seed_buffer);
125+
let button_keyboard = setup_button_keyboard(configured_pins);
126+
127+
let movement_controller = setup_movement_controller(seed_buffer, button_keyboard);
128+
129+
app_loop(&mut display, seed_buffer, movement_controller);
126130
loop {}
127131
}

esp-wrover-kit/src/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::types::ConfiguredPins;
22
use embedded_hal::digital::v2::InputPin;
3-
use spooky_embedded::{ button_keyboard::ButtonKeyboard, embedded_movement_controller::EmbeddedMovementController };
3+
use spooky_embedded::{ button_keyboard::ButtonKeyboard, controllers::embedded::EmbeddedMovementController };
44
use spooky_core;
55

66
pub fn setup_button_keyboard<Up: InputPin, Down: InputPin, Left: InputPin, Right: InputPin, Dyn: InputPin, Tel: InputPin>(

esp32-c3-devkit-rust/.cargo/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ rustflags = [
2525
"--cfg", 'target_has_atomic="ptr"',
2626
]
2727

28+
[env]
29+
# Use clean build after changing ESP_LOGLEVEL
30+
ESP_LOGLEVEL="DEBUG"
31+
2832
[build]
2933
target = "riscv32imac-unknown-none-elf"
3034

esp32-c3-devkit-rust/Cargo.toml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spooky-esp32-c3"
3-
version = "0.8.0"
3+
version = "0.9.0"
44
authors = ["Juraj Michálek <[email protected]>"]
55
edition = "2021"
66
license = "MIT"
@@ -10,35 +10,18 @@ hal = { package = "esp32c3-hal", version = "0.13.0" }
1010
esp-backtrace = { version = "0.9.0", features = [
1111
"esp32c3",
1212
"panic-handler",
13-
"print-rtt",
13+
"print-uart",
1414
] }
15-
esp-println = { version = "0.7.0", default-features = false, features = [ "esp32c3", "rtt" ] }
15+
esp-println = { version = "0.7.0", default-features = false, features = [ "esp32c3", "log" ] }
1616

1717
[dependencies]
1818
esp-alloc = "0.3.0"
1919
embedded-graphics = "0.8.0"
20-
embedded-graphics-framebuf = { version = "0.3.0", git = "https://github.com/georgik/embedded-graphics-framebuf.git", branch = "feature/embedded-graphics-0.8" }
2120
embedded-hal = "0.2"
22-
display-interface = "0.4"
23-
display-interface-spi = "0.4"
2421
icm42670 = { git = "https://github.com/jessebraham/icm42670/" }
2522
mipidsi = "0.7.1"
2623
panic-halt = "0.2"
2724
shared-bus = { version = "0.3.0" }
2825
spooky-core = { path = "../spooky-core", default-features = false, features = ["static_maze"]}
29-
spooky-embedded = { path = "../spooky-embedded", default-features = false, features = [ "static_maze" ] }
26+
spooky-embedded = { path = "../spooky-embedded", default-features = false, features = [ "esp32c3", "static_maze", "resolution_320x240" ] }
3027
spi-dma-displayinterface = { path = "../spi-dma-displayinterface", features = ["esp32c3"] }
31-
32-
[features]
33-
default = [ "esp32c3_ili9341" ]
34-
system_timer = []
35-
36-
button_controls = []
37-
imu_controls = []
38-
39-
esp32 = []
40-
esp32s2 = ["system_timer"]
41-
esp32s3 = []
42-
esp32c3 = ["system_timer"]
43-
44-
esp32c3_ili9341 = [ "esp32c3", "imu_controls" ]

esp32-c3-devkit-rust/src/accel_movement_controller.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

esp32-c3-devkit-rust/src/app.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)