From 4faae86a6b48ceea7736596f1b60fc89de4bd2e0 Mon Sep 17 00:00:00 2001 From: ju6ge Date: Thu, 11 Sep 2025 20:17:18 +0200 Subject: [PATCH] reduce amount of warnings --- rust/src/hal/mod.rs | 2 +- rust/src/hal/v3_hal.rs | 2 +- rust/src/hal/v4_hal.rs | 8 +++----- rust/src/main.rs | 10 +--------- rust/src/plant_state.rs | 6 +++--- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/rust/src/hal/mod.rs b/rust/src/hal/mod.rs index 4a413cf..6c4e486 100644 --- a/rust/src/hal/mod.rs +++ b/rust/src/hal/mod.rs @@ -113,7 +113,7 @@ pub trait BoardInteraction<'a> { impl dyn BoardInteraction<'_> { //the counter is just some arbitrary number that increases whenever some progress was made, try to keep the updates < 10 per second for ux reasons - fn progress(&mut self, counter: u32) { + fn _progress(&mut self, counter: u32) { let even = counter % 2 == 0; let current = counter / (PLANT_COUNT as u32); for led in 0..PLANT_COUNT { diff --git a/rust/src/hal/v3_hal.rs b/rust/src/hal/v3_hal.rs index bd9063a..3c246ed 100644 --- a/rust/src/hal/v3_hal.rs +++ b/rust/src/hal/v3_hal.rs @@ -210,7 +210,7 @@ impl<'a> BoardInteraction<'a> for V3<'a> { &self.config } - fn get_battery_monitor(&mut self) -> &mut Box<(dyn BatteryInteraction + Send + 'static)> { + fn get_battery_monitor(&mut self) -> &mut Box { &mut self.battery_monitor } diff --git a/rust/src/hal/v4_hal.rs b/rust/src/hal/v4_hal.rs index ee508f4..9833191 100644 --- a/rust/src/hal/v4_hal.rs +++ b/rust/src/hal/v4_hal.rs @@ -13,7 +13,7 @@ use anyhow::bail; use embedded_hal::digital::OutputPin; use embedded_hal_bus::i2c::MutexDevice; use esp_idf_hal::gpio::{AnyInputPin, IOPin, InputOutput, Output, PinDriver, Pull}; -use esp_idf_hal::i2c::{I2cDriver, I2cError}; +use esp_idf_hal::i2c::I2cDriver; use esp_idf_hal::pcnt::{ PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex, }; @@ -23,12 +23,10 @@ use ina219::calibration::UnCalibrated; use ina219::configuration::{Configuration, OperatingMode}; use ina219::SyncIna219; use measurements::{Current, Resistance, Voltage}; -use pca9535::{ExpanderError, GPIOBank, Pca9535Immediate, StandardExpanderInterface}; +use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface}; use std::result::Result::Ok as OkStd; -use embedded_can::nb::Can; use embedded_can::Frame; use embedded_can::StandardId; -use esp_idf_hal::prelude::*; use esp_idf_hal::can; pub enum Charger<'a> { @@ -205,7 +203,7 @@ pub(crate) fn create_v4( println!("Can bus mode "); let timing = can::config::Timing::B25K; let config = can::config::Config::new().timing(timing); - let mut can = can::CanDriver::new(peripherals.can, peripherals.gpio0, peripherals.gpio2, &config).unwrap(); + let can = can::CanDriver::new(peripherals.can, peripherals.gpio0, peripherals.gpio2, &config).unwrap(); let frame = StandardId::new(0x042).unwrap(); diff --git a/rust/src/main.rs b/rust/src/main.rs index c21a625..344947e 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -93,14 +93,6 @@ pub struct PumpResult { pump_time_s: u16, } -#[derive(Serialize, Deserialize, Debug, PartialEq)] -/// humidity sensor error -enum SensorError { - Unknown, - ShortCircuit { hz: f32, max: f32 }, - OpenCircuit { hz: f32, min: f32 }, -} - #[derive(Serialize, Debug, PartialEq)] enum SntpMode { OFFLINE, @@ -867,7 +859,7 @@ fn pump_info( median_current_ma: u16, max_current_ma: u16, min_current_ma: u16, - error: bool, + _error: bool, ) { let pump_info = PumpInfo { enabled: pump_active, diff --git a/rust/src/plant_state.rs b/rust/src/plant_state.rs index ae57373..01cdbf2 100644 --- a/rust/src/plant_state.rs +++ b/rust/src/plant_state.rs @@ -238,7 +238,7 @@ impl PlantState { } PlantWateringMode::MinMoisture => { let (moisture_percent, _) = self.plant_moisture(); - if let Some(moisture_percent) = moisture_percent { + if let Some(_moisture_percent) = moisture_percent { if self.pump_in_timeout(plant_conf, current_time) { false } else if !in_time_range( @@ -247,10 +247,10 @@ impl PlantState { plant_conf.pump_hour_end, ) { false - } else if (true) { + } else if true { //if not cooldown min and below max true - } else if (true) { + } else if true { //if below min disable cooldown min true } else {