From 35f12a4c451cad464add5d49edfafcc5f2f3714c Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 27 Oct 2025 16:08:18 +0100 Subject: [PATCH] pass current day to IDStore constructor --- src/main.rs | 5 +++-- src/store/id_store.rs | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index ddaf721..d932310 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,8 @@ use embassy_sync::{ signal::Signal, }; use embassy_time::{Duration, Timer}; +use esp_hal::gpio::InputConfig; use esp_hal::gpio::{AnyPin, Input}; -use esp_hal::{gpio::InputConfig, peripherals}; use log::{debug, info}; use static_cell::StaticCell; @@ -53,7 +53,8 @@ async fn main(spawner: Spawner) -> ! { let mut rtc = drivers::rtc::RTCClock::new(app_hardware.i2c).await; - let store: UsedStore = IDStore::new_from_storage(app_hardware.sdcard).await; + let current_day: Day = rtc.get_time().await.into(); + let store: UsedStore = IDStore::new_from_storage(app_hardware.sdcard, current_day).await; let shared_store = Rc::new(Mutex::new(store)); let chan: &'static mut TallyChannel = CHAN.init(PubSubChannel::new()); diff --git a/src/store/id_store.rs b/src/store/id_store.rs index 15a0bed..119f6c6 100644 --- a/src/store/id_store.rs +++ b/src/store/id_store.rs @@ -40,14 +40,12 @@ pub struct IDStore { } impl IDStore { - pub async fn new_from_storage(mut persistence_layer: T) -> Self { + pub async fn new_from_storage(mut persistence_layer: T, current_date: Day) -> Self { let mapping = match persistence_layer.load_mapping().await { Some(map) => map, None => IDMapping::new(), }; - let current_date: Day = Day::new(1); - let day = persistence_layer .load_day(current_date) .await