Merge branch 'master' into rj/visibility-cleanup
* master: Removing spurious settings updates
This commit is contained in:
commit
bf92f6209a
@ -11,9 +11,10 @@ use stabilizer::{
|
||||
Dac1Output, DacCode, DigitalInput0, DigitalInput1, InputPin,
|
||||
SystemTimer, AFE0, AFE1,
|
||||
},
|
||||
net::{Miniconf, NetworkUsers, Telemetry, TelemetryBuffer, UpdateState},
|
||||
net::{Miniconf, NetworkState, NetworkUsers, Telemetry, TelemetryBuffer},
|
||||
};
|
||||
|
||||
|
||||
const SCALE: f32 = i16::MAX as _;
|
||||
|
||||
// The number of cascaded IIR biquads per channel. Select 1 or 2!
|
||||
@ -170,8 +171,11 @@ const APP: () = {
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
loop {
|
||||
match c.resources.network.lock(|net| net.update()) {
|
||||
UpdateState::Updated => c.spawn.settings_update().unwrap(),
|
||||
UpdateState::NoChange => cortex_m::asm::wfi(),
|
||||
NetworkState::SettingsChanged => {
|
||||
c.spawn.settings_update().unwrap()
|
||||
}
|
||||
NetworkState::Updated => {}
|
||||
NetworkState::NoChange => cortex_m::asm::wfi(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use stabilizer::{
|
||||
Dac0Output, Dac1Output, DacCode, DigitalInput0, DigitalInput1,
|
||||
InputPin, InputStamper, SystemTimer, AFE0, AFE1,
|
||||
},
|
||||
net::{Miniconf, NetworkUsers, Telemetry, TelemetryBuffer, UpdateState},
|
||||
net::{Miniconf, NetworkState, NetworkUsers, Telemetry, TelemetryBuffer},
|
||||
};
|
||||
|
||||
// A constant sinusoid to send on the DAC output.
|
||||
@ -243,8 +243,11 @@ const APP: () = {
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
loop {
|
||||
match c.resources.network.lock(|net| net.update()) {
|
||||
UpdateState::Updated => c.spawn.settings_update().unwrap(),
|
||||
UpdateState::NoChange => cortex_m::asm::wfi(),
|
||||
NetworkState::SettingsChanged => {
|
||||
c.spawn.settings_update().unwrap()
|
||||
}
|
||||
NetworkState::Updated => {}
|
||||
NetworkState::NoChange => cortex_m::asm::wfi(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,12 @@ pub enum UpdateState {
|
||||
Updated,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub enum NetworkState {
|
||||
SettingsChanged,
|
||||
Updated,
|
||||
NoChange,
|
||||
}
|
||||
/// A structure of Stabilizer's default network users.
|
||||
pub struct NetworkUsers<S: Default + Clone + Miniconf, T: Serialize> {
|
||||
pub miniconf: MiniconfClient<S>,
|
||||
@ -97,15 +103,18 @@ where
|
||||
///
|
||||
/// # Returns
|
||||
/// An indication if any of the network users indicated a state change.
|
||||
pub fn update(&mut self) -> UpdateState {
|
||||
pub fn update(&mut self) -> NetworkState {
|
||||
// Poll for incoming data.
|
||||
let poll_result = self.processor.update();
|
||||
let poll_result = match self.processor.update() {
|
||||
UpdateState::NoChange => NetworkState::NoChange,
|
||||
UpdateState::Updated => NetworkState::Updated,
|
||||
};
|
||||
|
||||
// Update the MQTT clients.
|
||||
self.telemetry.update();
|
||||
|
||||
match self.miniconf.update() {
|
||||
UpdateState::Updated => UpdateState::Updated,
|
||||
UpdateState::Updated => NetworkState::SettingsChanged,
|
||||
UpdateState::NoChange => poll_result,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user