splitting wip

This commit is contained in:
2025-06-19 16:56:33 +02:00
parent c429c829b4
commit fc1991523a
9 changed files with 1553 additions and 1675 deletions

View File

@@ -116,12 +116,12 @@ impl PlantState {
plant_id: usize,
board: &mut HAL
) -> Self {
let sensor_a = if board.config.plants[plant_id].sensor_a {
match board.measure_moisture_hz(plant_id, Sensor::A) {
let sensor_a = if board.board_hal.get_config().plants[plant_id].sensor_a {
match board.board_hal.measure_moisture_hz(plant_id, Sensor::A) {
Ok(raw) => match map_range_moisture(
raw,
board.config.plants[plant_id].moisture_sensor_min_frequency,
board.config.plants[plant_id].moisture_sensor_max_frequency,
board.board_hal.get_config().plants[plant_id].moisture_sensor_min_frequency,
board.board_hal.get_config().plants[plant_id].moisture_sensor_max_frequency,
) {
Ok(moisture_percent) => MoistureSensorState::MoistureValue {
raw_hz: raw,
@@ -137,12 +137,12 @@ impl PlantState {
MoistureSensorState::Disabled
};
let sensor_b = if board.config.plants[plant_id].sensor_b {
match board.measure_moisture_hz(plant_id, Sensor::B) {
let sensor_b = if board.board_hal.get_config().plants[plant_id].sensor_b {
match board.board_hal.measure_moisture_hz(plant_id, Sensor::B) {
Ok(raw) => match map_range_moisture(
raw,
board.config.plants[plant_id].moisture_sensor_min_frequency,
board.config.plants[plant_id].moisture_sensor_max_frequency,
board.board_hal.get_config().plants[plant_id].moisture_sensor_min_frequency,
board.board_hal.get_config().plants[plant_id].moisture_sensor_max_frequency,
) {
Ok(moisture_percent) => MoistureSensorState::MoistureValue {
raw_hz: raw,
@@ -158,8 +158,8 @@ impl PlantState {
MoistureSensorState::Disabled
};
let previous_pump = board.last_pump_time(plant_id);
let consecutive_pump_count = board.consecutive_pump_count(plant_id);
let previous_pump = board.board_hal.get_esp().last_pump_time(plant_id);
let consecutive_pump_count = board.board_hal.get_esp().consecutive_pump_count(plant_id);
let state = Self {
sensor_a,
sensor_b,
@@ -169,7 +169,7 @@ impl PlantState {
},
};
if state.is_err() {
let _ = board.fault(plant_id, true);
let _ = board.board_hal.fault(plant_id, true);
}
state
}