From c3d516851db8b1632ccb372f949a65badaeea016 Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 11 Jan 2024 10:18:49 +0100 Subject: [PATCH 1/3] Update leh to 0.4 alpha.4 --- Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 69f4b33c..2c2e36b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,8 +27,7 @@ embedded-hal-mock = { version = "=0.10.0-rc.4", default-features = false, featur ] } [target.'cfg(unix)'.dev-dependencies] -# linux-embedded-hal = "0.3" -linux-embedded-hal = { git = "https://github.com/rust-embedded/linux-embedded-hal", rev = "a1fb24103e575615a29c6748cdeff1f0e7a3dae3" } +linux-embedded-hal = "0.4.0-alpha.4" [[example]] name = "epd1in54_no_graphics" From 9f70c167316e2bba2b7c9724156f419b9e193ae2 Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 11 Jan 2024 11:55:20 +0100 Subject: [PATCH 2/3] Update to eh-1.0, eh-mock 0.10 (not released), leh 0.4.0 (not released) --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2c2e36b4..55d682a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,17 +17,17 @@ edition = "2021" [dependencies] embedded-graphics-core = { version = "0.4", optional = true } -embedded-hal = "1.0.0-rc.3" +embedded-hal = "1.0.0" bit_field = "0.10.1" [dev-dependencies] embedded-graphics = "0.8" -embedded-hal-mock = { version = "=0.10.0-rc.4", default-features = false, features = [ +embedded-hal-mock = { version = "=0.10.0", default-features = false, features = [ "eh1", ] } [target.'cfg(unix)'.dev-dependencies] -linux-embedded-hal = "0.4.0-alpha.4" +linux-embedded-hal = "0.4.0" [[example]] name = "epd1in54_no_graphics" From 05ac118f48bec10920f42c148af2781f8517b39e Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 12 Jan 2024 11:06:44 +0100 Subject: [PATCH 3/3] Fix epd2in9d Change delayUs to delayNs and translate part of the chinese docs to english. --- src/epd2in9d/mod.rs | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/epd2in9d/mod.rs b/src/epd2in9d/mod.rs index 87b5e8ad..95d72398 100644 --- a/src/epd2in9d/mod.rs +++ b/src/epd2in9d/mod.rs @@ -8,7 +8,7 @@ use core::slice::from_raw_parts; use embedded_hal::{ - delay::DelayUs, + delay::DelayNs, digital::{InputPin, OutputPin}, spi::SpiDevice, }; @@ -58,7 +58,7 @@ pub struct Epd2in9d<'a, SPI, BUSY, DC, RST, DELAY> { color: Color, /// Refresh LUT refresh: RefreshLut, - // 存放旧数据,以供部分刷新使用 + // Storing old data for partial refreshes old_data: &'a [u8], // 标记是否局刷的状态 is_partial_refresh: bool, @@ -71,7 +71,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { self.interface.reset(delay, 10_000, 2_000); @@ -103,7 +103,7 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { type DisplayColor = Color; fn new( @@ -166,8 +166,8 @@ where HEIGHT } - // 对应的是Display函数 - // 用于将要显示的数据写入屏幕SRAM + // Corresponds to the Display function. + // Used to write the data to be displayed to the screen SRAM. fn update_frame( &mut self, spi: &mut SPI, @@ -175,7 +175,7 @@ where delay: &mut DELAY, ) -> Result<(), SPI::Error> { if self.is_partial_refresh { - // 若进行全刷则修改局刷状态 + // Modify local refresh status if full refresh is performed. self.is_partial_refresh = false; } self.wait_until_idle(spi, delay)?; @@ -202,7 +202,7 @@ where height: u32, ) -> Result<(), SPI::Error> { if !self.is_partial_refresh { - // 仅在初次调用时初始化 + // Initialize only on first call self.set_part_reg(spi, delay)?; self.is_partial_refresh = true; } @@ -289,12 +289,12 @@ where BUSY: InputPin, DC: OutputPin, RST: OutputPin, - DELAY: DelayUs, + DELAY: DelayNs, { - /// 唤醒屏幕 + /// Wake Up Screen /// - /// 在屏幕执行sleep之后,会进入深度睡眠模式。在深度睡眠模式下若需要刷新屏幕,必须先执行awaken() - /// 唤醒屏幕 + /// After the screen sleeps, it enters deep sleep mode. If you need to refresh the screen while in deep sleep mode, you must first execute awaken(). + /// Wake the screen. // fn awaken(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { // // reset the device // self.interface.reset(delay, 20_000, 2_000); @@ -316,43 +316,43 @@ where // } fn set_part_reg(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - // 重置EPD驱动电路 + // Reset the EPD driver circuit //TODO: 这里在微雪的例程中反复刷新了3次,后面有显示问题再进行修改 self.interface.reset(delay, 10_000, 2_000); - // 电源设置 - //TODO: 文档中的数据为[0x03,0x00,0x2b,0x2b,0x09] + // Power settings + //TODO: The data in the document is [0x03,0x00,0x2b,0x2b,0x09]. self.interface.cmd_with_data( spi, Command::PowerSetting, &[0x03, 0x00, 0x2b, 0x2b, 0x03], )?; - // 软启动 + // Soft start self.interface .cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x17])?; - // 面板设置 + // Panel settings self.interface .cmd_with_data(spi, Command::PanelSetting, &[0xbf, 0x0D])?; - // 设置刷新率 + // Setting the refresh rate // 3a 100HZ | 29 150Hz | 39 200HZ | 31 171HZ - // 例程中使用3a + // 3a is used in the example self.interface .cmd_with_data(spi, Command::PllControl, &[0x3C])?; - // 分辨率设置 + // Resolution Settings self.interface .cmd_with_data(spi, Command::ResolutionSetting, &[0x80, 0x01, 0x28])?; - // vcom_DC设置 + // vcom_DC settings self.interface .cmd_with_data(spi, Command::VcmDcSetting, &[0x12])?; self.set_lut(spi, delay, None)?; - // 开启电源 + // Power on // self.interface.cmd_with_data( // spi, // Command::PowerOn, @@ -360,11 +360,11 @@ where // ); self.interface.cmd(spi, Command::PowerOn)?; - // 获取BUSY电平,高电平继续执行,低电平则等待屏幕响应 - //TODO: 这里是文档推荐的步骤,但我看其他屏幕的也没等待就先忽略了 + // Get the BUSY level, high to continue, low to wait for the screen to respond. + //TODO: This is the recommended step in the documentation, but I've ignored it since I've seen other screens that don't wait. self.wait_until_idle(spi, delay)?; - // vcom和数据间隔设置 + // vcom and data interval settings // self.interface // .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x97])?;