Merge branch 'feature/v4_modular' into develop

# Conflicts:
#	rust/src/config.rs
#	rust/src/main.rs
#	rust/src/tank.rs
This commit is contained in:
2025-06-18 19:07:24 +02:00
66 changed files with 2368449 additions and 199754 deletions

View File

@@ -63,14 +63,10 @@ one-wire-bus = "0.1.1"
ds323x = "0.6.0"
#pure code dependencies
log = { version = "0.4", default-features = false }
once_cell = "1.19.0"
anyhow = { version = "1.0.75", features = ["std", "backtrace"] }
average = { version = "0.14.1" , features = ["std"] }
bit_field = "0.10.2"
strum = { version = "0.27.0", features = ["derive"] }
measurements = "0.11.0"
schemars = "0.8.16"
#json
serde = { version = "1.0.192", features = ["derive"] }

View File

@@ -1,6 +1,9 @@
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use chrono_tz::{Europe::Berlin, Tz};
use std::str::FromStr;
use crate::plant_state::PlantWateringMode;
use crate::PLANT_COUNT;
@@ -12,7 +15,8 @@ pub struct NetworkConfig {
pub password: Option<heapless::String<64>>,
pub mqtt_url: Option<heapless::String<128>>,
pub base_topic: Option<heapless::String<64>>,
pub max_wait: u32
pub max_wait: u32,
pub timezone: heapless::String<64>,
}
impl Default for NetworkConfig {
fn default() -> Self {
@@ -23,6 +27,7 @@ impl Default for NetworkConfig {
mqtt_url: None,
base_topic: None,
max_wait: 10000,
timezone: heapless::String::from_str("Europe/Berlin").unwrap(),
}
}
}

View File

@@ -31,6 +31,15 @@ use crate::plant_hal::{BatteryInteraction, BoardHal, BoardInteraction, HAL};
use plant_state::PlantState;
use tank::*;
const MOIST_SENSOR_MAX_FREQUENCY: u32 = 6500; // 60kHz (500Hz margin)
const MOIST_SENSOR_MIN_FREQUENCY: u32 = 150; // this is really really dry, think like cactus levels
const FROM: (f32, f32) = (
MOIST_SENSOR_MIN_FREQUENCY as f32,
MOIST_SENSOR_MAX_FREQUENCY as f32,
);
const TO: (f32, f32) = (0_f32, 100_f32);
pub static BOARD_ACCESS: Lazy<Mutex<HAL>> = Lazy::new(|| PlantHal::create().unwrap());
pub static STAY_ALIVE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
@@ -386,6 +395,7 @@ fn safe_main() -> anyhow::Result<()> {
board.any_pump(false)?; // disable main power output, eg for a central pump with valve setup or a main water valve for the risk affine
}
}
update_plant_state(&mut plantstate, &mut board, &config, &timezone_time.timezone());
let is_day = board.is_day();
let state_of_charge = board.battery_monitor.state_charge_percent().unwrap_or(0);
@@ -454,6 +464,10 @@ fn safe_main() -> anyhow::Result<()> {
};
let _ = board.mqtt_publish( "/state", "sleep".as_bytes());
//determine next event
//is light out of work trigger soon?
//is battery low ??
//is deep sleep
mark_app_valid();
let stay_alive_mqtt = STAY_ALIVE.load(std::sync::atomic::Ordering::Relaxed);
@@ -734,4 +748,4 @@ struct VersionInfo {
git_hash: String,
build_time: String,
partition: String,
}
}

View File

@@ -321,6 +321,8 @@ fn ota(
let read = request.read(&mut buffer)?;
total_read += read;
let to_write = &buffer[0..read];
//delay for watchdog and wifi stuff
Delay::new_default().delay_ms(1);
let iter = (total_read / 1024) % 8;
if iter != lastiter {