combine all branches

This commit is contained in:
2025-06-19 13:05:47 +02:00
parent 751f07e6fd
commit e2cce88390
9 changed files with 939 additions and 909 deletions

View File

@@ -2,8 +2,8 @@ use chrono::{DateTime, TimeDelta, Utc};
use chrono_tz::Tz;
use serde::{Deserialize, Serialize};
use crate::{config::PlantConfig, in_time_range, plant_hal};
use crate::plant_hal::BoardInteraction;
use crate::{config::PlantConfig, in_time_range};
use crate::hal::{BoardInteraction, Sensor, HAL};
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
@@ -114,10 +114,10 @@ fn map_range_moisture(
impl PlantState {
pub fn read_hardware_state(
plant_id: usize,
board: &mut plant_hal::HAL
board: &mut HAL
) -> Self {
let sensor_a = if board.config.plants[plant_id].sensor_a {
match board.measure_moisture_hz(plant_id, plant_hal::Sensor::A) {
match board.measure_moisture_hz(plant_id, Sensor::A) {
Ok(raw) => match map_range_moisture(
raw,
board.config.plants[plant_id].moisture_sensor_min_frequency,
@@ -138,7 +138,7 @@ impl PlantState {
};
let sensor_b = if board.config.plants[plant_id].sensor_b {
match board.measure_moisture_hz(plant_id, plant_hal::Sensor::B) {
match board.measure_moisture_hz(plant_id, Sensor::B) {
Ok(raw) => match map_range_moisture(
raw,
board.config.plants[plant_id].moisture_sensor_min_frequency,