fix pinnames
This commit is contained in:
parent
60947059e8
commit
fe4b57808d
@ -204,6 +204,7 @@ pub struct PlantCtrlBoard<'a> {
|
|||||||
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
>,
|
>,
|
||||||
|
shift_register_enable_invert: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Output>,
|
||||||
tank_channel: AdcChannelDriver<'a, Gpio5, AdcDriver<'a, esp_idf_hal::adc::ADC1>>,
|
tank_channel: AdcChannelDriver<'a, Gpio5, AdcDriver<'a, esp_idf_hal::adc::ADC1>>,
|
||||||
solar_is_day: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
solar_is_day: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
||||||
boot_button: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
boot_button: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
||||||
@ -403,7 +404,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
|
|||||||
self.signal_counter.counter_pause()?;
|
self.signal_counter.counter_pause()?;
|
||||||
self.signal_counter.counter_clear()?;
|
self.signal_counter.counter_clear()?;
|
||||||
//Disable all
|
//Disable all
|
||||||
self.shift_register.decompose()[SENSOR_ON]
|
self.shift_register.decompose()[MS_4]
|
||||||
.set_high()
|
.set_high()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -435,9 +436,12 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
|
|||||||
|
|
||||||
self.sensor_multiplexer(sensor_channel)?;
|
self.sensor_multiplexer(sensor_channel)?;
|
||||||
|
|
||||||
self.shift_register.decompose()[SENSOR_ON]
|
self.shift_register.decompose()[MS_4]
|
||||||
.set_low()
|
.set_low()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
self.shift_register.decompose()[SENSOR_ON]
|
||||||
|
.set_high()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let delay = Delay::new_default();
|
let delay = Delay::new_default();
|
||||||
let measurement = 100;
|
let measurement = 100;
|
||||||
@ -448,9 +452,12 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
|
|||||||
self.signal_counter.counter_resume()?;
|
self.signal_counter.counter_resume()?;
|
||||||
delay.delay_ms(measurement);
|
delay.delay_ms(measurement);
|
||||||
self.signal_counter.counter_pause()?;
|
self.signal_counter.counter_pause()?;
|
||||||
self.shift_register.decompose()[SENSOR_ON]
|
self.shift_register.decompose()[MS_4]
|
||||||
.set_high()
|
.set_high()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
self.shift_register.decompose()[SENSOR_ON]
|
||||||
|
.set_low()
|
||||||
|
.unwrap();
|
||||||
let unscaled = self.signal_counter.get_counter_value()? as i32;
|
let unscaled = self.signal_counter.get_counter_value()? as i32;
|
||||||
let hz = (unscaled as f32 * factor) as i32;
|
let hz = (unscaled as f32 * factor) as i32;
|
||||||
println!("Measuring {:?} @ {} with {}", sensor, plant, hz);
|
println!("Measuring {:?} @ {} with {}", sensor, plant, hz);
|
||||||
@ -1108,8 +1115,15 @@ impl CreatePlantHal<'_> for PlantHal {
|
|||||||
one_wire_pin.set_pull(Pull::Floating).unwrap();
|
one_wire_pin.set_pull(Pull::Floating).unwrap();
|
||||||
|
|
||||||
//disable all
|
//disable all
|
||||||
|
let ms1 = &mut shift_register.decompose()[MS_1];
|
||||||
|
ms1.set_low()?;
|
||||||
|
let ms2 = &mut shift_register.decompose()[MS_2];
|
||||||
|
ms2.set_low()?;
|
||||||
|
let ms3 = &mut shift_register.decompose()[MS_3];
|
||||||
|
ms3.set_low()?;
|
||||||
|
|
||||||
let ms4 = &mut shift_register.decompose()[MS_4];
|
let ms4 = &mut shift_register.decompose()[MS_4];
|
||||||
ms4.set_high()?;
|
ms4.set_low()?;
|
||||||
|
|
||||||
//init,reset rtc memory depending on cause
|
//init,reset rtc memory depending on cause
|
||||||
let reasons = ResetReason::get();
|
let reasons = ResetReason::get();
|
||||||
@ -1222,6 +1236,7 @@ impl CreatePlantHal<'_> for PlantHal {
|
|||||||
let mut general_fault = PinDriver::input_output(peripherals.pins.gpio6.downgrade())?;
|
let mut general_fault = PinDriver::input_output(peripherals.pins.gpio6.downgrade())?;
|
||||||
general_fault.set_pull(Pull::Floating)?;
|
general_fault.set_pull(Pull::Floating)?;
|
||||||
general_fault.set_low()?;
|
general_fault.set_low()?;
|
||||||
|
|
||||||
let one_wire_bus = OneWire::new(one_wire_pin)
|
let one_wire_bus = OneWire::new(one_wire_pin)
|
||||||
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
|
||||||
@ -1233,8 +1248,13 @@ impl CreatePlantHal<'_> for PlantHal {
|
|||||||
} else {
|
} else {
|
||||||
println!("Managed to comunnicate with battery");
|
println!("Managed to comunnicate with battery");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut shift_register_enable_invert = PinDriver::output(peripherals.pins.gpio21.downgrade())?;
|
||||||
|
shift_register_enable_invert.set_low().unwrap();
|
||||||
|
|
||||||
let rv = Mutex::new(PlantCtrlBoard {
|
let rv = Mutex::new(PlantCtrlBoard {
|
||||||
shift_register,
|
shift_register,
|
||||||
|
shift_register_enable_invert,
|
||||||
tank_channel,
|
tank_channel,
|
||||||
solar_is_day,
|
solar_is_day,
|
||||||
boot_button,
|
boot_button,
|
||||||
|
Loading…
Reference in New Issue
Block a user