webfix for sensora enable, ina start
This commit is contained in:
parent
3a2e59874e
commit
de54afce52
@ -85,6 +85,7 @@ strum_macros = "0.27.0"
|
|||||||
esp-ota = { version = "0.2.2", features = ["log"] }
|
esp-ota = { version = "0.2.2", features = ["log"] }
|
||||||
unit-enum = "1.4.1"
|
unit-enum = "1.4.1"
|
||||||
pca9535 = { version = "2.0.0", features = ["std"] }
|
pca9535 = { version = "2.0.0", features = ["std"] }
|
||||||
|
ina219 = { version = "0.2.0", features = ["std"] }
|
||||||
|
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
@ -26,6 +26,9 @@ use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, vTaskDelay, EspError};
|
|||||||
use one_wire_bus::OneWire;
|
use one_wire_bus::OneWire;
|
||||||
use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
|
use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
|
||||||
use std::result::Result::Ok as OkStd;
|
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 MS0: u8 = 1_u8;
|
||||||
const MS1: u8 = 0_u8;
|
const MS1: u8 = 0_u8;
|
||||||
@ -35,6 +38,7 @@ const MS4: u8 = 2_u8;
|
|||||||
const SENSOR_ON: u8 = 5_u8;
|
const SENSOR_ON: u8 = 5_u8;
|
||||||
|
|
||||||
pub struct V4<'a> {
|
pub struct V4<'a> {
|
||||||
|
mppt_ina: SyncIna219<MutexDevice<'a, I2cDriver<'a>>, UnCalibrated>,
|
||||||
esp: ESP<'a>,
|
esp: ESP<'a>,
|
||||||
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
||||||
config: PlantControllerConfig,
|
config: PlantControllerConfig,
|
||||||
@ -169,7 +173,17 @@ pub(crate) fn create_v4(
|
|||||||
let _ = sensor_expander.pin_set_low(GPIOBank::Bank1, pin);
|
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 {
|
let v = V4 {
|
||||||
|
mppt_ina,
|
||||||
esp,
|
esp,
|
||||||
awake,
|
awake,
|
||||||
tank_channel,
|
tank_channel,
|
||||||
|
@ -71,6 +71,10 @@
|
|||||||
<input class="plantvalue" id="plant_${plantId}_max_frequency" type="number" min="1000" max="25000" >
|
<input class="plantvalue" id="plant_${plantId}_max_frequency" type="number" min="1000" max="25000" >
|
||||||
</div>
|
</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="flexcontainer">
|
||||||
<div class="plantkey">Sensor B installed:</div>
|
<div class="plantkey">Sensor B installed:</div>
|
||||||
<input class="plantcheckbox" id="plant_${plantId}_sensor_b" type="checkbox">
|
<input class="plantcheckbox" id="plant_${plantId}_sensor_b" type="checkbox">
|
||||||
|
@ -55,6 +55,7 @@ export class PlantView {
|
|||||||
private readonly pumpCooldown: HTMLInputElement;
|
private readonly pumpCooldown: HTMLInputElement;
|
||||||
private readonly pumpHourStart: HTMLSelectElement;
|
private readonly pumpHourStart: HTMLSelectElement;
|
||||||
private readonly pumpHourEnd: HTMLSelectElement;
|
private readonly pumpHourEnd: HTMLSelectElement;
|
||||||
|
private readonly sensorAInstalled: HTMLInputElement;
|
||||||
private readonly sensorBInstalled: HTMLInputElement;
|
private readonly sensorBInstalled: HTMLInputElement;
|
||||||
private readonly mode: HTMLSelectElement;
|
private readonly mode: HTMLSelectElement;
|
||||||
private readonly moistureA: HTMLElement;
|
private readonly moistureA: HTMLElement;
|
||||||
@ -128,6 +129,11 @@ export class PlantView {
|
|||||||
this.pumpHourEnd.appendChild(option);
|
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 = document.getElementById("plant_"+plantId+"_sensor_b") as HTMLInputElement;
|
||||||
this.sensorBInstalled.onchange = function(){
|
this.sensorBInstalled.onchange = function(){
|
||||||
controller.configChanged()
|
controller.configChanged()
|
||||||
@ -165,6 +171,7 @@ export class PlantView {
|
|||||||
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
|
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
|
||||||
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
|
this.pumpHourEnd.value = plantConfig.pump_hour_end.toString();
|
||||||
this.sensorBInstalled.checked = plantConfig.sensor_b;
|
this.sensorBInstalled.checked = plantConfig.sensor_b;
|
||||||
|
this.sensorAInstalled.checked = plantConfig.sensor_a;
|
||||||
this.maxConsecutivePumpCount.value = plantConfig.max_consecutive_pump_count.toString();
|
this.maxConsecutivePumpCount.value = plantConfig.max_consecutive_pump_count.toString();
|
||||||
|
|
||||||
// Set new fields
|
// Set new fields
|
||||||
@ -176,8 +183,6 @@ export class PlantView {
|
|||||||
|
|
||||||
getConfig(): PlantConfig {
|
getConfig(): PlantConfig {
|
||||||
return {
|
return {
|
||||||
// hardcoded for now
|
|
||||||
sensor_a: true,
|
|
||||||
mode: this.mode.value,
|
mode: this.mode.value,
|
||||||
target_moisture: this.targetMoisture.valueAsNumber,
|
target_moisture: this.targetMoisture.valueAsNumber,
|
||||||
pump_time_s: this.pumpTimeS.valueAsNumber,
|
pump_time_s: this.pumpTimeS.valueAsNumber,
|
||||||
@ -185,6 +190,7 @@ export class PlantView {
|
|||||||
pump_hour_start: +this.pumpHourStart.value,
|
pump_hour_start: +this.pumpHourStart.value,
|
||||||
pump_hour_end: +this.pumpHourEnd.value,
|
pump_hour_end: +this.pumpHourEnd.value,
|
||||||
sensor_b: this.sensorBInstalled.checked,
|
sensor_b: this.sensorBInstalled.checked,
|
||||||
|
sensor_a: this.sensorAInstalled.checked,
|
||||||
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber,
|
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber,
|
||||||
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || null,
|
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || null,
|
||||||
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || null
|
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user