add initial flashing of batery and 3.1 adjustments
This commit is contained in:
@@ -30,7 +30,7 @@ mod config;
|
||||
pub mod espota;
|
||||
pub mod plant_hal;
|
||||
|
||||
const MOIST_SENSOR_MAX_FREQUENCY: u32 = 5200; // 60kHz (500Hz margin)
|
||||
const MOIST_SENSOR_MAX_FREQUENCY: u32 = 50000; // 60kHz (500Hz margin)
|
||||
const MOIST_SENSOR_MIN_FREQUENCY: u32 = 500; // 0.5kHz (500Hz margin)
|
||||
|
||||
const FROM: (f32, f32) = (
|
||||
@@ -73,7 +73,9 @@ struct LightState {
|
||||
#[derive(Debug, PartialEq, Default)]
|
||||
struct PlantState {
|
||||
a: Option<u8>,
|
||||
a_raw: Option<i32>,
|
||||
b: Option<u8>,
|
||||
b_raw: Option<i32>,
|
||||
consecutive_pump_count: u32,
|
||||
after_p: Option<u8>,
|
||||
do_water: bool,
|
||||
@@ -117,7 +119,9 @@ struct TankStateMQTT {
|
||||
#[derive(Serialize)]
|
||||
struct PlantStateMQTT<'a> {
|
||||
a: &'a str,
|
||||
a_raw: &'a str,
|
||||
b: &'a str,
|
||||
b_raw: &'a str,
|
||||
mode: &'a str,
|
||||
consecutive_pump_count: u32,
|
||||
dry: bool,
|
||||
@@ -657,6 +661,7 @@ fn determine_state_target_moisture_for_plant(
|
||||
}
|
||||
match board.measure_moisture_hz(plant, plant_hal::Sensor::A) {
|
||||
Ok(a) => {
|
||||
state.a_raw = Some(a);
|
||||
let mapped = map_range_moisture(a as f32);
|
||||
match mapped {
|
||||
Ok(result) => state.a = Some(result),
|
||||
@@ -672,6 +677,7 @@ fn determine_state_target_moisture_for_plant(
|
||||
if plant_config.sensor_b {
|
||||
match board.measure_moisture_hz(plant, plant_hal::Sensor::B) {
|
||||
Ok(b) => {
|
||||
state.b_raw = Some(b);
|
||||
let mapped = map_range_moisture(b as f32);
|
||||
match mapped {
|
||||
Ok(result) => state.b = Some(result),
|
||||
@@ -885,7 +891,9 @@ fn update_plant_state(
|
||||
&state.sensor_error_a,
|
||||
plant_config.mode != Mode::OFF,
|
||||
),
|
||||
a_raw: &state.a_raw.unwrap_or(0).to_string(),
|
||||
b: &sensor_to_string(&state.b, &state.sensor_error_b, plant_config.sensor_b),
|
||||
b_raw: &state.b_raw.unwrap_or(0).to_string(),
|
||||
active: state.active,
|
||||
mode: &mode,
|
||||
last_pump: &time_to_string_utc(board.last_pump_time(plant)),
|
||||
|
||||
Reference in New Issue
Block a user