diff rust/src/fridge.rs @ 635:4424a8b30f9c rust

config crate wants everything to be lower case
author Matt Johnston <matt@ucc.asn.au>
date Sun, 22 Sep 2019 22:06:46 +0800
parents a5721c02d3ee
children 43eb3cfdf769
line wrap: on
line diff
--- a/rust/src/fridge.rs	Sun Sep 22 20:35:40 2019 +0800
+++ b/rust/src/fridge.rs	Sun Sep 22 22:06:46 2019 +0800
@@ -61,8 +61,8 @@
                 ctx: &Context<Self::Msg>,
                 r: Readings,
                 _sender: Sender) {
-        self.temp_wort = r.get_temp(&self.config.WORT_NAME);
-        self.temp_fridge = r.get_temp(&self.config.FRIDGE_NAME);
+        self.temp_wort = r.get_temp(&self.config.wort_name);
+        self.temp_fridge = r.get_temp(&self.config.fridge_name);
 
         if self.temp_wort.is_some() {
             self.wort_valid_time = Instant::now();
@@ -121,13 +121,13 @@
             temp_wort: None,
             temp_fridge: None,
             last_off_time: Instant::now(),
-            wort_valid_time: Instant::now() - Duration::new(config.FRIDGE_WORT_INVALID_TIME, 100),
+            wort_valid_time: Instant::now() - Duration::new(config.fridge_wort_invalid_time, 100),
             integrator: StepIntegrator::new(Duration::new(1, 0)),
             control: Self::make_control(&config),
         };
 
         if nowait {
-            f.last_off_time -= Duration::new(config.FRIDGE_DELAY, 1);
+            f.last_off_time -= Duration::new(config.fridge_delay, 1);
         }
 
         f
@@ -135,7 +135,7 @@
 
 #[cfg(target_os = "linux")]
     fn make_control(config: &Config) -> FridgeControl {
-        let mut pin = Pin(config.FRIDGE_GPIO_PIN);
+        let mut pin = Pin(config.fridge_gpio_pin);
         // XXX better error handling?
         pin.export().expect("Exporting fridge gpio failed");
         pin.set_direction(Direction::Low).expect("Fridge gpio direction failed");
@@ -185,7 +185,7 @@
 
         // Safety to avoid bad things happening to the fridge motor (?)
         // When it turns off don't start up again for at least FRIDGE_DELAY
-        if !self.on && off_time < Duration::new(self.config.FRIDGE_DELAY, 0) {
+        if !self.on && off_time < Duration::new(self.config.fridge_delay, 0) {
             info!("fridge skipping, too early");
             return;
         }
@@ -202,7 +202,7 @@
         if self.temp_wort.is_none() {
             let invalid_time = Instant::now() - self.wort_valid_time;
             warn!("Invalid wort sensor for {:?} secs", invalid_time);
-            if invalid_time < Duration::new(self.config.FRIDGE_WORT_INVALID_TIME, 0) {
+            if invalid_time < Duration::new(self.config.fridge_wort_invalid_time, 0) {
                 warn!("Has only been invalid for {:?}, waiting", invalid_time);
                 return;
             }