Merge branch 'feature/board-hal-splitting' into develop

This commit is contained in:
Empire Phoenix 2025-06-20 02:59:37 +02:00
commit c84e863d0f
4 changed files with 27 additions and 2 deletions

View File

@ -85,6 +85,7 @@ strum_macros = "0.27.0"
esp-ota = { version = "0.2.2", features = ["log"] }
unit-enum = "1.4.1"
pca9535 = { version = "2.0.0", features = ["std"] }
ina219 = { version = "0.2.0", features = ["std"] }
[patch.crates-io]

View File

@ -26,6 +26,9 @@ use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, vTaskDelay, EspError};
use one_wire_bus::OneWire;
use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
use std::result::Result::Ok as OkStd;
use ina219::address::Address;
use ina219::calibration::{Calibration, UnCalibrated};
use ina219::SyncIna219;
const MS0: u8 = 1_u8;
const MS1: u8 = 0_u8;
@ -35,6 +38,7 @@ const MS4: u8 = 2_u8;
const SENSOR_ON: u8 = 5_u8;
pub struct V4<'a> {
mppt_ina: SyncIna219<MutexDevice<'a, I2cDriver<'a>>, UnCalibrated>,
esp: ESP<'a>,
battery_monitor: Box<dyn BatteryInteraction + Send>,
config: PlantControllerConfig,
@ -169,7 +173,17 @@ pub(crate) fn create_v4(
let _ = sensor_expander.pin_set_low(GPIOBank::Bank1, pin);
}
let mut mppt_ina = SyncIna219::new(MutexDevice::new(&I2C_DRIVER), Address::from_byte(68)?)?;
esp.delay.delay_ms(mppt_ina.configuration()?.conversion_time().unwrap().as_millis() as u32);
println!("Bus Voltage: {}", mppt_ina.bus_voltage()?);
println!("Shunt Voltage: {}", mppt_ina.shunt_voltage()?);
let volt = (mppt_ina.shunt_voltage()?.shunt_voltage_mv()) as f32 / 1000_f32;
let current = volt /0.05;
println!("Shunt Current: {}", current);
let v = V4 {
mppt_ina,
esp,
awake,
tank_channel,

View File

@ -71,6 +71,10 @@
<input class="plantvalue" id="plant_${plantId}_max_frequency" type="number" min="1000" max="25000" >
</div>
<div class="flexcontainer">
<div class="plantkey">Sensor A installed:</div>
<input class="plantcheckbox" id="plant_${plantId}_sensor_a" type="checkbox">
</div>
<div class="flexcontainer">
<div class="plantkey">Sensor B installed:</div>
<input class="plantcheckbox" id="plant_${plantId}_sensor_b" type="checkbox">

View File

@ -55,6 +55,7 @@ export class PlantView {
private readonly pumpCooldown: HTMLInputElement;
private readonly pumpHourStart: HTMLSelectElement;
private readonly pumpHourEnd: HTMLSelectElement;
private readonly sensorAInstalled: HTMLInputElement;
private readonly sensorBInstalled: HTMLInputElement;
private readonly mode: HTMLSelectElement;
private readonly moistureA: HTMLElement;
@ -128,6 +129,11 @@ export class PlantView {
this.pumpHourEnd.appendChild(option);
}
this.sensorAInstalled = document.getElementById("plant_"+plantId+"_sensor_a") as HTMLInputElement;
this.sensorAInstalled.onchange = function(){
controller.configChanged()
}
this.sensorBInstalled = document.getElementById("plant_"+plantId+"_sensor_b") as HTMLInputElement;
this.sensorBInstalled.onchange = function(){
controller.configChanged()
@ -165,6 +171,7 @@ export class PlantView {
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
this.sensorBInstalled.checked = plantConfig.sensor_b;
this.sensorAInstalled.checked = plantConfig.sensor_a;
this.maxConsecutivePumpCount.value = plantConfig.max_consecutive_pump_count.toString();
// Set new fields
@ -176,8 +183,6 @@ export class PlantView {
getConfig(): PlantConfig {
return {
// hardcoded for now
sensor_a: true,
mode: this.mode.value,
target_moisture: this.targetMoisture.valueAsNumber,
pump_time_s: this.pumpTimeS.valueAsNumber,
@ -185,6 +190,7 @@ export class PlantView {
pump_hour_start: +this.pumpHourStart.value,
pump_hour_end: +this.pumpHourEnd.value,
sensor_b: this.sensorBInstalled.checked,
sensor_a: this.sensorAInstalled.checked,
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber,
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || null,
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || null