allow startup with initial board mode and nearly no pin configs

This commit is contained in:
2025-06-11 22:08:59 +02:00
parent a9d7936376
commit 6499b18ada
8 changed files with 627 additions and 469 deletions

View File

@@ -114,15 +114,14 @@ fn map_range_moisture(
impl PlantState {
pub fn read_hardware_state(
plant_id: usize,
board: &mut plant_hal::HAL,
config: &PlantConfig,
board: &mut plant_hal::HAL
) -> Self {
let sensor_a = if config.sensor_a {
let sensor_a = if board.config.plants[plant_id].sensor_a {
match board.measure_moisture_hz(plant_id, plant_hal::Sensor::A) {
Ok(raw) => match map_range_moisture(
raw,
config.moisture_sensor_min_frequency,
config.moisture_sensor_max_frequency,
board.config.plants[plant_id].moisture_sensor_min_frequency,
board.config.plants[plant_id].moisture_sensor_max_frequency,
) {
Ok(moisture_percent) => MoistureSensorState::MoistureValue {
raw_hz: raw,
@@ -138,12 +137,12 @@ impl PlantState {
MoistureSensorState::Disabled
};
let sensor_b = if config.sensor_b {
let sensor_b = if board.config.plants[plant_id].sensor_b {
match board.measure_moisture_hz(plant_id, plant_hal::Sensor::B) {
Ok(raw) => match map_range_moisture(
raw,
config.moisture_sensor_min_frequency,
config.moisture_sensor_max_frequency,
board.config.plants[plant_id].moisture_sensor_min_frequency,
board.config.plants[plant_id].moisture_sensor_max_frequency,
) {
Ok(moisture_percent) => MoistureSensorState::MoistureValue {
raw_hz: raw,