cargo: gate motion sim behind feature flag
This commit is contained in:
+4
-1
@@ -8,6 +8,9 @@ version = "0.1.0"
|
||||
name = "renderbug-embassy"
|
||||
path = "./src/bin/main.rs"
|
||||
|
||||
[features]
|
||||
simulation = ["dep:csv-core"]
|
||||
|
||||
[dependencies]
|
||||
figments = { path = "../figments/figments/", features = ["alloc"] }
|
||||
esp-bootloader-esp-idf = { version = "0.2.0", features = ["esp32s3"] }
|
||||
@@ -94,7 +97,7 @@ nalgebra = { version = "0.33.2", default-features = false }
|
||||
esp-storage = { version = "0.7.0", features = ["esp32s3"] }
|
||||
bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "a5148d8ae679e021b78f53fd33afb8bb35d0b62e", features = [ "macros", "async"] }
|
||||
serde_json = {version = "1.0.145", default-features = false, features = ["alloc"] }
|
||||
csv-core = "0.1.12"
|
||||
csv-core = {version = "0.1.12", optional = true }
|
||||
kfilter = "0.4.0"
|
||||
|
||||
[profile.dev]
|
||||
|
||||
+45
-29
@@ -12,38 +12,48 @@ use core::ptr::addr_of_mut;
|
||||
use bleps::ad_structure::{create_advertising_data, AdStructure, BR_EDR_NOT_SUPPORTED, LE_GENERAL_DISCOVERABLE};
|
||||
use bleps::attribute_server::{AttributeServer, NotificationData};
|
||||
use bleps::{gatt, Ble, HciConnector};
|
||||
use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::channel::DynamicReceiver;
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use embassy_time::{Instant, Timer};
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::gpio::Pin;
|
||||
use esp_hal::i2c::master::{Config, I2c};
|
||||
use esp_hal::interrupt::software::SoftwareInterruptControl;
|
||||
use esp_hal::system::{AppCoreGuard, CpuControl, Stack};
|
||||
use esp_hal::timer::AnyTimer;
|
||||
use esp_hal::Async;
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::time::Rate;
|
||||
use esp_hal::timer::systimer::SystemTimer;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_hal::{
|
||||
gpio::Pin,
|
||||
interrupt::software::SoftwareInterruptControl,
|
||||
clock::CpuClock,
|
||||
system::{AppCoreGuard, CpuControl, Stack},
|
||||
timer::{AnyTimer, systimer::SystemTimer, timg::TimerGroup}
|
||||
};
|
||||
|
||||
use esp_hal_embassy::{Executor, InterruptExecutor};
|
||||
use esp_wifi::ble::controller::BleConnector;
|
||||
use figments::surface::BufferedSurfacePool;
|
||||
use log::info;
|
||||
use renderbug_embassy::events::{BusGarage, Measurement, Telemetry};
|
||||
use renderbug_embassy::tasks::simulation::{motion_simulation_task, location_simulation_task};
|
||||
use renderbug_embassy::tasks::ui::{Ui, ui_main};
|
||||
use renderbug_embassy::tasks::gps::gps_task;
|
||||
use renderbug_embassy::tasks::motion::motion_task;
|
||||
use serde_json::json;
|
||||
use static_cell::StaticCell;
|
||||
|
||||
use renderbug_embassy::{
|
||||
tasks::mpu::*,
|
||||
tasks::render::render
|
||||
#[cfg(feature="simulation")]
|
||||
use renderbug_embassy::tasks::simulation::{motion_simulation_task, location_simulation_task};
|
||||
#[cfg(not(feature="simulation"))]
|
||||
use renderbug_embassy::tasks::{gps::gps_task, mpu::mpu_task};
|
||||
#[cfg(not(feature="simulation"))]
|
||||
use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice;
|
||||
#[cfg(not(feature="simulation"))]
|
||||
use esp_hal::{
|
||||
time::Rate,
|
||||
i2c::master::{Config, I2c},
|
||||
Async,
|
||||
};
|
||||
#[cfg(not(feature="simulation"))]
|
||||
use embassy_sync::{
|
||||
mutex::Mutex,
|
||||
blocking_mutex::raw::CriticalSectionRawMutex
|
||||
};
|
||||
|
||||
use renderbug_embassy::tasks::{
|
||||
render::render,
|
||||
motion::motion_task,
|
||||
ui::{Ui, ui_main}
|
||||
};
|
||||
extern crate alloc;
|
||||
|
||||
@@ -51,7 +61,9 @@ extern crate alloc;
|
||||
// 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!();
|
||||
|
||||
#[cfg(not(feature="simulation"))]
|
||||
static I2C_BUS: StaticCell<Mutex<CriticalSectionRawMutex, I2c<'static, Async>>> = StaticCell::new();
|
||||
|
||||
static BUS_GARAGE: StaticCell<BusGarage> = StaticCell::new();
|
||||
static mut CORE2_STACK: Stack<8192> = Stack::new();
|
||||
static CORE_HANDLE: StaticCell<AppCoreGuard> = StaticCell::new();
|
||||
@@ -81,16 +93,20 @@ async fn main(spawner: Spawner) {
|
||||
let hi_spawn = hi_exec.start(esp_hal::interrupt::Priority::Priority1);
|
||||
hi_spawn.must_spawn(render(peripherals.RMT, peripherals.GPIO5.degrade(), surfaces, &garage.display));
|
||||
|
||||
info!("Launching i2c sensor tasks");
|
||||
let i2c = I2c::new(peripherals.I2C1, Config::default().with_frequency(Rate::from_khz(400)).with_timeout(esp_hal::i2c::master::BusTimeout::Maximum)).unwrap().with_scl(peripherals.GPIO4).with_sda(peripherals.GPIO3).into_async();
|
||||
let i2c_bus = I2C_BUS.init(Mutex::new(i2c));
|
||||
#[cfg(not(feature="simulation"))]
|
||||
{
|
||||
info!("Launching i2c sensor tasks");
|
||||
let i2c = I2c::new(peripherals.I2C1, Config::default().with_frequency(Rate::from_khz(400)).with_timeout(esp_hal::i2c::master::BusTimeout::Maximum)).unwrap().with_scl(peripherals.GPIO4).with_sda(peripherals.GPIO3).into_async();
|
||||
let i2c_bus = I2C_BUS.init(Mutex::new(i2c));
|
||||
spawner.must_spawn(mpu_task(garage.motion.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
spawner.must_spawn(gps_task(garage.motion.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
}
|
||||
|
||||
spawner.must_spawn(mpu_task(garage.motion.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
spawner.must_spawn(gps_task(garage.motion.dyn_sender(), I2cDevice::new(i2c_bus)));
|
||||
|
||||
// TODO: Only run the motion sim sources with cfg(simulation)
|
||||
spawner.must_spawn(motion_simulation_task(garage.motion.dyn_sender()));
|
||||
spawner.must_spawn(location_simulation_task(garage.motion.dyn_sender()));
|
||||
#[cfg(feature="simulation")]
|
||||
{
|
||||
spawner.must_spawn(motion_simulation_task(garage.motion.dyn_sender()));
|
||||
spawner.must_spawn(location_simulation_task(garage.motion.dyn_sender()));
|
||||
}
|
||||
|
||||
info!("Launching motion engine");
|
||||
spawner.must_spawn(motion_task(garage.motion.dyn_receiver(), garage.scenes.dyn_sender(), garage.telemetry.dyn_sender()));
|
||||
|
||||
@@ -3,4 +3,5 @@ pub mod render;
|
||||
pub mod motion;
|
||||
pub mod gps;
|
||||
pub mod ui;
|
||||
#[cfg(feature="simulation")]
|
||||
pub mod simulation;
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
use embassy_sync::channel::DynamicSender;
|
||||
use csv_core::{ReadFieldResult, Reader};
|
||||
use embassy_time::{Duration, Timer};
|
||||
use nalgebra::{Vector2, Vector3};
|
||||
use csv_core::{ReadFieldResult, Reader};
|
||||
|
||||
use crate::events::Measurement;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user