forked from M-Labs/thermostat
command_parser: require the explicit `i_set` symbol
This commit is contained in:
parent
b92a5f18cd
commit
5c8bb47e11
16
README.md
16
README.md
|
@ -75,7 +75,7 @@ The scope of this setting is per TCP session.
|
||||||
| `pwm <0/1> max_i_pos <amp>` | Set PWM duty cycle for **max_i_pos** to *ampere* |
|
| `pwm <0/1> max_i_pos <amp>` | Set PWM duty cycle for **max_i_pos** to *ampere* |
|
||||||
| `pwm <0/1> max_i_neg <amp>` | Set PWM duty cycle for **max_i_neg** to *ampere* |
|
| `pwm <0/1> max_i_neg <amp>` | Set PWM duty cycle for **max_i_neg** to *ampere* |
|
||||||
| `pwm <0/1> max_v <volts>` | Set PWM duty cycle for **max_v** to *volt* |
|
| `pwm <0/1> max_v <volts>` | Set PWM duty cycle for **max_v** to *volt* |
|
||||||
| `pwm <0/1> <amp>` | Disengage PID, set **i_set** DAC to *ampere* |
|
| `pwm <0/1> i_set <amp>` | Disengage PID, set **i_set** DAC to *ampere* |
|
||||||
| `pwm <0/1> pid` | Set PWM to be controlled by PID |
|
| `pwm <0/1> pid` | Set PWM to be controlled by PID |
|
||||||
| `center <0/1> <volts>` | Set the MAX1968 0A-centerpoint to *volts* |
|
| `center <0/1> <volts>` | Set the MAX1968 0A-centerpoint to *volts* |
|
||||||
| `center <0/1> vref` | Set the MAX1968 0A-centerpoint to measure from VREF |
|
| `center <0/1> vref` | Set the MAX1968 0A-centerpoint to measure from VREF |
|
||||||
|
@ -146,12 +146,12 @@ output limits.
|
||||||
|
|
||||||
Use the `pwm` command to see current settings and maximum values.
|
Use the `pwm` command to see current settings and maximum values.
|
||||||
|
|
||||||
| Limit | Unit | Description |
|
| Limit | Unit | Description |
|
||||||
| --- | :---: | --- |
|
| --- | :---: | --- |
|
||||||
| `max_v` | Volts | Maximum voltage |
|
| `max_v` | Volts | Maximum voltage |
|
||||||
| `max_i_pos` | Amperes | Maximum positive current |
|
| `max_i_pos` | Amperes | Maximum positive current |
|
||||||
| `max_i_neg` | Amperes | Maximum negative current |
|
| `max_i_neg` | Amperes | Maximum negative current |
|
||||||
| | Amperes | Output current control (Open-loop mode) |
|
| `i_set` | Amperes | (Not a limit; Open-loop mode) |
|
||||||
|
|
||||||
Example: set the maximum voltage of channel 0 to 1.5 V.
|
Example: set the maximum voltage of channel 0 to 1.5 V.
|
||||||
```
|
```
|
||||||
|
@ -166,7 +166,7 @@ channel.
|
||||||
|
|
||||||
Example: set output current of channel 0 to 0 A.
|
Example: set output current of channel 0 to 0 A.
|
||||||
```
|
```
|
||||||
pwm 0 0
|
pwm 0 i_set 0
|
||||||
```
|
```
|
||||||
|
|
||||||
## PID-stabilized temperature control
|
## PID-stabilized temperature control
|
||||||
|
|
|
@ -249,6 +249,16 @@ fn pwm_setup(input: &[u8]) -> IResult<&[u8], Result<(PwmPin, f64), Error>> {
|
||||||
result.map(|value| (pin, value));
|
result.map(|value| (pin, value));
|
||||||
|
|
||||||
alt((
|
alt((
|
||||||
|
map(
|
||||||
|
preceded(
|
||||||
|
tag("i_set"),
|
||||||
|
preceded(
|
||||||
|
whitespace,
|
||||||
|
float
|
||||||
|
)
|
||||||
|
),
|
||||||
|
result_with_pin(PwmPin::ISet)
|
||||||
|
),
|
||||||
map(
|
map(
|
||||||
preceded(
|
preceded(
|
||||||
tag("max_i_pos"),
|
tag("max_i_pos"),
|
||||||
|
@ -278,8 +288,6 @@ fn pwm_setup(input: &[u8]) -> IResult<&[u8], Result<(PwmPin, f64), Error>> {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
result_with_pin(PwmPin::MaxV)
|
result_with_pin(PwmPin::MaxV)
|
||||||
),
|
|
||||||
map(float, result_with_pin(PwmPin::ISet)
|
|
||||||
))
|
))
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
@ -528,8 +536,8 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_pwm_manual() {
|
fn parse_pwm_i_set() {
|
||||||
let command = Command::parse(b"pwm 1 16383");
|
let command = Command::parse(b"pwm 1 i_set 16383");
|
||||||
assert_eq!(command, Ok(Command::Pwm {
|
assert_eq!(command, Ok(Command::Pwm {
|
||||||
channel: 1,
|
channel: 1,
|
||||||
pin: PwmPin::ISet,
|
pin: PwmPin::ISet,
|
||||||
|
|
Loading…
Reference in New Issue