From 3f9f71f185fda1d4d096e2cb4b98c9a382abfd8e Mon Sep 17 00:00:00 2001 From: Brendan Ball Date: Thu, 19 Oct 2023 07:19:20 +0200 Subject: [PATCH 1/2] use embedded_hal 1.0 and epd-waveshare master --- Cargo.lock | 196 ++++++++++++++++++--------- Cargo.toml | 3 +- esp32c3_nostd/Cargo.toml | 9 +- esp32c3_nostd/examples/epd_simple.rs | 54 +++----- 4 files changed, 157 insertions(+), 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 839f66e..9019747 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,15 +46,15 @@ checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cfg-if" @@ -89,7 +89,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.35", + "syn 2.0.38", ] [[package]] @@ -100,7 +100,16 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.35", + "syn 2.0.38", +] + +[[package]] +name = "embedded-can" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d2e857f87ac832df68fa498d18ddc679175cf3d2e4aa893988e5601baf9438" +dependencies = [ + "nb 1.1.0", ] [[package]] @@ -120,9 +129,22 @@ checksum = "750082c65094fbcc4baf9ba31583ce9a8bb7f52cadfb96f6164b1bc7f922f32b" dependencies = [ "az", "byteorder", - "embedded-graphics-core", - "float-cmp", - "micromath", + "embedded-graphics-core 0.3.3", + "float-cmp 0.8.0", + "micromath 1.1.1", +] + +[[package]] +name = "embedded-graphics" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0" +dependencies = [ + "az", + "byteorder", + "embedded-graphics-core 0.4.0", + "float-cmp 0.9.0", + "micromath 2.0.0", ] [[package]] @@ -135,6 +157,16 @@ dependencies = [ "byteorder", ] +[[package]] +name = "embedded-graphics-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044" +dependencies = [ + "az", + "byteorder", +] + [[package]] name = "embedded-hal" version = "0.2.7" @@ -145,6 +177,22 @@ dependencies = [ "void", ] +[[package]] +name = "embedded-hal" +version = "1.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2894bc2f0457b8ca3d6b8ab8aad64d9337583672494013457f86c5a9146c0e22" + +[[package]] +name = "embedded-hal-nb" +version = "1.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257e3bb0163c69195acb0ebe0083b017b963235861d5ea9741626abdc55f39c9" +dependencies = [ + "embedded-hal 1.0.0-rc.1", + "nb 1.1.0", +] + [[package]] name = "embedded-io" version = "0.5.0" @@ -154,12 +202,10 @@ checksum = "658bbadc628dc286b9ae02f0cb0f5411c056eb7487b72f0083203f115de94060" [[package]] name = "epd-waveshare" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5502a0ed11effff2f47b69b83cf8d4325de86362b5ca37925fa1bf240522bbc" dependencies = [ "bit_field", - "embedded-graphics-core", - "embedded-hal", + "embedded-graphics-core 0.4.0", + "embedded-hal 1.0.0-rc.1", ] [[package]] @@ -180,16 +226,18 @@ dependencies = [ [[package]] name = "esp-hal-common" version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b785e4195e1e1e6fae5b8c7fc44a1a71efa94e0b69527a38cce64815bfe7a6" +source = "git+https://github.com/esp-rs/esp-hal.git?rev=33bfe80d958911f4d0b43adb89cca34b5dce1676#33bfe80d958911f4d0b43adb89cca34b5dce1676" dependencies = [ "basic-toml", "bitfield", "bitflags", "cfg-if", "critical-section", + "embedded-can", "embedded-dma", - "embedded-hal", + "embedded-hal 0.2.7", + "embedded-hal 1.0.0-rc.1", + "embedded-hal-nb", "embedded-io", "esp-hal-procmacros", "esp-riscv-rt", @@ -206,15 +254,15 @@ dependencies = [ [[package]] name = "esp-hal-procmacros" version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4cdf19581f9b0bb2b57b1549a2e639342825344b52f34048ddb29c46efa30de" +source = "git+https://github.com/esp-rs/esp-hal.git?rev=33bfe80d958911f4d0b43adb89cca34b5dce1676#33bfe80d958911f4d0b43adb89cca34b5dce1676" dependencies = [ "darling", + "litrs", "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.38", ] [[package]] @@ -230,8 +278,7 @@ dependencies = [ [[package]] name = "esp-riscv-rt" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7639ac03e9fe4e6d5f1c0e90b95ce9478d487335f6684c22b3515e6dc3155d8f" +source = "git+https://github.com/esp-rs/esp-hal.git?rev=33bfe80d958911f4d0b43adb89cca34b5dce1676#33bfe80d958911f4d0b43adb89cca34b5dce1676" dependencies = [ "riscv", "riscv-rt-macros", @@ -250,8 +297,7 @@ dependencies = [ [[package]] name = "esp32c3-hal" version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98501cfeea3081911074cde8074533b2939e46bd3630b1cd3e89563d58148a00" +source = "git+https://github.com/esp-rs/esp-hal.git?rev=33bfe80d958911f4d0b43adb89cca34b5dce1676#33bfe80d958911f4d0b43adb89cca34b5dce1676" dependencies = [ "cfg-if", "esp-hal-common", @@ -261,10 +307,11 @@ dependencies = [ name = "esp32c3_nostd" version = "0.1.0" dependencies = [ - "embedded-graphics", - "embedded-hal", + "embedded-graphics 0.8.1", + "embedded-hal 1.0.0-rc.1", "epd-waveshare", "esp-backtrace", + "esp-hal-common", "esp-println", "esp32c3-hal", "heapless", @@ -283,6 +330,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -315,9 +371,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "heapless" @@ -346,19 +402,28 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", "hashbrown", ] +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" +dependencies = [ + "proc-macro2", +] + [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -376,7 +441,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6abd59177985bc46fa25bb7b3d6deb0090107d876a5e67a518ef6d69d3429" dependencies = [ - "embedded-hal", + "embedded-hal 0.2.7", ] [[package]] @@ -385,16 +450,16 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "302f5dfbf4c935516a895099b7703e462a56697c55893c4d21b170cca827448e" dependencies = [ - "embedded-graphics", - "embedded-hal", + "embedded-graphics 0.7.1", + "embedded-hal 0.2.7", "num_enum", ] [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "micromath" @@ -402,6 +467,12 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc4010833aea396656c2f91ee704d51a6f1329ec2ab56ffd00bfd56f7481ea94" +[[package]] +name = "micromath" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39617bc909d64b068dcffd0e3e31679195b5576d0c83fadc52690268cc2b2b55" + [[package]] name = "nb" version = "0.1.3" @@ -419,9 +490,9 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -446,12 +517,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - [[package]] name = "paste" version = "1.0.14" @@ -460,11 +525,10 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "once_cell", "toml_edit", ] @@ -494,9 +558,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -518,7 +582,7 @@ checksum = "aa3145d2fae3778b1e31ec2e827b228bdc6abd9b74bb5705ba46dcb82069bc4f" dependencies = [ "bit_field", "critical-section", - "embedded-hal", + "embedded-hal 0.2.7", ] [[package]] @@ -559,7 +623,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac1e1abfa47df52b13ccc801bb4461849c718fee09cd4c8505012e2b565a2c36" dependencies = [ - "embedded-hal", + "embedded-hal 0.2.7", "sensirion-i2c", ] @@ -581,27 +645,27 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37f8a8f52f850f281f9faebd9dc09d68caa29d6ce1dfd3806686b316258768d6" dependencies = [ - "embedded-hal", + "embedded-hal 0.2.7", ] [[package]] name = "serde" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.35", + "syn 2.0.38", ] [[package]] @@ -636,15 +700,15 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn 2.0.35", + "syn 2.0.38", ] [[package]] @@ -660,9 +724,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.35" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59bf04c28bee9043ed9ea1e41afc0552288d3aba9c6efdd78903b802926f4879" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -677,9 +741,9 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap", "toml_datetime", @@ -712,9 +776,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "winnow" -version = "0.5.15" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 00ffd6e..62450db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,7 @@ resolver = "2" [workspace.dependencies] defmt = "=0.3.5" -esp32c3-hal = { version = "0.12.0" } -esp32-hal = { version = "0.15.0" } +esp32c3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "33bfe80d958911f4d0b43adb89cca34b5dce1676" } critical-section = "1.1.1" atomic-polyfill = "1.0.2" log = "0.4.18" diff --git a/esp32c3_nostd/Cargo.toml b/esp32c3_nostd/Cargo.toml index 3f56ecd..c12a32d 100644 --- a/esp32c3_nostd/Cargo.toml +++ b/esp32c3_nostd/Cargo.toml @@ -6,14 +6,15 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -hal = { package = "esp32c3-hal", version = "0.12.0" } +esp32c3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "33bfe80d958911f4d0b43adb89cca34b5dce1676", features = ["eh1"] } +esp-hal-common = { git = "https://github.com/esp-rs/esp-hal.git", rev = "33bfe80d958911f4d0b43adb89cca34b5dce1676", features = ["esp32c3", "eh1"] } esp-backtrace = { version = "0.8.0", features = ["esp32c3", "panic-handler", "exception-handler", "print-uart"] } esp-println = { version = "0.6.0", features = ["esp32c3","log"] } log = { version = "0.4.18" } scd4x = "0.2.1" -epd-waveshare = "0.5.0" -embedded-graphics = "0.7.1" -embedded-hal = "0.2.7" +epd-waveshare = { path = "/home/brendan/dev/projects/epd-waveshare" } +embedded-graphics = "0.8.1" +embedded-hal = "1.0.0-rc.1" max7219 = "0.4.0" max7219-driver = "0.2.2" heapless = "0.7.16" \ No newline at end of file diff --git a/esp32c3_nostd/examples/epd_simple.rs b/esp32c3_nostd/examples/epd_simple.rs index 8e39205..41e0e55 100644 --- a/esp32c3_nostd/examples/epd_simple.rs +++ b/esp32c3_nostd/examples/epd_simple.rs @@ -2,37 +2,34 @@ #![no_main] use esp_backtrace as _; -use esp_println::println; -use hal::{ + +use esp32c3_hal::{ clock::ClockControl, peripherals::Peripherals, - spi::{Spi, SpiMode, FullDuplexMode}, + spi::{ + master::{Spi, SpiBusController}, + SpiMode, + }, gpio::IO, prelude::*, Delay, }; -use embedded_hal::blocking::spi::Write; -use embedded_hal::digital::v2::{OutputPin, InputPin}; use embedded_graphics::{ mono_font::MonoTextStyleBuilder, prelude::*, - primitives::{Circle, Line, PrimitiveStyle}, text::{Baseline, Text, TextStyleBuilder}, }; -use epd_waveshare::{epd2in9bc::*, prelude::*, color::*}; +use epd_waveshare::{epd2in9bc::*, prelude::*, color::Color}; use heapless::String; use core::fmt::{self, Write as FmtWrite}; use log::{info, error}; -enum Error> { - EpdError(>::Error) -} #[entry] fn main() -> ! { let peripherals = Peripherals::take(); - let mut system = peripherals.SYSTEM.split(); - let mut clocks = ClockControl::boot_defaults(system.clock_control).freeze(); + let system = peripherals.SYSTEM.split(); + let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut delay = Delay::new(&clocks); // setup logger @@ -50,33 +47,28 @@ fn main() -> ! { let rst = io.pins.gpio18.into_push_pull_output(); let busy = io.pins.gpio19.into_pull_down_input(); - let mut spi = Spi::new_no_cs_no_miso( + let spi_controller = SpiBusController::from_spi(Spi::new_no_cs_no_miso( peripherals.SPI2, sck, mosi, 100u32.kHz(), SpiMode::Mode0, - &mut system.peripheral_clock_control, - &mut clocks, - ); + &clocks, + )); + let mut spi = spi_controller.add_device(cs); info!("Connecting to display"); // Setup EPD let mut epd = Epd2in9bc::new( &mut spi, - cs, busy, dc, rst, - &mut delay + &mut delay, + None ).expect("failing setting up epd"); - info!("epd is busy: {}", epd.is_busy()); - for i in 0..10 { - info!("epd is busy: {}", epd.is_busy()); - delay.delay_ms(1000u16); - } let mut mono_display = Display2in9bc::default(); @@ -85,6 +77,8 @@ fn main() -> ! { // epd.wake_up(&mut spi, &mut delay).expect("Failed waking up epd"); + epd.wait_until_idle(&mut spi, &mut delay).expect("Failed waiting until idle"); + epd.update_frame(&mut spi, mono_display.buffer(), &mut delay).expect("Failed updating frame"); epd .display_frame(&mut spi, &mut delay).expect("Failed displaying frame"); @@ -111,14 +105,8 @@ fn main() -> ! { info!("waking up display"); epd.wake_up(&mut spi, &mut delay).expect("Failed waking up epd"); - info!("epd is busy: {}", epd.is_busy()); - loop { - if !epd.is_busy() { - break; - } - info!("epd is still busy"); - delay.delay_ms(1000u16); - } + epd.wait_until_idle(&mut spi, &mut delay).expect("Failed waiting until idle"); + info!("updating display frame"); epd.update_frame(&mut spi, mono_display.buffer(), &mut delay).expect("Failed updating frame"); @@ -135,8 +123,8 @@ fn main() -> ! { fn draw_text(display: &mut Display2in9bc, text: &str, x: i32, y: i32) { let style = MonoTextStyleBuilder::new() .font(&embedded_graphics::mono_font::ascii::FONT_6X10) - .text_color(Black) - .background_color(White) + .text_color(Color::Black) + .background_color(Color::White) .build(); let text_style = TextStyleBuilder::new().baseline(Baseline::Top).build(); From b0146ff6786ad9cf1a3cc883ebc5f0adf21fbb80 Mon Sep 17 00:00:00 2001 From: Brendan Ball Date: Sun, 22 Oct 2023 08:39:37 +0200 Subject: [PATCH 2/2] use new correct epd driver --- esp32c3_nostd/examples/epd_simple.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/esp32c3_nostd/examples/epd_simple.rs b/esp32c3_nostd/examples/epd_simple.rs index 41e0e55..a8985af 100644 --- a/esp32c3_nostd/examples/epd_simple.rs +++ b/esp32c3_nostd/examples/epd_simple.rs @@ -19,7 +19,7 @@ use embedded_graphics::{ prelude::*, text::{Baseline, Text, TextStyleBuilder}, }; -use epd_waveshare::{epd2in9bc::*, prelude::*, color::Color}; +use epd_waveshare::{epd2in9b_v3::*, prelude::*, color::Color}; use heapless::String; use core::fmt::{self, Write as FmtWrite}; use log::{info, error}; @@ -60,7 +60,7 @@ fn main() -> ! { info!("Connecting to display"); // Setup EPD - let mut epd = Epd2in9bc::new( + let mut epd = Epd2in9b::new( &mut spi, busy, dc, @@ -70,9 +70,9 @@ fn main() -> ! { ).expect("failing setting up epd"); - let mut mono_display = Display2in9bc::default(); + let mut mono_display = Display2in9b::default(); - mono_display.set_rotation(DisplayRotation::Rotate90); + mono_display.set_rotation(DisplayRotation::Rotate270); draw_text(&mut mono_display, "Hello", 5, 10); // epd.wake_up(&mut spi, &mut delay).expect("Failed waking up epd"); @@ -95,11 +95,11 @@ fn main() -> ! { // fmt::write(&mut counter_text, format_args!("Counter: {}", counter)).expect("Error occurred while trying to write in String"); write!(counter_text, "Counter: {counter}").expect("Error occurred while trying to write in String"); info!("Sleeping"); - delay.delay_ms(15000u16); + delay.delay_ms(30000u16); - let mut mono_display = Display2in9bc::default(); + let mut mono_display = Display2in9b::default(); - mono_display.set_rotation(DisplayRotation::Rotate90); + mono_display.set_rotation(DisplayRotation::Rotate270); draw_text(&mut mono_display, counter_text.as_str(), 5, 10); info!("waking up display"); @@ -120,9 +120,9 @@ fn main() -> ! { } -fn draw_text(display: &mut Display2in9bc, text: &str, x: i32, y: i32) { +fn draw_text(display: &mut Display2in9b, text: &str, x: i32, y: i32) { let style = MonoTextStyleBuilder::new() - .font(&embedded_graphics::mono_font::ascii::FONT_6X10) + .font(&embedded_graphics::mono_font::ascii::FONT_8X13_BOLD) .text_color(Color::Black) .background_color(Color::White) .build();