forked from M-Labs/thermostat
clippy
This commit is contained in:
parent
a947e25e8f
commit
ce86dc27fd
@ -199,7 +199,7 @@ impl<SPI: Transfer<u8, Error = E>, NSS: OutputPin, E: fmt::Debug> Adc<SPI, NSS>
|
|||||||
ChecksumMode::Crc => ChecksumMode::Crc,
|
ChecksumMode::Crc => ChecksumMode::Crc,
|
||||||
});
|
});
|
||||||
checksum.feed(&[address]);
|
checksum.feed(&[address]);
|
||||||
checksum.feed(®_data);
|
checksum.feed(reg_data);
|
||||||
let checksum_out = checksum.result();
|
let checksum_out = checksum.result();
|
||||||
|
|
||||||
let mut data = reg_data.clone();
|
let mut data = reg_data.clone();
|
||||||
|
@ -158,7 +158,7 @@ impl Channels {
|
|||||||
|
|
||||||
pub fn set_i(&mut self, channel: usize, i_set: ElectricCurrent) -> ElectricCurrent {
|
pub fn set_i(&mut self, channel: usize, i_set: ElectricCurrent) -> ElectricCurrent {
|
||||||
let i_set = i_set.min(MAX_TEC_I).max(-MAX_TEC_I);
|
let i_set = i_set.min(MAX_TEC_I).max(-MAX_TEC_I);
|
||||||
let vref_meas = match channel.into() {
|
let vref_meas = match channel {
|
||||||
0 => self.channel0.vref_meas,
|
0 => self.channel0.vref_meas,
|
||||||
1 => self.channel1.vref_meas,
|
1 => self.channel1.vref_meas,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
@ -193,7 +193,7 @@ impl Channels {
|
|||||||
}
|
}
|
||||||
sample / avg_pt as u32
|
sample / avg_pt as u32
|
||||||
}
|
}
|
||||||
Channel0VRef::Disabled(_) => 2048 as u32,
|
Channel0VRef::Disabled(_) => 2048_u32,
|
||||||
},
|
},
|
||||||
PinsAdcReadTarget::DacVfb => {
|
PinsAdcReadTarget::DacVfb => {
|
||||||
for _ in (0..avg_pt).rev() {
|
for _ in (0..avg_pt).rev() {
|
||||||
@ -238,7 +238,7 @@ impl Channels {
|
|||||||
}
|
}
|
||||||
sample / avg_pt as u32
|
sample / avg_pt as u32
|
||||||
}
|
}
|
||||||
Channel1VRef::Disabled(_) => 2048 as u32,
|
Channel1VRef::Disabled(_) => 2048_u32,
|
||||||
},
|
},
|
||||||
PinsAdcReadTarget::DacVfb => {
|
PinsAdcReadTarget::DacVfb => {
|
||||||
for _ in (0..avg_pt).rev() {
|
for _ in (0..avg_pt).rev() {
|
||||||
@ -310,9 +310,9 @@ impl Channels {
|
|||||||
let samples = 50;
|
let samples = 50;
|
||||||
let mut target_voltage = ElectricPotential::new::<volt>(0.0);
|
let mut target_voltage = ElectricPotential::new::<volt>(0.0);
|
||||||
for _ in 0..samples {
|
for _ in 0..samples {
|
||||||
target_voltage = target_voltage + self.get_center(channel);
|
target_voltage += self.get_center(channel);
|
||||||
}
|
}
|
||||||
target_voltage = target_voltage / samples as f64;
|
target_voltage /= samples as f64;
|
||||||
let mut start_value = 1;
|
let mut start_value = 1;
|
||||||
let mut best_error = ElectricPotential::new::<volt>(100.0);
|
let mut best_error = ElectricPotential::new::<volt>(100.0);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ fn send_line(socket: &mut TcpSocket, data: &[u8]) -> bool {
|
|||||||
data.len(),
|
data.len(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
match socket.send_slice(&data) {
|
match socket.send_slice(data) {
|
||||||
Ok(sent) if sent == data.len() => {
|
Ok(sent) if sent == data.len() => {
|
||||||
let _ = socket.send_slice(b"\n");
|
let _ = socket.send_slice(b"\n");
|
||||||
// success
|
// success
|
||||||
|
@ -208,7 +208,7 @@ fn unsigned(input: &[u8]) -> IResult<&[u8], Result<u32, Error>> {
|
|||||||
fn float(input: &[u8]) -> IResult<&[u8], Result<f64, Error>> {
|
fn float(input: &[u8]) -> IResult<&[u8], Result<f64, Error>> {
|
||||||
let (input, sign) = opt(is_a("-"))(input)?;
|
let (input, sign) = opt(is_a("-"))(input)?;
|
||||||
let negative = sign.is_some();
|
let negative = sign.is_some();
|
||||||
let (input, digits) = take_while1(|c| is_digit(c) || c == '.' as u8)(input)?;
|
let (input, digits) = take_while1(|c| is_digit(c) || c == b'.')(input)?;
|
||||||
let result = from_utf8(digits)
|
let result = from_utf8(digits)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
.and_then(|digits| f64::from_str_radix(digits, 10).map_err(|e| e.into()))
|
.and_then(|digits| f64::from_str_radix(digits, 10).map_err(|e| e.into()))
|
||||||
@ -580,7 +580,7 @@ fn command(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
|||||||
impl Command {
|
impl Command {
|
||||||
pub fn parse(input: &[u8]) -> Result<Self, Error> {
|
pub fn parse(input: &[u8]) -> Result<Self, Error> {
|
||||||
match command(input) {
|
match command(input) {
|
||||||
Ok((input_remain, result)) if input_remain.len() == 0 => result,
|
Ok((input_remain, result)) if input_remain.is_empty() => result,
|
||||||
Ok((input_remain, _)) => Err(Error::UnexpectedInput(input_remain[0])),
|
Ok((input_remain, _)) => Err(Error::UnexpectedInput(input_remain[0])),
|
||||||
Err(e) => Err(e.into()),
|
Err(e) => Err(e.into()),
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ impl ChannelConfig {
|
|||||||
pid: state.pid.parameters.clone(),
|
pid: state.pid.parameters.clone(),
|
||||||
pid_target: state.pid.target as f32,
|
pid_target: state.pid.target as f32,
|
||||||
pid_engaged: state.pid_engaged,
|
pid_engaged: state.pid_engaged,
|
||||||
i_set: i_set,
|
i_set,
|
||||||
sh: state.sh.clone(),
|
sh: state.sh.clone(),
|
||||||
pwm,
|
pwm,
|
||||||
adc_postfilter,
|
adc_postfilter,
|
||||||
|
@ -74,7 +74,7 @@ fn send_line(socket: &mut TcpSocket, data: &[u8]) -> bool {
|
|||||||
data.len(),
|
data.len(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
match socket.send_slice(&data) {
|
match socket.send_slice(data) {
|
||||||
Ok(sent) if sent == data.len() => {
|
Ok(sent) if sent == data.len() => {
|
||||||
let _ = socket.send_slice(b"\n");
|
let _ = socket.send_slice(b"\n");
|
||||||
// success
|
// success
|
||||||
|
@ -39,7 +39,7 @@ pub struct Controller {
|
|||||||
impl Controller {
|
impl Controller {
|
||||||
pub const fn new(parameters: Parameters) -> Controller {
|
pub const fn new(parameters: Parameters) -> Controller {
|
||||||
Controller {
|
Controller {
|
||||||
parameters: parameters,
|
parameters,
|
||||||
target: 0.0,
|
target: 0.0,
|
||||||
u1: 0.0,
|
u1: 0.0,
|
||||||
x1: 0.0,
|
x1: 0.0,
|
||||||
|
@ -188,7 +188,7 @@ impl Pins {
|
|||||||
|
|
||||||
let (dac0_spi, dac0_sync) = Self::setup_dac0(clocks, spi4, gpioe.pe2, gpioe.pe4, gpioe.pe6);
|
let (dac0_spi, dac0_sync) = Self::setup_dac0(clocks, spi4, gpioe.pe2, gpioe.pe4, gpioe.pe6);
|
||||||
let mut shdn0 = gpioe.pe10.into_push_pull_output();
|
let mut shdn0 = gpioe.pe10.into_push_pull_output();
|
||||||
let _ = shdn0.set_low();
|
shdn0.set_low();
|
||||||
let vref0_pin = if hwrev.major > 2 {
|
let vref0_pin = if hwrev.major > 2 {
|
||||||
Channel0VRef::Analog(gpioa.pa0.into_analog())
|
Channel0VRef::Analog(gpioa.pa0.into_analog())
|
||||||
} else {
|
} else {
|
||||||
@ -209,7 +209,7 @@ impl Pins {
|
|||||||
|
|
||||||
let (dac1_spi, dac1_sync) = Self::setup_dac1(clocks, spi5, gpiof.pf7, gpiof.pf6, gpiof.pf9);
|
let (dac1_spi, dac1_sync) = Self::setup_dac1(clocks, spi5, gpiof.pf7, gpiof.pf6, gpiof.pf9);
|
||||||
let mut shdn1 = gpioe.pe15.into_push_pull_output();
|
let mut shdn1 = gpioe.pe15.into_push_pull_output();
|
||||||
let _ = shdn1.set_low();
|
shdn1.set_low();
|
||||||
let vref1_pin = if hwrev.major > 2 {
|
let vref1_pin = if hwrev.major > 2 {
|
||||||
Channel1VRef::Analog(gpioa.pa3.into_analog())
|
Channel1VRef::Analog(gpioa.pa3.into_analog())
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,7 +96,7 @@ impl Session {
|
|||||||
self.report_pending.iter().enumerate().fold(
|
self.report_pending.iter().enumerate().fold(
|
||||||
None,
|
None,
|
||||||
|result, (channel, report_pending)| {
|
|result, (channel, report_pending)| {
|
||||||
result.or_else(|| if *report_pending { Some(channel) } else { None })
|
result.or(if *report_pending { Some(channel) } else { None })
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ impl Session {
|
|||||||
let line = self.reader.feed(*b);
|
let line = self.reader.feed(*b);
|
||||||
match line {
|
match line {
|
||||||
Some(line) => {
|
Some(line) => {
|
||||||
let command = Command::parse(&line);
|
let command = Command::parse(line);
|
||||||
match command {
|
match command {
|
||||||
Ok(Command::Reporting(reporting)) => {
|
Ok(Command::Reporting(reporting)) => {
|
||||||
self.reporting = reporting;
|
self.reporting = reporting;
|
||||||
|
Loading…
Reference in New Issue
Block a user