Merge remote-tracking branch 'origin/feature/miniconf-update' into lockin-external-miniconf

* origin/feature/miniconf-update:
  Adjusting sleep semantics
  Fixing negation
  Restoring sleep semantics
  Updating dependencies
  Updating id semantics
  Updating dependencies
  Updating minimq/miniconf dependencies
  Updating miniconf dependencies
master
Robert Jördens 2021-03-02 17:24:58 +01:00
commit ca66894d51
7 changed files with 23 additions and 36 deletions

11
Cargo.lock generated
View File

@ -199,9 +199,9 @@ dependencies = [
] ]
[[package]] [[package]]
name = "derive_stringset" name = "derive_miniconf"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#97ace3d8268075235cb67a2a8740d200bea1fe30" source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -402,9 +402,9 @@ dependencies = [
[[package]] [[package]]
name = "miniconf" name = "miniconf"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/quartiq/miniconf.git?branch=develop#97ace3d8268075235cb67a2a8740d200bea1fe30" source = "git+https://github.com/quartiq/miniconf.git?branch=develop#394d0634a9622e43a55850afc34eb4695ecababa"
dependencies = [ dependencies = [
"derive_stringset", "derive_miniconf",
"heapless", "heapless",
"minimq", "minimq",
"serde", "serde",
@ -414,8 +414,7 @@ dependencies = [
[[package]] [[package]]
name = "minimq" name = "minimq"
version = "0.2.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/quartiq/minimq.git?branch=master#a89a6f11d0d1f63114fb15f676022eb4fe904f56"
checksum = "9c5e626690b6f62e15710cf9815e5ca25ee54084899298c100a14b2504c80a46"
dependencies = [ dependencies = [
"bit_field", "bit_field",
"embedded-nal", "embedded-nal",

View File

@ -52,6 +52,10 @@ generic-array = "0.14"
git = "https://github.com/quartiq/miniconf.git" git = "https://github.com/quartiq/miniconf.git"
branch = "develop" branch = "develop"
[patch.crates-io.minimq]
git = "https://github.com/quartiq/minimq.git"
branch = "master"
[patch.crates-io.serde-json-core] [patch.crates-io.serde-json-core]
git = "https://github.com/rust-embedded-community/serde-json-core.git" git = "https://github.com/rust-embedded-community/serde-json-core.git"
branch = "master" branch = "master"

View File

@ -1,4 +1,4 @@
use miniconf::StringSet; use miniconf::MiniconfAtomic;
use serde::Deserialize; use serde::Deserialize;
use super::{abs, copysign, macc, max, min}; use super::{abs, copysign, macc, max, min};
@ -39,7 +39,7 @@ pub type Vec5 = [f32; 5];
/// Therefore it can trivially implement bump-less transfer. /// Therefore it can trivially implement bump-less transfer.
/// * Cascading multiple IIR filters allows stable and robust /// * Cascading multiple IIR filters allows stable and robust
/// implementation of transfer functions beyond bequadratic terms. /// implementation of transfer functions beyond bequadratic terms.
#[derive(Copy, Clone, Debug, Default, Deserialize, StringSet)] #[derive(Copy, Clone, Debug, Default, Deserialize, MiniconfAtomic)]
pub struct IIR { pub struct IIR {
pub ba: Vec5, pub ba: Vec5,
pub y_offset: f32, pub y_offset: f32,

View File

@ -1,6 +1,6 @@
use super::tools::macc_i32; use super::tools::macc_i32;
use core::f64::consts::PI; use core::f64::consts::PI;
use miniconf::StringSet; use miniconf::MiniconfAtomic;
use serde::Deserialize; use serde::Deserialize;
/// Generic vector for integer IIR filter. /// Generic vector for integer IIR filter.
@ -46,7 +46,7 @@ impl Coeff for Vec5 {
/// See `dsp::iir::IIR` for general implementation details. /// See `dsp::iir::IIR` for general implementation details.
/// Offset and limiting disabled to suit lowpass applications. /// Offset and limiting disabled to suit lowpass applications.
/// Coefficient scaling fixed and optimized. /// Coefficient scaling fixed and optimized.
#[derive(Copy, Clone, Default, Debug, StringSet, Deserialize)] #[derive(Copy, Clone, Default, Debug, MiniconfAtomic, Deserialize)]
pub struct IIR { pub struct IIR {
pub ba: Vec5, pub ba: Vec5,
// pub y_offset: i32, // pub y_offset: i32,

View File

@ -8,7 +8,7 @@ use stabilizer::hardware;
use miniconf::{ use miniconf::{
embedded_nal::{IpAddr, Ipv4Addr}, embedded_nal::{IpAddr, Ipv4Addr},
minimq, MqttInterface, StringSet, minimq, Miniconf, MqttInterface,
}; };
use serde::Deserialize; use serde::Deserialize;
@ -23,7 +23,7 @@ const SCALE: f32 = i16::MAX as _;
// The number of cascaded IIR biquads per channel. Select 1 or 2! // The number of cascaded IIR biquads per channel. Select 1 or 2!
const IIR_CASCADE_LENGTH: usize = 1; const IIR_CASCADE_LENGTH: usize = 1;
#[derive(Debug, Deserialize, StringSet)] #[derive(Debug, Deserialize, Miniconf)]
pub struct Settings { pub struct Settings {
afe: [AfeGain; 2], afe: [AfeGain; 2],
iir_ch: [[iir::IIR; IIR_CASCADE_LENGTH]; 2], iir_ch: [[iir::IIR; IIR_CASCADE_LENGTH]; 2],
@ -63,12 +63,8 @@ const APP: () = {
let mqtt_interface = { let mqtt_interface = {
let mqtt_client = { let mqtt_client = {
let broker = IpAddr::V4(Ipv4Addr::new(10, 34, 16, 1)); let broker = IpAddr::V4(Ipv4Addr::new(10, 34, 16, 1));
minimq::MqttClient::new( minimq::MqttClient::new(broker, "", stabilizer.net.stack)
broker, .unwrap()
"stabilizer",
stabilizer.net.stack,
)
.unwrap()
}; };
MqttInterface::new(mqtt_client, "stabilizer", Settings::default()) MqttInterface::new(mqtt_client, "stabilizer", Settings::default())
@ -147,19 +143,13 @@ const APP: () = {
!interface.network_stack().poll(clock.current_ms()) !interface.network_stack().poll(clock.current_ms())
}); });
match c if c.resources
.resources
.mqtt_interface .mqtt_interface
.lock(|interface| interface.update().unwrap()) .lock(|interface| interface.update().unwrap())
{ {
miniconf::Action::Continue => { c.spawn.settings_update().unwrap()
if sleep { } else if sleep {
cortex_m::asm::wfi(); cortex_m::asm::wfi();
}
}
miniconf::Action::CommitSettings => {
c.spawn.settings_update().unwrap()
}
} }
} }
} }

View File

@ -1,11 +1,11 @@
use miniconf::StringSet; use miniconf::Miniconf;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use core::convert::TryFrom; use core::convert::TryFrom;
use enum_iterator::IntoEnumIterator; use enum_iterator::IntoEnumIterator;
#[derive( #[derive(
Copy, Clone, Debug, Serialize, Deserialize, IntoEnumIterator, StringSet, Copy, Clone, Debug, Serialize, Deserialize, IntoEnumIterator, Miniconf,
)] )]
pub enum Gain { pub enum Gain {
G1 = 0b00, G1 = 0b00,

View File

@ -108,10 +108,6 @@ async def configure_settings(args):
response = await interface.command(f'settings/{args.setting}', json.dumps(request)) response = await interface.command(f'settings/{args.setting}', json.dumps(request))
logger.info(response) logger.info(response)
if args.commit:
response = await interface.command('commit', 'commit')
logger.info(response)
def main(): def main():
""" Main program entry point. """ """ Main program entry point. """
@ -122,8 +118,6 @@ def main():
parser.add_argument('--broker', default='10.34.16.1', type=str, help='The MQTT broker address') parser.add_argument('--broker', default='10.34.16.1', type=str, help='The MQTT broker address')
parser.add_argument('values', nargs='+', type=str, parser.add_argument('values', nargs='+', type=str,
help='The value of settings. key=value list or a single value is accepted.') help='The value of settings. key=value list or a single value is accepted.')
parser.add_argument('--commit', action='store_true',
help='Specified true to commit after updating settings.')
parser.add_argument('-v', '--verbose', action='store_true', help='Enable verbose logging') parser.add_argument('-v', '--verbose', action='store_true', help='Enable verbose logging')
args = parser.parse_args() args = parser.parse_args()