mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2025-11-03 15:24:09 +00:00
pass current day to IDStore constructor
This commit is contained in:
parent
7346fb42bd
commit
35f12a4c45
@ -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());
|
||||
|
||||
@ -40,14 +40,12 @@ pub struct IDStore<T: Persistence> {
|
||||
}
|
||||
|
||||
impl<T: Persistence> IDStore<T> {
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user