fix all compiler warnings

This commit is contained in:
ju6ge 2025-06-20 20:36:29 +02:00
parent c1d0ce542c
commit 7115809f2b
Signed by: judge
GPG Key ID: 6512C30DD8E017B5
9 changed files with 84 additions and 88 deletions

View File

@ -1,4 +1,3 @@
use crate::to_string;
use anyhow::anyhow;
use bq34z100::{Bq34Z100Error, Bq34z100g1, Bq34z100g1Driver};
use embedded_hal_bus::i2c::MutexDevice;

View File

@ -1,7 +1,9 @@
use crate::config::{BoardHardware, PlantControllerConfig};
use crate::hal::battery::{BatteryInteraction, NoBatteryMonitor};
use crate::hal::esp::ESP;
use crate::hal::{deep_sleep, BackupHeader, BoardInteraction, FreePeripherals, Sensor};
use crate::{
config::PlantControllerConfig,
hal::battery::{BatteryInteraction, NoBatteryMonitor},
};
use anyhow::{bail, Result};
use chrono::{DateTime, Utc};
use embedded_hal::digital::OutputPin;

View File

@ -4,54 +4,45 @@ mod initial_hal;
mod v3_hal;
mod v4_hal;
use crate::{
config::{BatteryBoardVersion, BoardVersion, PlantControllerConfig},
hal::{
battery::{print_battery_bq34z100, BatteryInteraction, NoBatteryMonitor},
esp::ESP,
},
log::{log, LogMessage},
};
use anyhow::{Ok, Result};
use battery::BQ34Z100G1;
use bq34z100::Bq34z100g1Driver;
use crate::log::LogMessage;
use ds323x::DateTimeAccess;
use esp_ota::mark_app_valid;
use eeprom24x::Eeprom24xTrait;
use chrono::{DateTime, Utc};
use embedded_hal_bus::i2c::MutexDevice;
use esp_idf_hal::adc::ADC1;
use esp_idf_hal::i2c::{APBTickType, I2cConfig, I2cDriver};
use esp_idf_hal::units::FromValueType;
use esp_idf_svc::eventloop::EspSystemEventLoop;
use esp_idf_svc::nvs::EspDefaultNvsPartition;
use esp_idf_svc::wifi::EspWifi;
use esp_idf_sys::esp_restart;
use esp_idf_hal::{
adc::ADC1,
delay::Delay,
gpio::{
Gpio0, Gpio1, Gpio10, Gpio11, Gpio12, Gpio13, Gpio14, Gpio15, Gpio16, Gpio17, Gpio18,
Gpio2, Gpio21, Gpio22, Gpio23, Gpio24, Gpio25, Gpio26, Gpio27, Gpio28, Gpio29, Gpio3,
Gpio30, Gpio4, Gpio5, Gpio6, Gpio7, Gpio8, IOPin, PinDriver, Pull,
},
i2c::{APBTickType, I2cConfig, I2cDriver},
pcnt::PCNT0,
prelude::Peripherals,
reset::ResetReason,
units::FromValueType,
};
use esp_idf_svc::{eventloop::EspSystemEventLoop, nvs::EspDefaultNvsPartition, wifi::EspWifi};
use esp_idf_sys::{
esp_deep_sleep, esp_sleep_enable_ext1_wakeup,
esp_deep_sleep, esp_restart, esp_sleep_enable_ext1_wakeup,
esp_sleep_ext1_wakeup_mode_t_ESP_EXT1_WAKEUP_ANY_LOW,
};
use esp_ota::mark_app_valid;
use once_cell::sync::Lazy;
use anyhow::{Ok, Result};
use serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};
use std::result::Result::Ok as OkStd;
use std::sync::Mutex;
use std::time::Duration;
use crate::config::{BatteryBoardVersion, BoardVersion, PlantControllerConfig};
use crate::hal::battery::{print_battery_bq34z100, BatteryInteraction, NoBatteryMonitor};
use crate::hal::esp::ESP;
use crate::hal::initial_hal::Initial;
use crate::log::log;
use embedded_hal::digital::OutputPin;
use esp_idf_hal::delay::Delay;
use esp_idf_hal::gpio::{
Gpio0, Gpio1, Gpio10, Gpio11, Gpio12, Gpio13, Gpio14, Gpio15, Gpio16, Gpio17, Gpio18, Gpio2,
Gpio21, Gpio22, Gpio23, Gpio24, Gpio25, Gpio26, Gpio27, Gpio28, Gpio29, Gpio3, Gpio30, Gpio4,
Gpio5, Gpio6, Gpio7, Gpio8, IOPin, PinDriver, Pull,
};
use esp_idf_hal::pcnt::PCNT0;
use esp_idf_hal::prelude::Peripherals;
use esp_idf_hal::reset::ResetReason;
use pca9535::StandardExpanderInterface;
//Only support for 8 right now!
pub const PLANT_COUNT: usize = 8;
const REPEAT_MOIST_MEASURE: usize = 1;

