Not working upload but atleast no crash
This commit is contained in:
16
.cargo/config.toml
Normal file
16
.cargo/config.toml
Normal file
@@ -0,0 +1,16 @@
|
||||
[build]
|
||||
target = "xtensa-esp32-espidf"
|
||||
|
||||
[target.xtensa-esp32-espidf]
|
||||
linker = "ldproxy"
|
||||
runner = "espflash flash --monitor"
|
||||
rustflags = [ "--cfg", "espidf_time64"]
|
||||
|
||||
[unstable]
|
||||
build-std = ["std", "panic_abort"]
|
||||
|
||||
[env]
|
||||
MCU="esp32"
|
||||
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
|
||||
ESP_IDF_VERSION = "v5.3.2"
|
||||
|
||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/.vscode
|
||||
/.embuild
|
||||
/target
|
||||
/Cargo.lock
|
||||
51
Cargo.toml
Normal file
51
Cargo.toml
Normal file
@@ -0,0 +1,51 @@
|
||||
[package]
|
||||
name = "esp-epd"
|
||||
version = "0.1.0"
|
||||
authors = ["zenonet <git@zenonet.de>"]
|
||||
edition = "2021"
|
||||
resolver = "2"
|
||||
rust-version = "1.77"
|
||||
|
||||
[[bin]]
|
||||
name = "esp-epd"
|
||||
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
|
||||
[profile.dev]
|
||||
debug = true # Symbols are nice and they don't increase the size on Flash
|
||||
opt-level = "z"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
experimental = ["esp-idf-svc/experimental"]
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
esp-idf-svc = "0.51"
|
||||
esp-idf-hal = "0.45.2"
|
||||
epd-waveshare = "0.6.0"
|
||||
embedded-graphics = "0.8.1"
|
||||
embedded-hal = "1.0.0"
|
||||
|
||||
# --- Optional Embassy Integration ---
|
||||
# esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync"] }
|
||||
|
||||
# If you enable embassy-time-driver, you MUST also add one of:
|
||||
|
||||
# a) Standalone Embassy libs ( embassy-time, embassy-sync etc) with a foreign async runtime:
|
||||
# embassy-time = { version = "0.4.0", features = ["generic-queue-8"] } # NOTE: any generic-queue variant will work
|
||||
|
||||
# b) With embassy-executor:
|
||||
# embassy-executor = { version = "0.7", features = ["executor-thread", "arch-std"] }
|
||||
|
||||
# NOTE: if you use embassy-time with embassy-executor you don't need the generic-queue-8 feature
|
||||
|
||||
# --- Temporary workaround for embassy-executor < 0.8 ---
|
||||
# esp-idf-svc = { version = "0.51", features = ["embassy-time-driver", "embassy-sync"] }
|
||||
# critical-section = { version = "1.1", features = ["std"], default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
embuild = "0.33"
|
||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "esp"
|
||||
10
sdkconfig.defaults
Normal file
10
sdkconfig.defaults
Normal file
@@ -0,0 +1,10 @@
|
||||
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000
|
||||
|
||||
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
|
||||
# This allows to use 1 ms granularity for thread sleeps (10 ms by default).
|
||||
#CONFIG_FREERTOS_HZ=1000
|
||||
|
||||
# Workaround for https://github.com/espressif/esp-idf/issues/7631
|
||||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
|
||||
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n
|
||||
107
src/main.rs
Normal file
107
src/main.rs
Normal file
@@ -0,0 +1,107 @@
|
||||
use embedded_graphics::{mono_font::MonoTextStyleBuilder, prelude::Point, Drawable, text::{Baseline, Text, TextStyleBuilder}};
|
||||
use epd_waveshare::{color::Color, epd7in5_v2::Epd7in5, prelude::WaveshareDisplay};
|
||||
use esp_idf_hal::{delay::{Delay, Ets}, gpio::PinDriver, spi::{config, Spi, SpiDriver, SpiDriverConfig}};
|
||||
use esp_idf_svc::hal::{prelude::*, spi::SpiDeviceDriver};
|
||||
use embedded_hal::delay::DelayNs;
|
||||
|
||||
|
||||
//static mut display: epd_waveshare::epd7in5_v2::Display7in5 = epd_waveshare::epd7in5_v2::Display7in5::default();
|
||||
|
||||
static FRAMEBUF: [u8; 48000] = [1; 48000];
|
||||
fn main() {
|
||||
// It is necessary to call this function once. Otherwise some patches to the runtime
|
||||
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
|
||||
esp_idf_svc::sys::link_patches();
|
||||
|
||||
// Bind the log crate to the ESP Logging facilities
|
||||
esp_idf_svc::log::EspLogger::initialize_default();
|
||||
|
||||
log::info!("Hello, world!");
|
||||
log::info!("Just logging something again");
|
||||
|
||||
let peripherals = Peripherals::take().unwrap();
|
||||
|
||||
log::info!("Took peripherals");
|
||||
|
||||
let busy = PinDriver::input(peripherals.pins.gpio4).unwrap();
|
||||
let rst = PinDriver::output(peripherals.pins.gpio16).unwrap();
|
||||
let dc = PinDriver::output(peripherals.pins.gpio17).unwrap();
|
||||
let cs = peripherals.pins.gpio5;
|
||||
let clk = peripherals.pins.gpio18;
|
||||
let mosi = peripherals.pins.gpio23;
|
||||
|
||||
log::info!("Initialized pins");
|
||||
|
||||
|
||||
let config = config::Config::new();
|
||||
|
||||
let mut spi = SpiDeviceDriver::new_single(
|
||||
peripherals.spi3,
|
||||
clk,
|
||||
peripherals.pins.gpio21,
|
||||
Some(mosi),
|
||||
Some(cs),
|
||||
&SpiDriverConfig::default(),
|
||||
&config
|
||||
).unwrap();
|
||||
|
||||
log::info!("Initialized spi interface");
|
||||
|
||||
//static mut display: epd_waveshare::epd7in5_v2::Display7in5 = epd_waveshare::epd7in5_v2::Display7in5::default();
|
||||
|
||||
let mut delay = Ets;
|
||||
|
||||
let mut epd7in5 = Epd7in5::new(&mut spi, busy, dc, rst, &mut delay, None).unwrap();
|
||||
log::info!("Created epd object");
|
||||
|
||||
log::info!("Created display object");
|
||||
|
||||
|
||||
//draw_text(&mut display, "Hello esp", 5, 50);
|
||||
log::info!("Draw text done");
|
||||
|
||||
|
||||
let res = epd7in5.update_and_display_frame(&mut spi, &FRAMEBUF, &mut delay);
|
||||
|
||||
|
||||
if let Err(e) = res{
|
||||
log::info!("{}", e);
|
||||
}
|
||||
|
||||
/* let mut i = 0;
|
||||
loop{
|
||||
let d = &mut delay;
|
||||
d.delay_ms(500);
|
||||
log::info!("Loop {}", i);
|
||||
i += 1;
|
||||
|
||||
if i == 5{
|
||||
//let data = display.buffer();
|
||||
|
||||
/* for d in data{
|
||||
log::info!("{}", d)
|
||||
} */
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
/*
|
||||
// Get SpiDevice trait implementation
|
||||
//let mut spi_device = spi.into_device();
|
||||
|
||||
// let mut epd7in5 = Epd7in5::new(spi, busy, dc, rst, delay, delay_us)
|
||||
*/
|
||||
}
|
||||
|
||||
fn draw_text(display: &mut epd_waveshare::epd7in5_v2::Display7in5, text: &str, x: i32, y: i32) {
|
||||
let style = MonoTextStyleBuilder::new()
|
||||
.font(&embedded_graphics::mono_font::ascii::FONT_6X10)
|
||||
.text_color(Color::White)
|
||||
.background_color(Color::Black)
|
||||
.build();
|
||||
|
||||
let text_style = TextStyleBuilder::new().baseline(Baseline::Top).build();
|
||||
|
||||
// The problem:
|
||||
//let _ = Text::with_text_style(text, Point::new(x, y), style, text_style).draw(display);
|
||||
}
|
||||
Reference in New Issue
Block a user