Thermostat: Add default to ChannelState
This commit is contained in:
parent
f49fd08c69
commit
d0f226ce03
@ -34,10 +34,17 @@ pub struct ChannelState {
|
||||
}
|
||||
|
||||
impl ChannelState {
|
||||
pub fn new(adc_calibration: ad7172::ChannelCalibration) -> Self {
|
||||
fn adc_calibration(mut self, adc_calibration: ad7172::ChannelCalibration) -> Self {
|
||||
self.adc_calibration = adc_calibration;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ChannelState {
|
||||
fn default() -> Self {
|
||||
ChannelState {
|
||||
adc_data: None,
|
||||
adc_calibration,
|
||||
adc_calibration: ad7172::ChannelCalibration::default(),
|
||||
adc_time: Instant::from_secs(0),
|
||||
// default: 10 Hz
|
||||
adc_interval: Duration::from_millis(100),
|
||||
@ -48,6 +55,12 @@ impl ChannelState {
|
||||
sh: sh::Parameters::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ChannelState {
|
||||
pub fn new(adc_calibration: ad7172::ChannelCalibration) -> Self {
|
||||
ChannelState::default().adc_calibration(adc_calibration)
|
||||
}
|
||||
|
||||
pub fn update(&mut self, now: Instant, adc_data: u32) {
|
||||
self.adc_data = if adc_data == ad7172::MAX_VALUE {
|
||||
|
Loading…
Reference in New Issue
Block a user