View File

@ -1,11 +1,12 @@
use crate::config::PlantControllerConfig;
use crate::hal::battery::BatteryInteraction;
use crate::hal::esp::ESP;
use crate::hal::{
deep_sleep, BackupHeader, BoardInteraction, FreePeripherals, Sensor, V3Constants, I2C_DRIVER,
PLANT_COUNT, REPEAT_MOIST_MEASURE, TANK_MULTI_SAMPLE, X25,
deep_sleep, BackupHeader, BoardInteraction, FreePeripherals, Sensor, I2C_DRIVER, PLANT_COUNT,
REPEAT_MOIST_MEASURE, TANK_MULTI_SAMPLE, X25,
};
use crate::log::{log, LogMessage};
use crate::{
config::PlantControllerConfig,
hal::{battery::BatteryInteraction, esp::ESP},
};
use anyhow::{anyhow, bail, Ok, Result};
use chrono::{DateTime, Utc};
use ds18b20::Ds18b20;
@ -13,20 +14,21 @@ use ds323x::{DateTimeAccess, Ds323x};
use eeprom24x::{Eeprom24x, Eeprom24xTrait, SlaveAddr};
use embedded_hal::digital::OutputPin;
use embedded_hal_bus::i2c::MutexDevice;
use esp_idf_hal::adc::oneshot::config::AdcChannelConfig;
use esp_idf_hal::adc::oneshot::{AdcChannelDriver, AdcDriver};
use esp_idf_hal::adc::{attenuation, Resolution};
use esp_idf_hal::delay::Delay;
use esp_idf_hal::gpio::{AnyInputPin, Gpio5, IOPin, InputOutput, PinDriver, Pull};
use esp_idf_hal::i2c::I2cDriver;
use esp_idf_hal::pcnt::{
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
use esp_idf_hal::{
adc::{
attenuation,
oneshot::{config::AdcChannelConfig, AdcChannelDriver, AdcDriver},
Resolution,
},
delay::Delay,
gpio::{AnyInputPin, Gpio5, IOPin, InputOutput, PinDriver, Pull},
i2c::I2cDriver,
pcnt::{PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex},
};
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, vTaskDelay, EspError};
use one_wire_bus::OneWire;
use plant_ctrl2::sipo::ShiftRegister40;
use std::result::Result::Ok as OkStd;
use std::sync::Arc;
const PUMP8_BIT: usize = 0;
const PUMP1_BIT: usize = 1;

View File

@ -1,4 +1,4 @@
use crate::config::PlantControllerConfig;
pub use crate::config::PlantControllerConfig;
use crate::hal::battery::BatteryInteraction;
use crate::hal::esp::ESP;
use crate::hal::{
@ -13,19 +13,19 @@ use ds323x::{DateTimeAccess, Ds323x};
use eeprom24x::{Eeprom24x, Eeprom24xTrait, SlaveAddr};
use embedded_hal::digital::OutputPin;
use embedded_hal_bus::i2c::MutexDevice;
use esp_idf_hal::adc::oneshot::config::AdcChannelConfig;
use esp_idf_hal::adc::oneshot::{AdcChannelDriver, AdcDriver};
use esp_idf_hal::adc::{attenuation, Resolution};
use esp_idf_hal::delay::Delay;
use esp_idf_hal::gpio::{AnyInputPin, Gpio5, IOPin, InputOutput, Output, PinDriver, Pull};
use esp_idf_hal::i2c::I2cDriver;
use esp_idf_hal::pcnt::{
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
use esp_idf_hal::{
adc::{
attenuation,
oneshot::{config::AdcChannelConfig, AdcChannelDriver, AdcDriver},
Resolution,
},
delay::Delay,
gpio::{AnyInputPin, Gpio5, IOPin, InputOutput, Output, PinDriver, Pull},
i2c::I2cDriver,
pcnt::{PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex},
};
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, vTaskDelay, EspError};
use ina219::address::Address;
use ina219::calibration::{Calibration, UnCalibrated};
use ina219::SyncIna219;
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, EspError};
use ina219::{address::Address, calibration::UnCalibrated, SyncIna219};
use one_wire_bus::OneWire;
use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
use std::result::Result::Ok as OkStd;

