Renaming interface to avoid confusion
This commit is contained in:
parent
f32949ed17
commit
1a08634dcb
@ -13,7 +13,7 @@ use hardware::{
|
||||
InputPin, AFE0, AFE1,
|
||||
};
|
||||
|
||||
use net::{Action, MqttSettings};
|
||||
use net::{Action, MiniconfInterface};
|
||||
|
||||
const SCALE: f32 = i16::MAX as _;
|
||||
|
||||
@ -46,7 +46,7 @@ const APP: () = {
|
||||
digital_input1: DigitalInput1,
|
||||
adcs: (Adc0Input, Adc1Input),
|
||||
dacs: (Dac0Output, Dac1Output),
|
||||
mqtt_settings: MqttSettings<Settings>,
|
||||
mqtt_config: MiniconfInterface<Settings>,
|
||||
|
||||
// Format: iir_state[ch][cascade-no][coeff]
|
||||
#[init([[[0.; 5]; IIR_CASCADE_LENGTH]; 2])]
|
||||
@ -59,7 +59,7 @@ const APP: () = {
|
||||
// Configure the microcontroller
|
||||
let (mut stabilizer, _pounder) = hardware::setup(c.core, c.device);
|
||||
|
||||
let mqtt_settings = MqttSettings::new(
|
||||
let mqtt_config = MiniconfInterface::new(
|
||||
stabilizer.net.stack,
|
||||
"",
|
||||
"dt/sinara/stabilizer",
|
||||
@ -83,7 +83,7 @@ const APP: () = {
|
||||
afes: stabilizer.afes,
|
||||
adcs: stabilizer.adcs,
|
||||
dacs: stabilizer.dacs,
|
||||
mqtt_settings,
|
||||
mqtt_config,
|
||||
digital_input1: stabilizer.digital_inputs.1,
|
||||
settings: Settings::default(),
|
||||
}
|
||||
@ -140,10 +140,14 @@ const APP: () = {
|
||||
}
|
||||
}
|
||||
|
||||
#[idle(resources=[mqtt_settings], spawn=[settings_update])]
|
||||
#[idle(resources=[mqtt_config], spawn=[settings_update])]
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
loop {
|
||||
match c.resources.mqtt_settings.lock(|settings| settings.update()) {
|
||||
match c
|
||||
.resources
|
||||
.mqtt_config
|
||||
.lock(|config_interface| config_interface.update())
|
||||
{
|
||||
Some(Action::Sleep) => cortex_m::asm::wfi(),
|
||||
Some(Action::UpdateSettings) => {
|
||||
c.spawn.settings_update().unwrap()
|
||||
@ -153,9 +157,9 @@ const APP: () = {
|
||||
}
|
||||
}
|
||||
|
||||
#[task(priority = 1, resources=[mqtt_settings, afes, settings])]
|
||||
#[task(priority = 1, resources=[mqtt_config, afes, settings])]
|
||||
fn settings_update(mut c: settings_update::Context) {
|
||||
let settings = &c.resources.mqtt_settings.mqtt.settings;
|
||||
let settings = &c.resources.mqtt_config.mqtt.settings;
|
||||
|
||||
// Update the IIR channels.
|
||||
c.resources.settings.lock(|current| *current = *settings);
|
||||
|
@ -14,7 +14,7 @@ use stabilizer::hardware::{
|
||||
};
|
||||
|
||||
use miniconf::Miniconf;
|
||||
use stabilizer::net::{Action, MqttSettings};
|
||||
use stabilizer::net::{Action, MiniconfInterface};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Miniconf)]
|
||||
enum Conf {
|
||||
@ -58,7 +58,7 @@ const APP: () = {
|
||||
afes: (AFE0, AFE1),
|
||||
adcs: (Adc0Input, Adc1Input),
|
||||
dacs: (Dac0Output, Dac1Output),
|
||||
mqtt_settings: MqttSettings<Settings>,
|
||||
mqtt_config: MiniconfInterface<Settings>,
|
||||
settings: Settings,
|
||||
|
||||
timestamper: InputStamper,
|
||||
@ -71,7 +71,7 @@ const APP: () = {
|
||||
// Configure the microcontroller
|
||||
let (mut stabilizer, _pounder) = setup(c.core, c.device);
|
||||
|
||||
let mqtt_settings = MqttSettings::new(
|
||||
let mqtt_config = MiniconfInterface::new(
|
||||
stabilizer.net.stack,
|
||||
"",
|
||||
"dt/sinara/lockin",
|
||||
@ -108,7 +108,7 @@ const APP: () = {
|
||||
afes: stabilizer.afes,
|
||||
adcs: stabilizer.adcs,
|
||||
dacs: stabilizer.dacs,
|
||||
mqtt_settings,
|
||||
mqtt_config,
|
||||
timestamper: stabilizer.timestamper,
|
||||
|
||||
settings,
|
||||
@ -190,10 +190,14 @@ const APP: () = {
|
||||
}
|
||||
}
|
||||
|
||||
#[idle(resources=[mqtt_settings], spawn=[settings_update])]
|
||||
#[idle(resources=[mqtt_config], spawn=[settings_update])]
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
loop {
|
||||
match c.resources.mqtt_settings.lock(|settings| settings.update()) {
|
||||
match c
|
||||
.resources
|
||||
.mqtt_config
|
||||
.lock(|config_interface| config_interface.update())
|
||||
{
|
||||
Some(Action::Sleep) => cortex_m::asm::wfi(),
|
||||
Some(Action::UpdateSettings) => {
|
||||
c.spawn.settings_update().unwrap()
|
||||
@ -203,9 +207,9 @@ const APP: () = {
|
||||
}
|
||||
}
|
||||
|
||||
#[task(priority = 1, resources=[mqtt_settings, settings, afes])]
|
||||
#[task(priority = 1, resources=[mqtt_config, settings, afes])]
|
||||
fn settings_update(mut c: settings_update::Context) {
|
||||
let settings = &c.resources.mqtt_settings.mqtt.settings;
|
||||
let settings = &c.resources.mqtt_config.mqtt.settings;
|
||||
|
||||
c.resources.afes.0.set_gain(settings.afe[0]);
|
||||
c.resources.afes.1.set_gain(settings.afe[1]);
|
||||
|
@ -2,7 +2,7 @@ use crate::hardware::{
|
||||
design_parameters::MQTT_BROKER, CycleCounter, EthernetPhy, NetworkStack,
|
||||
};
|
||||
|
||||
use miniconf::{minimq, MqttInterface};
|
||||
use miniconf::minimq;
|
||||
|
||||
/// Potential actions for firmware to take.
|
||||
pub enum Action {
|
||||
@ -14,17 +14,17 @@ pub enum Action {
|
||||
}
|
||||
|
||||
/// MQTT settings interface.
|
||||
pub struct MqttSettings<S>
|
||||
pub struct MiniconfInterface<S>
|
||||
where
|
||||
S: miniconf::Miniconf + Default,
|
||||
{
|
||||
pub mqtt: MqttInterface<S, NetworkStack, minimq::consts::U256>,
|
||||
pub mqtt: miniconf::MqttInterface<S, NetworkStack, minimq::consts::U256>,
|
||||
clock: CycleCounter,
|
||||
phy: EthernetPhy,
|
||||
network_was_reset: bool,
|
||||
}
|
||||
|
||||
impl<S> MqttSettings<S>
|
||||
impl<S> MiniconfInterface<S>
|
||||
where
|
||||
S: miniconf::Miniconf + Default,
|
||||
{
|
||||
@ -49,7 +49,8 @@ where
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
MqttInterface::new(mqtt_client, prefix, S::default()).unwrap()
|
||||
miniconf::MqttInterface::new(mqtt_client, prefix, S::default())
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
Self {
|
||||
|
Loading…
Reference in New Issue
Block a user