rework card storage to use nvs

This commit was merged in pull request #60.
This commit is contained in:
2026-08-31 20:16:42 +02:00
parent b814c61f45
commit 0aa1370a2b
8 changed files with 320 additions and 222 deletions
+19 -13
View File
@@ -17,14 +17,13 @@ use creaturedex::drivers::spi_bus;
use creaturedex::drivers::tertiary_lcd::{
BOX, EMPTY, EXAMPLE, HEART, TertiaryDisplay, TertiaryDisplayPinConfiguration,
};
use creaturedex::navigation::navigation::Mutex;
use creaturedex::navigation::inputs::Inputs;
use creaturedex::navigation::navigation::Mutex;
use creaturedex::navigation::navigation::{self};
use creaturedex::navigation::state::NavigationState;
use creaturedex::navigation::outputs::Outputs;
use creaturedex::navigation::state::NavigationState;
use creaturedex::peripherals::Peripherals;
use creaturedex::peripherals::storage::cardstore::CardStore;
use creaturedex::peripherals::storage::flash_store::FlashStore;
use creaturedex::peripherals::storage::store::Store;
use embassy_executor::Spawner;
use embedded_graphics::pixelcolor::BinaryColor;
@@ -51,6 +50,9 @@ extern crate alloc;
const HEAP_SIZE: usize = 73744;
const NVS_PARTITION_OFFSET: usize = 0x10000;
const NVS_PARTITION_SIZE: usize = 0xfa000;
// This creates a default app-descriptor required by the esp-idf bootloader.
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
esp_bootloader_esp_idf::esp_app_desc!();
@@ -122,18 +124,18 @@ async fn main(spawner: Spawner) {
);
}
let flash_store = Box::leak(Box::new(
FlashStore::new(esp_peripherals.FLASH).expect("Could not initialize Flash Store"),
));
let storage = esp_storage::FlashStorage::new(esp_peripherals.FLASH);
let card_store = CardStore::new(flash_store)
let nvs = Mutex::new(
esp_nvs::Nvs::new(NVS_PARTITION_OFFSET, NVS_PARTITION_SIZE, storage)
.expect("failed to create nvs"),
);
let card_store = CardStore::new(nvs)
.await
.expect("Could not initialize Card Store");
let store = Store {
flash_store,
card_store,
};
let store = Store { card_store };
let rtc = Rtc::new(esp_peripherals.LPWR);
//setup_wifi(peripherals.WIFI, peripherals.FLASH, &spawner).await;
@@ -179,10 +181,14 @@ async fn main(spawner: Spawner) {
let navigation_state = Box::leak(Box::new(Mutex::new(NavigationState::new())));
log::info!("Setup complete, entering main loop");
spawner.spawn(navigation::run(inputs, outputs, peripherals, navigation_state).expect("run task failed"));
spawner.spawn(
background_tasks::nfc_scanner(nfc_driver, outputs, peripherals, navigation_state).expect("nfc scanner task failed"),
navigation::run(inputs, outputs, peripherals, navigation_state).expect("run task failed"),
);
spawner.spawn(
background_tasks::nfc_scanner(nfc_driver, outputs, peripherals, navigation_state)
.expect("nfc scanner task failed"),
);
core::future::pending::<()>().await
}