View File

@ -1,8 +1,11 @@
use crate::webserver::webserver::httpd;
use crate::{
config::BoardVersion::INITIAL,
hal::{PlantHal, HAL, PLANT_COUNT},
webserver::webserver::httpd,
};
use anyhow::bail;
use chrono::{DateTime, Datelike, Timelike, Utc};
use chrono_tz::Tz;
use chrono_tz::Tz::UTC;
use chrono_tz::Tz::{self, UTC};
use esp_idf_hal::delay::Delay;
use esp_idf_sys::{
esp_ota_get_app_partition_count, esp_ota_get_running_partition, esp_ota_get_state_partition,
@ -15,23 +18,21 @@ use esp_ota::{mark_app_valid, rollback_and_reboot};
use hal::battery::BatteryState;
use log::{log, LogMessage};
use once_cell::sync::Lazy;
use plant_state::PlantState;
use serde::{Deserialize, Serialize};
use std::sync::MutexGuard;
use std::{
fmt::Display,
sync::{atomic::AtomicBool, Arc, Mutex},
};
use tank::*;
mod config;
mod hal;
mod log;
mod plant_state;
mod tank;
use crate::config::BoardVersion::INITIAL;
use crate::hal::battery::BatteryInteraction;
use crate::hal::{BoardInteraction, PlantHal, HAL, PLANT_COUNT};
use plant_state::PlantState;
use tank::*;
pub static BOARD_ACCESS: Lazy<Mutex<HAL>> = Lazy::new(|| PlantHal::create().unwrap());
pub static STAY_ALIVE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
@ -424,7 +425,7 @@ fn safe_main() -> anyhow::Result<()> {
.state_charge_percent()
.unwrap_or(0.);
/// try to load full battery state if failed the battery state is unknown
// try to load full battery state if failed the battery state is unknown
let battery_state = board
.board_hal
.get_battery_monitor()
@ -739,7 +740,8 @@ fn pump_info(
fn publish_battery_state(board: &mut MutexGuard<'_, HAL<'_>>) {
let state = board.board_hal.get_battery_monitor().get_battery_state();
if let Ok(serialized_battery_state_bytes) = serde_json::to_string(&state).map(|s| s.into_bytes())
if let Ok(serialized_battery_state_bytes) =
serde_json::to_string(&state).map(|s| s.into_bytes())
{
let _ = board
.board_hal

View File

@ -1,10 +1,12 @@
use crate::{
config::PlantConfig,
hal::{Sensor, HAL},
in_time_range,
};
use chrono::{DateTime, TimeDelta, Utc};
use chrono_tz::Tz;
use serde::{Deserialize, Serialize};
use crate::hal::{BoardInteraction, Sensor, HAL};
use crate::{config::PlantConfig, in_time_range};
const MOIST_SENSOR_MAX_FREQUENCY: f32 = 7500.; // 60kHz (500Hz margin)
const MOIST_SENSOR_MIN_FREQUENCY: f32 = 150.; // this is really, really dry, think like cactus levels

View File

@ -1,8 +1,6 @@
use crate::{config::TankConfig, hal::HAL};
use serde::Serialize;
use crate::config::TankConfig;
use crate::hal::{BoardInteraction, HAL};
const OPEN_TANK_VOLTAGE: f32 = 3.0;
pub const WATER_FROZEN_THRESH: f32 = 4.0;

View File

@ -1,8 +1,12 @@
//offer ota and config mode
use crate::hal::battery::BatteryInteraction;
use crate::{
determine_tank_state, get_version, log::LogMessage, plant_state::PlantState, BOARD_ACCESS,
config::PlantControllerConfig,
determine_tank_state, get_version,
hal::PLANT_COUNT,
log::LogMessage,
plant_state::{MoistureSensorState, PlantState},
BOARD_ACCESS,
};
use anyhow::bail;
use chrono::DateTime;
@ -19,10 +23,6 @@ use std::{
};
use url::Url;
use crate::config::PlantControllerConfig;
use crate::hal::{BoardInteraction, PLANT_COUNT};
use crate::plant_state::MoistureSensorState;
#[derive(Serialize, Debug)]
struct SSIDList<'a> {
ssids: Vec<&'a String<32>>,