From e15e78cc26e9e1275811e58853e8a71b3a67a420 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Tue, 5 May 2026 22:02:46 +0200 Subject: [PATCH] rename deepsleep to deep_sleep_ms for clarity on expected duration in main deep sleep was larger than required by a factor of 1000, fixed this an renamed function to make expected duration count size obvious from the name --- rust/src/hal/esp.rs | 2 +- rust/src/hal/initial_hal.rs | 4 ++-- rust/src/hal/mod.rs | 2 +- rust/src/hal/v3_hal.rs | 4 ++-- rust/src/hal/v4_hal.rs | 4 ++-- rust/src/main.rs | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rust/src/hal/esp.rs b/rust/src/hal/esp.rs index 996d088..dd188cd 100644 --- a/rust/src/hal/esp.rs +++ b/rust/src/hal/esp.rs @@ -626,7 +626,7 @@ impl Esp<'_> { Ok(*stack) } - pub fn deep_sleep(&mut self, duration_in_ms: u64) -> ! { + pub fn deep_sleep_ms(&mut self, duration_in_ms: u64) -> ! { // Mark the current OTA image as valid if we reached here while in pending verify. if let Ok(cur) = self.ota.current_ota_state() { if cur == OtaImageState::PendingVerify { diff --git a/rust/src/hal/initial_hal.rs b/rust/src/hal/initial_hal.rs index 38d986b..924697c 100644 --- a/rust/src/hal/initial_hal.rs +++ b/rust/src/hal/initial_hal.rs @@ -104,8 +104,8 @@ impl<'a> BoardInteraction<'a> for Initial<'a> { bail!("Please configure board revision") } - async fn deep_sleep(&mut self, duration_in_ms: u64) -> ! { - self.esp.deep_sleep(duration_in_ms); + async fn deep_sleep_ms(&mut self, duration_in_ms: u64) -> ! { + self.esp.deep_sleep_ms(duration_in_ms); } fn is_day(&self) -> bool { false diff --git a/rust/src/hal/mod.rs b/rust/src/hal/mod.rs index 83e0f07..9a03799 100644 --- a/rust/src/hal/mod.rs +++ b/rust/src/hal/mod.rs @@ -215,7 +215,7 @@ pub trait BoardInteraction<'a> { async fn get_time(&mut self) -> DateTime; async fn set_time(&mut self, time: &DateTime) -> FatResult<()>; async fn set_charge_indicator(&mut self, charging: bool) -> Result<(), FatError>; - async fn deep_sleep(&mut self, duration_in_ms: u64) -> !; + async fn deep_sleep_ms(&mut self, duration_in_ms: u64) -> !; fn is_day(&self) -> bool; //should be multsampled diff --git a/rust/src/hal/v3_hal.rs b/rust/src/hal/v3_hal.rs index f9c0437..54d0a51 100644 --- a/rust/src/hal/v3_hal.rs +++ b/rust/src/hal/v3_hal.rs @@ -217,9 +217,9 @@ impl<'a> BoardInteraction<'a> for V3<'a> { Ok(()) } - async fn deep_sleep(&mut self, duration_in_ms: u64) -> ! { + async fn deep_sleep_ms(&mut self, duration_in_ms: u64) -> ! { let _ = self.shift_register.lock().await.decompose()[AWAKE].set_low(); - self.esp.deep_sleep(duration_in_ms) + self.esp.deep_sleep_ms(duration_in_ms) } fn is_day(&self) -> bool { diff --git a/rust/src/hal/v4_hal.rs b/rust/src/hal/v4_hal.rs index 0a85231..a0af30e 100644 --- a/rust/src/hal/v4_hal.rs +++ b/rust/src/hal/v4_hal.rs @@ -341,10 +341,10 @@ impl<'a> BoardInteraction<'a> for V4<'a> { self.charger.set_charge_indicator(charging) } - async fn deep_sleep(&mut self, duration_in_ms: u64) -> ! { + async fn deep_sleep_ms(&mut self, duration_in_ms: u64) -> ! { self.awake.set_low(); self.charger.power_save(); - self.esp.deep_sleep(duration_in_ms); + self.esp.deep_sleep_ms(duration_in_ms); } fn is_day(&self) -> bool { diff --git a/rust/src/main.rs b/rust/src/main.rs index 78bf202..daf76d7 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -596,7 +596,7 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> { board.board_hal.get_esp().set_restart_to_conf(false); board .board_hal - .deep_sleep(1000 * 1000 * 60 * deep_sleep_duration_minutes as u64) + .deep_sleep_ms(1000 * 60 * deep_sleep_duration_minutes as u64) .await; } } @@ -991,7 +991,7 @@ async fn wait_infinity( board.board_hal.get_esp().set_restart_to_conf(false); // ensure clean http answer / visible confirmation Timer::after_millis(500).await; - board.board_hal.deep_sleep(0).await; + board.board_hal.deep_sleep_ms(0).await; // not sleeping smells like a hidden reset, we should call it that! } // Short tick while holding so the pattern updates smoothly. @@ -1100,7 +1100,7 @@ async fn wait_infinity( .lock() .await .board_hal - .deep_sleep(0) + .deep_sleep_ms(0) // not sleeping smells like a hidden reset, we should call it that! .await; } }