rework card storage to use nvs
This commit was merged in pull request #60.
This commit is contained in:
@@ -5,7 +5,6 @@ use crate::navigation::navigation::NewState;
|
||||
use crate::navigation::outputs::Outputs;
|
||||
use crate::peripherals::Peripherals;
|
||||
use crate::peripherals::storage::MAGIC_REGION;
|
||||
use crate::peripherals::storage::cardstore::COUNT_REGION;
|
||||
use crate::views::view::View;
|
||||
use alloc::boxed::Box;
|
||||
use core::error;
|
||||
@@ -39,22 +38,6 @@ impl Navigable for FlashInfoView {
|
||||
.clear(Rgb565::BLACK)
|
||||
.map_err(PrimaryDisplayError::from)?;
|
||||
let _style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
let mut magic_bytes: [u8; MAGIC_REGION.size] = [0; MAGIC_REGION.size];
|
||||
peripherals
|
||||
.store
|
||||
.lock()
|
||||
.await
|
||||
.flash_store
|
||||
.read(MAGIC_REGION.offset, &mut magic_bytes)
|
||||
.await?;
|
||||
let mut card_count_bytes: [u8; COUNT_REGION.size] = [0; COUNT_REGION.size];
|
||||
peripherals
|
||||
.store
|
||||
.lock()
|
||||
.await
|
||||
.flash_store
|
||||
.read(COUNT_REGION.offset, &mut card_count_bytes)
|
||||
.await?;
|
||||
|
||||
let style = MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE);
|
||||
let textbox_style = TextBoxStyleBuilder::new()
|
||||
@@ -65,14 +48,18 @@ impl Navigable for FlashInfoView {
|
||||
let display_area = outputs.primary_display.bounding_box();
|
||||
let bounds = Rectangle::new(Point::new(0, 30), display_area.size);
|
||||
|
||||
log::debug!("locking store");
|
||||
let store = peripherals.store.lock().await;
|
||||
|
||||
log::debug!("getting card count");
|
||||
let card_count = store.card_store.load_card_count().await?;
|
||||
|
||||
TextBox::with_textbox_style(
|
||||
&format!(
|
||||
"
|
||||
Flash Init Magic: 0x{:x}\n
|
||||
Card Count: {}\n
|
||||
",
|
||||
u32::from_le_bytes(magic_bytes),
|
||||
u32::from_le_bytes(card_count_bytes)
|
||||
card_count
|
||||
),
|
||||
bounds,
|
||||
style,
|
||||
|
||||
Reference in New Issue
Block a user