webfix for sensora enable, ina start
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user