clippy happier
This commit is contained in:
		@@ -3,12 +3,12 @@ use chrono_tz::Tz;
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
 | 
			
		||||
use crate::{
 | 
			
		||||
    config::{self, PlantConfig},
 | 
			
		||||
    config::PlantConfig,
 | 
			
		||||
    in_time_range, plant_hal,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const MOIST_SENSOR_MAX_FREQUENCY: f32 = 6500.; // 60kHz (500Hz margin)
 | 
			
		||||
const MOIST_SENSOR_MIN_FREQUENCY: f32 = 150.; // this is really really dry, think like cactus levels
 | 
			
		||||
const MOIST_SENSOR_MIN_FREQUENCY: f32 = 150.; // this is really, really dry, think like cactus levels
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, PartialEq, Serialize)]
 | 
			
		||||
pub enum MoistureSensorError {
 | 
			
		||||
@@ -117,7 +117,7 @@ impl PlantState {
 | 
			
		||||
    pub fn read_hardware_state(
 | 
			
		||||
        plant_id: usize,
 | 
			
		||||
        board: &mut plant_hal::PlantCtrlBoard,
 | 
			
		||||
        config: &config::PlantConfig,
 | 
			
		||||
        config: &PlantConfig,
 | 
			
		||||
    ) -> Self {
 | 
			
		||||
        let sensor_a = if config.sensor_a {
 | 
			
		||||
            match board.measure_moisture_hz(plant_id, plant_hal::Sensor::A) {
 | 
			
		||||
@@ -225,28 +225,22 @@ impl PlantState {
 | 
			
		||||
                if let Some(moisture_percent) = moisture_percent {
 | 
			
		||||
                    if self.pump_in_timeout(plant_conf, current_time) {
 | 
			
		||||
                        false
 | 
			
		||||
                    } else if moisture_percent < plant_conf.target_moisture {
 | 
			
		||||
                        in_time_range(
 | 
			
		||||
                            current_time,
 | 
			
		||||
                            plant_conf.pump_hour_start,
 | 
			
		||||
                            plant_conf.pump_hour_end,
 | 
			
		||||
                        )
 | 
			
		||||
                    } else {
 | 
			
		||||
                        if moisture_percent < plant_conf.target_moisture {
 | 
			
		||||
                            in_time_range(
 | 
			
		||||
                                current_time,
 | 
			
		||||
                                plant_conf.pump_hour_start,
 | 
			
		||||
                                plant_conf.pump_hour_end,
 | 
			
		||||
                            )
 | 
			
		||||
                        } else {
 | 
			
		||||
                            false
 | 
			
		||||
                        }
 | 
			
		||||
                        false
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    // in case no moisture can be determined do not water plant
 | 
			
		||||
                    return false;
 | 
			
		||||
                    // in case no moisture can be determined, do not water the plant
 | 
			
		||||
                    false
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            PlantWateringMode::TimerOnly => {
 | 
			
		||||
                if self.pump_in_timeout(plant_conf, current_time) {
 | 
			
		||||
                    false
 | 
			
		||||
                } else {
 | 
			
		||||
                    true
 | 
			
		||||
                }
 | 
			
		||||
                !self.pump_in_timeout(plant_conf, current_time)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -299,9 +293,9 @@ pub struct PlantInfo<'a> {
 | 
			
		||||
    sensor_b: &'a MoistureSensorState,
 | 
			
		||||
    /// configured plant watering mode
 | 
			
		||||
    mode: PlantWateringMode,
 | 
			
		||||
    /// plant needs to be watered
 | 
			
		||||
    /// the plant needs to be watered
 | 
			
		||||
    do_water: bool,
 | 
			
		||||
    /// is plant considerd to be dry according to settings
 | 
			
		||||
    /// plant is considered to be dry according to settings
 | 
			
		||||
    dry: bool,
 | 
			
		||||
    /// plant irrigation cooldown is active
 | 
			
		||||
    cooldown: bool,
 | 
			
		||||
@@ -310,7 +304,7 @@ pub struct PlantInfo<'a> {
 | 
			
		||||
    /// how often has the pump been watered without reaching target moisture
 | 
			
		||||
    consecutive_pump_count: u32,
 | 
			
		||||
    pump_error: Option<PumpError>,
 | 
			
		||||
    /// last time when pump was active
 | 
			
		||||
    /// last time when the pump was active
 | 
			
		||||
    last_pump: Option<DateTime<Tz>>,
 | 
			
		||||
    /// next time when pump should activate
 | 
			
		||||
    next_pump: Option<DateTime<Tz>>,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user