Skip to content

Commit

Permalink
Release 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mrene committed Jan 15, 2021
2 parents 5c66c83 + 9b7a99d commit d78b03b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Mathieu Rene <[email protected]>"]
edition = "2018"
name = "minidsp"
version = "0.0.3"
version = "0.0.4"
license = "MIT"
description = "A control interface for some MiniDSP products"
repository = "https://github.com/mrene/minidsp-rs"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cargo install minidsp

## Usage

## Attention
### Attention
The changes done through this command will not be visible from the minidsp app, as it cannot read the settings back from the device.
The following settings will be visible after changing them from any source:
- Master Gain
Expand Down Expand Up @@ -404,4 +404,4 @@ Then reload using:
```
sudo udevadm control --reload-rules
```
```
20 changes: 17 additions & 3 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ pub enum Responses {
},

/// Speculative commands
MaybeConfigChanged,
ConfigChanged,

Unknown {
cmd_id: u8,
Expand Down Expand Up @@ -443,7 +443,7 @@ impl Responses {
frame.get_u16()
},
},
0xab => Responses::MaybeConfigChanged,
0xab => Responses::ConfigChanged,
cmd_id => Responses::Unknown {
cmd_id,
payload: BytesWrap(frame),
Expand Down Expand Up @@ -480,7 +480,7 @@ impl Responses {
f.put_u8(0x39);
f.put_u16(*size);
}
Responses::MaybeConfigChanged => {}
Responses::ConfigChanged => {}
}
f.freeze()
}
Expand Down Expand Up @@ -541,6 +541,20 @@ impl Responses {
}
}

pub fn is_config_changed(&self) -> bool {
matches!(self, Responses::ConfigChanged)
}

pub fn into_config_changed(self) -> Result<(), MiniDSPError> {
match self {
Responses::ConfigChanged => Ok(()),
_ => Err(MiniDSPError::MalformedResponse(format!(
"Expected a ConfigChanged, but got a {:?}",
self
))),
}
}

pub fn is_fir_size(&self) -> bool {
matches!(self, Responses::FirLoadSize { .. })
}
Expand Down
15 changes: 9 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,15 @@ impl MiniDSP<'_> {

/// Sets the active configuration
pub async fn set_config(&self, config: u8) -> Result<()> {
self.roundtrip(Commands::SetConfig {
config,
reset: true,
})
.await?;
Ok(())
self.roundtrip_expect(
Commands::SetConfig {
config,
reset: true,
},
|resp| resp.is_config_changed(),
)
.await?
.into_config_changed()
}

/// Gets an object wrapping an input channel
Expand Down

0 comments on commit d78b03b

Please sign in to comment.