From 3bbfc74657eb722ccd358b475f682074591fcb18 Mon Sep 17 00:00:00 2001 From: Claas Date: Tue, 27 Jan 2026 00:28:47 +0100 Subject: [PATCH] Fix screen starting on --- .gitmodules | 3 +++ README.md | 1 + crosspoint-reader | 1 + src/eink_display/mod.rs | 46 +++++++++++++++++++++++++++++------------ 4 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 .gitmodules create mode 160000 crosspoint-reader diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0184449 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "crosspoint-reader"] + path = crosspoint-reader + url = https://github.com/crosspoint-reader/crosspoint-reader diff --git a/README.md b/README.md index f052744..fadd07c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ I did not build this from scratch. This is based on the previous and future work - [CrossPoint Reader](https://github.com/daveallie/crosspoint-reader) - [Xteink X4 Sample](https://github.com/CidVonHighwind/xteink-x4-sample) - [Ariel-OS fork x4 example](https://github.com/juicecultus/ariel-os/blob/a2816b156b632b2633801df45d69c8fe9dde500c/examples/x4-launcher/src/ssd1677.rs) + - [Xteink X4 sample rust](https://github.com/HookedBehemoth/TrustyReader/) - Tools - [Xteink Flash Tools](https://xteink.dve.al/) - [ESPConnect](https://thelastoutpostworkshop.github.io/ESPConnect/) diff --git a/crosspoint-reader b/crosspoint-reader new file mode 160000 index 0000000..3ce11f1 --- /dev/null +++ b/crosspoint-reader @@ -0,0 +1 @@ +Subproject commit 3ce11f14ce7bc3ce1f2f040bfb09a9b3d9f87f72 diff --git a/src/eink_display/mod.rs b/src/eink_display/mod.rs index 4fe7285..2defa8e 100644 --- a/src/eink_display/mod.rs +++ b/src/eink_display/mod.rs @@ -130,7 +130,10 @@ impl<'d> EinkDisplay<'d> { // Set up GPIO pins let reset = Output::new(reset, Level::Low, OutputConfig::default()); let data_command = Output::new(data_command, Level::High, OutputConfig::default()); - let busy = Input::new(busy, InputConfig::default()); + let busy = Input::new( + busy, + InputConfig::default().with_pull(esp_hal::gpio::Pull::Down), + ); info!("Size: {}", Self::BUFFER_SIZE); Ok(Self { @@ -138,7 +141,7 @@ impl<'d> EinkDisplay<'d> { reset, data_command, busy, - is_screen_on: true, + is_screen_on: false, is_custom_lut_active: false, }) } @@ -184,6 +187,11 @@ impl<'d> EinkDisplay<'d> { with_timeout(Duration::from_millis(100_000), self.busy.wait_for_low()) .await .map_err(WaitForBusyTimeoutError) + // while self.busy.is_high() { + // info!("Waiting for low. Current: {}", self.busy.level()); + // Timer::after_millis(100).await; + // } + // Ok(()) } async fn set_ram_area( @@ -335,11 +343,14 @@ impl<'d> EinkDisplay<'d> { // Configure Display Update Control 1 self.send_command(Command::DisplayUpdateControl1).await?; // Configure buffer comparison mode - self.send_data(&[match mode { - RefreshMode::Fast => ControlMode::Normal, - RefreshMode::Full | RefreshMode::HalfRefresh => ControlMode::BypassRed, - } as u8]) - .await?; + self.send_data(&[ + match mode { + RefreshMode::Fast => ControlMode::Normal, + RefreshMode::Full | RefreshMode::HalfRefresh => ControlMode::BypassRed, + } as u8, + 0x00, + ]) + .await?; // (From crosspoint/open xteink community sdk) // best guess at display mode bits: @@ -355,30 +366,38 @@ impl<'d> EinkDisplay<'d> { // 0 | 01 | CLOCK_OFF | Disable internal oscillato // Select appropriate display mode based on refresh type - let mut display_mode = 0b0000_0000u8; + // let mut display_mode = 0b0000_0000u8; + let mut display_mode = 0x00; if !self.is_screen_on { + info!("Turning screen on"); // Set CLOCK_ON and ANALOG_ON bits self.is_screen_on = true; - display_mode |= 0b1100_0000 + // display_mode |= 0b1100_0000 + display_mode |= 0xC0; } if turn_screen_off { + info!("Turning screen off"); self.is_screen_on = false; // Set ANALOG_OFF_PHASE and CLOCK_OFF bits - display_mode |= 0b000_00011; + // display_mode |= 0b000_00011; + display_mode |= 0x03; } match mode { RefreshMode::Fast => { display_mode |= if self.is_custom_lut_active { - 0b0000_1100 + // 0b0000_1100 + 0x0C } else { - 0b0001_1100 + // 0b0001_1100 + 0x1C }; } RefreshMode::Full => { - display_mode |= 0b0011_0100; + // display_mode |= 0b0011_0100; + display_mode |= 0x34; } RefreshMode::HalfRefresh => { // Write high temp to the register for a faster refresh @@ -392,6 +411,7 @@ impl<'d> EinkDisplay<'d> { self.send_command(Command::DisplayUpdateControl2).await?; self.send_data(&[display_mode]).await?; + info!("Is busy? {}", self.busy.level()); self.send_command(Command::MasterActivation).await?; // Wait for display to finish updating -- knotmirror 0.0.1