forked from M-Labs/thermostat
add Channels::read_ref_adc()
This commit is contained in:
parent
3d1740b23b
commit
eb9aeb160a
|
@ -75,4 +75,18 @@ impl Channels {
|
|||
channel
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read_ref_adc(&mut self, channel: usize) -> u16 {
|
||||
match channel {
|
||||
0 => self.channel0.ref_adc.convert(
|
||||
&self.channel0.ref_pin,
|
||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||
),
|
||||
1 => self.channel1.ref_adc.convert(
|
||||
&self.channel1.ref_pin,
|
||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||
),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -141,19 +141,16 @@ fn main() -> ! {
|
|||
}
|
||||
Command::Show(ShowCommand::Input) => {
|
||||
for channel in 0..CHANNELS {
|
||||
if let Some(adc_data) = channels.channel_state(channel).adc_data {
|
||||
let ref_adc_data = channels.read_ref_adc(channel);
|
||||
let state = channels.channel_state(channel);
|
||||
if let Some(adc_data) = state.adc_data {
|
||||
let _ = writeln!(
|
||||
socket, "t={} raw{}=0x{:06X}",
|
||||
state.adc_time, channel, adc_data
|
||||
socket, "t={} raw{}=0x{:06X} ref_adc={}",
|
||||
state.adc_time, channel, adc_data,
|
||||
ref_adc_data
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let ref0 = channels.channel0.ref_adc.convert(
|
||||
&channels.channel0.ref_pin, stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||
);
|
||||
let _ = writeln!(socket, "ref0={}", ref0);
|
||||
}
|
||||
Command::Show(ShowCommand::Pid) => {
|
||||
for channel in 0..CHANNELS {
|
||||
|
|
Loading…
Reference in New Issue