we should be feature compatible with main version now!

This commit is contained in:
2025-09-30 22:37:45 +02:00
parent cfe23c8a09
commit cf58486cf5
5 changed files with 65 additions and 93 deletions

View File

@@ -18,6 +18,8 @@ use crate::hal::v4_sensor::{SensorImpl, SensorInteraction};
use crate::log::{LogMessage, LOG_ACCESS};
use esp_hal::gpio::{Flex, Input, InputConfig, Level, Output, OutputConfig, Pull};
use esp_hal::i2c::master::I2c;
use esp_hal::pcnt::channel::CtrlMode::Keep;
use esp_hal::pcnt::channel::EdgeMode::{Hold, Increment};
use esp_hal::pcnt::Pcnt;
use esp_hal::twai::{EspTwaiFrame, StandardId, TwaiMode};
use esp_println::println;
@@ -174,28 +176,18 @@ pub(crate) async fn create_v4(
let sensor = match sensor_expander.pin_into_output(GPIOBank::Bank0, 0) {
Ok(_) => {
log::info!("SensorExpander answered");
//pulse counter version
// let mut signal_counter = PcntDriver::new(
// peripherals.pcnt0,
// Some(peripherals.gpio22),
// Option::<AnyInputPin>::None,
// Option::<AnyInputPin>::None,
// Option::<AnyInputPin>::None,
// )?;
//
// signal_counter.channel_config(
// PcntChannel::Channel0,
// PinIndex::Pin0,
// PinIndex::Pin1,
// &PcntChannelConfig {
// lctrl_mode: PcntControlMode::Keep,
// hctrl_mode: PcntControlMode::Keep,
// pos_mode: PcntCountMode::Increment,
// neg_mode: PcntCountMode::Hold,
// counter_h_lim: i16::MAX,
// counter_l_lim: 0,
// },
// )?;
let signal_counter = peripherals.pcnt0;
signal_counter.set_low_limit(Some(0))?;
signal_counter.set_high_limit(Some(i16::MAX))?;
let ch0 = &signal_counter.channel0;
let edge_pin = Input::new(peripherals.gpio22, InputConfig::default());
ch0.set_edge_signal(edge_pin.peripheral_input());
ch0.set_input_mode(Hold, Increment);
ch0.set_ctrl_mode(Keep, Keep);
signal_counter.listen();
for pin in 0..8 {
let _ = sensor_expander.pin_into_output(GPIOBank::Bank0, pin);
@@ -205,7 +197,7 @@ pub(crate) async fn create_v4(
}
SensorImpl::PulseCounter {
// signal_counter,
signal_counter,
sensor_expander,
}
}
@@ -300,7 +292,6 @@ pub(crate) async fn create_v4(
tank_sensor,
light,
general_fault,
//pump_ina,
pump_expander,
config,
battery_monitor,