Browse Source

Migrated to esp-hal 1.0.0 (#5)

* migration to esp-hal 1.0.0

* migrating led highfader to esp-hal 1.0.0

* migrated blinky-embassy to esp-hal 1.0.0

* migrated active-buzzer esp-hal 1.0.0

* buzzer song migrated to esp-hal 1.0.0

* migrated ultrasonic to esp-hal 1.0.0

* migrated pir sensor to esp-hal 1.0.0

* migrated servo to esp-hal 1.0.0

* ldr migrated to esp-hal 1.0.0

* wifi sta migrated to esp-hal 1.0.0

* async access website migrated to esp-hal 1.0.0

* migrated wifi web server to esp-hal 1.0.0

* wifi web server migrated to esp-hal 1.0.0

* migrated wifi control led to esp-hal 1.0.0

* migrated wifi-ap to esp-hal 1.0.0

* oled migrated to esp-hal 1.0.0

* thermistor to esp-hal 1.0.0

* sdcard migrated to esp-hal 1.0.0

* simplified setting time

* rfid migrated to esp-hal 1.0.0

* joystick migrated to esp-hal 1.0.0

* migrated ble to esp-hal 1.0.0

* lcd migrated to esp-hal 1.0.0

* e-ink migrated to esp-hal 1.0.0

* migrated tft display to esp-hal 1.0.0

* ratatui migrated to esp-hal 1.0.0
main
impl Ferris 11 months ago
committed by GitHub
parent
commit
d9601c3181
9 changed files with 637 additions and 508 deletions
  1. +5
    -1
      .gitignore
  2. +559
    -384
      Cargo.lock
  3. +23
    -23
      Cargo.toml
  4. +10
    -6
      build.rs
  5. +0
    -33
      diagram.json
  6. +1
    -1
      rust-toolchain.toml
  7. +39
    -24
      src/bin/main.rs
  8. +0
    -31
      tests/hello_test.rs
  9. +0
    -5
      wokwi.toml

+ 5
- 1
.gitignore View File

@ -1,8 +1,12 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Editor configuration
.vscode/
.zed/
.helix/
.nvim.lua
# These are backup files generated by rustfmt
**/*.rs.bk

+ 559
- 384
Cargo.lock
File diff suppressed because it is too large
View File


+ 23
- 23
Cargo.toml View File

@ -1,28 +1,28 @@
[package]
edition = "2021"
name = "e-ink-hello"
version = "0.1.0"
edition = "2024"
name = "e-ink-hello"
rust-version = "1.88"
version = "0.1.0"
[[bin]]
name = "e-ink-hello"
path = "./src/bin/main.rs"
[dependencies]
esp-hal = { version = "1.0.0", features = ["defmt", "esp32", "unstable"] }
esp-rtos = { version = "0.2.0", features = ["defmt", "embassy", "esp32"] }
defmt = "1.0.1"
esp-bootloader-esp-idf = { version = "0.4.0", features = ["defmt", "esp32"] }
embassy-executor = { version = "0.9.1", features = ["defmt"] }
embassy-time = { version = "0.5.0", features = ["defmt"] }
esp-println = { version = "0.16.1", features = ["defmt-espflash", "esp32"] }
critical-section = "1.2.0"
defmt = "0.3.10"
embassy-executor = { version = "0.7.0", features = [
"defmt",
"task-arena-size-20480",
] }
embassy-time = "0.4.0"
esp-hal = { version = "1.0.0-beta.0", features = [
"defmt",
"esp32",
"unstable",
] }
esp-hal-embassy = { version = "0.7.0", features = ["esp32"] }
esp-println = { version = "0.13.0", features = ["defmt-espflash", "esp32"] }
static_cell = { version = "2.1.0", features = ["nightly"] }
static_cell = "2.1.1"
epd-waveshare = { features = [
"graphics",
], git = "https://github.com/ImplFerris/epd-waveshare", branch = "1in54_v2_fix" }
@ -36,10 +36,10 @@ embedded-graphics = "0.8.1"
opt-level = "s"
[profile.release]
codegen-units = 1 # LLVM can perform better optimizations using a single thread
debug = 2
codegen-units = 1 # LLVM can perform better optimizations using a single thread
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 's'
overflow-checks = false
incremental = false
lto = 'fat'
opt-level = 's'
overflow-checks = false

+ 10
- 6
build.rs View File

@ -15,7 +15,9 @@ fn linker_be_nice() {
"undefined-symbol" => match what.as_str() {
"_defmt_timestamp" => {
eprintln!();
eprintln!("💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`");
eprintln!(
"💡 `defmt` not found - make sure `defmt.x` is added as a linker script and you have included `use defmt_rtt as _;`"
);
eprintln!();
}
"_stack_start" => {
@ -23,16 +25,18 @@ fn linker_be_nice() {
eprintln!("💡 Is the linker script `linkall.x` missing?");
eprintln!();
}
"esp_wifi_preempt_enable"
| "esp_wifi_preempt_yield_task"
| "esp_wifi_preempt_task_create" => {
"esp_rtos_initialized" | "esp_rtos_yield_task" | "esp_rtos_task_create" => {
eprintln!();
eprintln!("💡 `esp-wifi` has no scheduler enabled. Make sure you have the `builtin-scheduler` feature enabled, or that you provide an external scheduler.");
eprintln!(
"💡 `esp-radio` has no scheduler enabled. Make sure you have initialized `esp-rtos` or provided an external scheduler."
);
eprintln!();
}
"embedded_test_linker_file_not_added_to_rustflags" => {
eprintln!();
eprintln!("💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests");
eprintln!(
"💡 `embedded-test` not found - make sure `embedded-test.x` is added as a linker script for tests"
);
eprintln!();
}
_ => (),

+ 0
- 33
diagram.json View File

@ -1,33 +0,0 @@
{
"version": 1,
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-devkit-c-v4",
"id": "esp",
"top": 0.59,
"left": 0.67,
"attrs": {
"flashSize": "16"
}
}
],
"connections": [
[
"esp:TX",
"$serialMonitor:RX",
"",
[]
],
[
"esp:RX",
"$serialMonitor:TX",
"",
[]
]
],
"serialMonitor": {
"display": "terminal",
"convertEol": true
}
}

+ 1
- 1
rust-toolchain.toml View File

@ -1,2 +1,2 @@
[toolchain]
channel = "book-1.0.0-beta"
channel = "book-1.0.0"

+ 39
- 24
src/bin/main.rs View File

@ -1,59 +1,74 @@
#![no_std]
#![no_main]
#![deny(
clippy::mem_forget,
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
holding buffers for the duration of a data transfer."
)]
use defmt::info;
use embassy_executor::Spawner;
use embassy_time::{Delay, Duration, Timer};
use embedded_graphics::mono_font::ascii::FONT_10X20;
use embedded_graphics::prelude::*;
use epd_waveshare::prelude::WaveshareDisplay;
use embedded_hal_bus::spi::ExclusiveDevice;
use esp_hal::clock::CpuClock;
use esp_hal::gpio::{Input, InputConfig, Level, Output, OutputConfig, Pull};
use esp_hal::timer::timg::TimerGroup;
use esp_println as _;
use embedded_graphics::mono_font::MonoTextStyleBuilder;
use embedded_graphics::text::{Baseline, Text};
use embedded_hal_bus::spi::ExclusiveDevice;
// SPI
use esp_hal::spi;
use esp_hal::spi::master::Spi;
use esp_hal::time::Rate;
// epd
use epd_waveshare::color::Color;
use epd_waveshare::epd1in54_v2::{Display1in54, Epd1in54};
use esp_hal::gpio::{Input, InputConfig, Level, Output, OutputConfig, Pull};
use esp_hal::spi::master::{Config as SpiConfig, Spi};
use esp_hal::spi::Mode as SpiMode;
use esp_hal::time::Rate;
use epd_waveshare::prelude::WaveshareDisplay;
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
esp_println::println!("Panic occurred: {:?}", info);
// embedded graphics
use embedded_graphics::mono_font::MonoTextStyleBuilder;
use embedded_graphics::mono_font::ascii::FONT_10X20;
use embedded_graphics::prelude::*;
use embedded_graphics::text::{Baseline, Text};
#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
loop {}
}
#[esp_hal_embassy::main]
async fn main(_spawner: Spawner) {
// generator version: 0.3.1
// This creates a default app-descriptor required by the esp-idf bootloader.
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();
#[esp_rtos::main]
async fn main(spawner: Spawner) -> ! {
// generator version: 1.0.0
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);
let timer0 = TimerGroup::new(peripherals.TIMG1);
esp_hal_embassy::init(timer0.timer0);
let timg0 = TimerGroup::new(peripherals.TIMG0);
esp_rtos::start(timg0.timer0);
info!("Embassy initialized!");
// Initialize SPI
let spi = Spi::new(
// TODO: Spawn some tasks
let _ = spawner;
let spi_bus = Spi::new(
peripherals.SPI2,
SpiConfig::default()
spi::master::Config::default()
.with_frequency(Rate::from_mhz(4))
.with_mode(SpiMode::_0),
.with_mode(spi::Mode::_0),
)
.unwrap()
//CLK
.with_sck(peripherals.GPIO18)
//DIN
.with_mosi(peripherals.GPIO23);
let cs = Output::new(peripherals.GPIO33, Level::Low, OutputConfig::default());
let mut spi_dev = ExclusiveDevice::new(spi, cs, Delay);
let mut spi_dev = ExclusiveDevice::new(spi_bus, cs, Delay);
// Initialize Display
let busy_in = Input::new(
@ -81,7 +96,7 @@ async fn main(_spawner: Spawner) {
loop {
info!("Hello world!");
Timer::after(Duration::from_secs(60)).await;
Timer::after(Duration::from_secs(1)).await;
}
}

+ 0
- 31
tests/hello_test.rs View File

@ -1,31 +0,0 @@
//! Demo test suite using embedded-test
//!
//! You can run this using `cargo test` as usual.
#![no_std]
#![no_main]
#[cfg(test)]
#[embedded_test::tests(executor = esp_hal_embassy::Executor::new())]
mod tests {
use defmt::assert_eq;
use esp_hal::timer::timg::TimerGroup;
#[init]
fn init() {
let peripherals = esp_hal::init(esp_hal::Config::default());
let timer0 = TimerGroup::new(peripherals.TIMG1);
esp_hal_embassy::init(timer0.timer0);
rtt_target::rtt_init_defmt!();
}
#[test]
async fn hello_test() {
defmt::info!("Running test!");
embassy_time::Timer::after(embassy_time::Duration::from_millis(100)).await;
assert_eq!(1 + 1, 2);
}
}

+ 0
- 5
wokwi.toml View File

@ -1,5 +0,0 @@
[wokwi]
version = 1
gdbServerPort = 3333
elf = "target/xtensa-esp32-none-elf/debug/e-ink-hello"
firmware = "target/xtensa-esp32-none-elf/debug/e-ink-hello"

Loading…
Cancel
Save