diff --git a/rmk/src/eeprom.rs b/rmk/src/eeprom.rs index 813032e4..c06160a1 100644 --- a/rmk/src/eeprom.rs +++ b/rmk/src/eeprom.rs @@ -73,10 +73,18 @@ pub(crate) struct Eeprom { impl Eeprom { pub(crate) fn new( storage: F, - storage_config: EepromStorageConfig, eeconfig: Option, keymap: &[[[KeyAction; COL]; ROW]; NUM_LAYER], ) -> Option { + let mut storage_config = EepromStorageConfig { + start_addr: (F::ERASE_SIZE * (storage.capacity() / F::ERASE_SIZE - 1)) as u32, + storage_size: F::ERASE_SIZE as u32, + page_size: F::WRITE_SIZE as u32, + }; + // At least write 4 byte(1 record) + if storage_config.page_size < 4 { + storage_config.page_size = 4; + } // Check backend storage config if (!is_power_of_two(storage_config.page_size)) || storage_config.start_addr == 0 diff --git a/rmk/src/keymap.rs b/rmk/src/keymap.rs index c2096fb7..7f779612 100644 --- a/rmk/src/keymap.rs +++ b/rmk/src/keymap.rs @@ -1,6 +1,6 @@ use crate::{ action::KeyAction, - eeprom::{eeconfig::Eeconfig, Eeprom, EepromStorageConfig}, + eeprom::{eeconfig::Eeconfig, Eeprom}, matrix::KeyState, }; use defmt::warn; @@ -70,17 +70,7 @@ impl< // Initialize eeprom, if success, re-load keymap from it let eeprom = match storage { Some(s) => { - // TODO: Refactor Eeprom so that we don't need this anymore - let mut eeprom_storage_config = EepromStorageConfig { - start_addr: (F::ERASE_SIZE * (s.capacity() / F::ERASE_SIZE - 1)) as u32, - storage_size: F::ERASE_SIZE as u32, - page_size: F::WRITE_SIZE as u32, - }; - // At least write 4 byte(1 record) - if eeprom_storage_config.page_size < 4 { - eeprom_storage_config.page_size = 4; - } - let e = Eeprom::new(s, eeprom_storage_config, eeconfig, &mut action_map); + let e = Eeprom::new(s, eeconfig, &mut action_map); // If eeprom is initialized, read keymap from it. match e { Some(e) => {