tasks: simulation: refactor the simulation tasks to common types that can simulate any sensor
This commit is contained in:
@@ -123,21 +123,23 @@ async fn main(spawner: Spawner) {
|
||||
|
||||
#[cfg(feature="simulation")]
|
||||
{
|
||||
use core::{cell::RefCell, ops::DerefMut};
|
||||
|
||||
use alloc::rc::Rc;
|
||||
use esp_storage::FlashStorage;
|
||||
let storage = Rc::new(RefCell::new(FlashStorage::new()));
|
||||
use renderbug_embassy::tasks::simulation::{SharedFlash, SimDataTable};
|
||||
let mut storage = SharedFlash::new(FlashStorage::new());
|
||||
let mut buf = [8; 1024];
|
||||
let partitions = esp_bootloader_esp_idf::partitions::read_partition_table(storage.borrow_mut().deref_mut(), &mut buf).unwrap();
|
||||
let partitions = esp_bootloader_esp_idf::partitions::read_partition_table(&mut storage, &mut buf).unwrap();
|
||||
let data_partition = partitions.find_partition(
|
||||
esp_bootloader_esp_idf::partitions::PartitionType::Data(
|
||||
esp_bootloader_esp_idf::partitions::DataPartitionSubType::Undefined
|
||||
)).expect("Unable to read partition table").expect("Could not find data partition!");
|
||||
let data_offset = data_partition.offset() as usize;
|
||||
info!("Loading simulation data starting at {data_offset:#02x}");
|
||||
spawner.must_spawn(renderbug_embassy::tasks::simulation::motion_simulation_task(Rc::clone(&storage), data_offset, garage.motion.dyn_sender()));
|
||||
spawner.must_spawn(renderbug_embassy::tasks::simulation::location_simulation_task(storage, data_offset, garage.motion.dyn_sender()));
|
||||
for sim_data in SimDataTable::open(storage.clone(), data_offset) {
|
||||
info!("Found simulation data for {:?}", sim_data.srcid());
|
||||
if spawner.spawn(renderbug_embassy::tasks::simulation::simulation_task(sim_data, garage.motion.dyn_sender())).is_err() {
|
||||
error!("Unable to spawn simulation task! Increase the task pool size.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info!("Launching motion engine");
|
||||
|
||||
Reference in New Issue
Block a user