Compare commits

..

No commits in common. "4f4d15e4a42ed39e7f3aa327c2e76cf39eba9e06" and "171b130a2929c185cd2a0e5e9abaed934551cb70" have entirely different histories.

5 changed files with 21 additions and 29 deletions

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use crate::{config::PlantConfig, in_time_range, plant_hal}; use crate::{config::PlantConfig, in_time_range, plant_hal};
const MOIST_SENSOR_MAX_FREQUENCY: f32 = 7500.; // 60kHz (500Hz margin) const MOIST_SENSOR_MAX_FREQUENCY: f32 = 6500.; // 60kHz (500Hz margin)
const MOIST_SENSOR_MIN_FREQUENCY: f32 = 150.; // this is really, really dry, think like cactus levels const MOIST_SENSOR_MIN_FREQUENCY: f32 = 150.; // this is really, really dry, think like cactus levels
#[derive(Debug, PartialEq, Serialize)] #[derive(Debug, PartialEq, Serialize)]

View File

@ -80,7 +80,7 @@ impl TankState {
} }
pub fn is_enabled(&self) -> bool { pub fn is_enabled(&self) -> bool {
!matches!(self, TankState::Disabled) matches!(self, TankState::Disabled)
} }
pub fn warn_level(&self, config: &TankConfig) -> Result<bool, TankError> { pub fn warn_level(&self, config: &TankConfig) -> Result<bool, TankError> {

View File

@ -21,7 +21,6 @@ use std::{
use url::Url; use url::Url;
use crate::config::PlantControllerConfig; use crate::config::PlantControllerConfig;
use crate::plant_state::MoistureSensorState;
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
struct SSIDList<'a> { struct SSIDList<'a> {
@ -36,8 +35,8 @@ struct LoadData<'a> {
#[derive(Serialize, Debug)] #[derive(Serialize, Debug)]
struct Moistures { struct Moistures {
moisture_a: Vec<std::string::String>, moisture_a: Vec<Option<f32>>,
moisture_b: Vec<std::string::String>, moisture_b: Vec<Option<f32>>,
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@ -123,28 +122,12 @@ fn get_live_moisture(
let a = Vec::from_iter( let a = Vec::from_iter(
plant_state plant_state
.iter() .iter()
.map(|s| { .map(|s| s.sensor_a.moisture_percent().map(|f| f.to_precision(2))),
match &s.sensor_a {
MoistureSensorState::Disabled => "disabled".to_string(),
MoistureSensorState::MoistureValue {raw_hz, moisture_percent } => {
format!("{moisture_percent:.2}% {raw_hz}hz",)
}
MoistureSensorState::SensorError(err) => format!("{err:?}"),
}
})
); );
let b = Vec::from_iter( let b = Vec::from_iter(
plant_state plant_state
.iter() .iter()
.map(|s| { .map(|s| s.sensor_b.moisture_percent().map(|f| f.to_precision(2))),
match &s.sensor_b {
MoistureSensorState::Disabled => "disabled".to_string(),
MoistureSensorState::MoistureValue {raw_hz, moisture_percent } => {
format!("{moisture_percent:.2}% {raw_hz}hz",)
}
MoistureSensorState::SensorError(err) => format!("{err:?}"),
}
})
); );
let data = Moistures { let data = Moistures {

View File

@ -106,8 +106,8 @@ interface GetTime {
} }
interface Moistures { interface Moistures {
moisture_a: [string], moisture_a: [number],
moisture_b: [string], moisture_b: [number],
} }
interface VersionInfo { interface VersionInfo {

View File

@ -24,7 +24,7 @@ export class PlantViews {
} }
return rv return rv
} }
update(moisture_a: [string], moisture_b: [string]) { update(moisture_a: [number], moisture_b: [number]) {
for (let plantId = 0; plantId < PLANT_COUNT; plantId++) { for (let plantId = 0; plantId < PLANT_COUNT; plantId++) {
const a = moisture_a[plantId] const a = moisture_a[plantId]
const b = moisture_b[plantId] const b = moisture_b[plantId]
@ -150,9 +150,18 @@ export class PlantView {
}; };
} }
update(a: string, b: string) { update(a: number, b: number) {
this.moistureA.innerText = a if (a == 200){
this.moistureB.innerText = b this.moistureA.innerText = "error"
} else {
this.moistureA.innerText = String(a)
}
if (b == 200){
this.moistureB.innerText = "error"
} else {
this.moistureB.innerText = String(b)
}
} }
setConfig(plantConfig: PlantConfig) { setConfig(plantConfig: PlantConfig) {