Refactor plant state handling and moisture interpretation
- Replaced `read_hardware_state` with `interpret_raw_values` for better abstraction and clarity. - Enhanced error handling by introducing `NoMessage` and `NotExpectedMessage` states. - Updated moisture sensor logic to differentiate expected and unexpected messages. - Renamed and refactored enum fields for consistency (`raw_hz` to `hz`). - Minor imports and formatting optimizations.
This commit is contained in:
@@ -385,14 +385,14 @@ async fn safe_main(spawner: Spawner) -> FatResult<()> {
|
||||
let moisture = board.board_hal.measure_moisture_hz().await?;
|
||||
|
||||
let plantstate: [PlantState; PLANT_COUNT] = [
|
||||
PlantState::read_hardware_state(moisture, 0, &mut board).await,
|
||||
PlantState::read_hardware_state(moisture, 1, &mut board).await,
|
||||
PlantState::read_hardware_state(moisture, 2, &mut board).await,
|
||||
PlantState::read_hardware_state(moisture, 3, &mut board).await,
|
||||
PlantState::read_hardware_state(moisture, 4, &mut board).await,
|
||||
PlantState::read_hardware_state(moisture, 5, &mut board).await,
|
||||
PlantState::read_hardware_state(moisture, 6, &mut board).await,
|
||||
PlantState::read_hardware_state(moisture, 7, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 0, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 1, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 2, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 3, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 4, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 5, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 6, &mut board).await,
|
||||
PlantState::interpret_raw_values(moisture, 7, &mut board).await,
|
||||
];
|
||||
|
||||
publish_plant_states(&mut board, &timezone_time.clone(), &plantstate)
|
||||
|
||||
Reference in New Issue
Block a user