Skip to content
Snippets Groups Projects
Commit e93ce83a authored by TuxCoder's avatar TuxCoder
Browse files

fix pad 2 captouch

parent b3a86794
No related branches found
No related tags found
No related merge requests found
......@@ -221,10 +221,10 @@ impl<STATE, const S: usize> ConfigurationBuilder<STATE, S> {
stages[i] = ext_stage.0;
}
let mut calibration = [false; 12];
let mut low_int = [false; 12];
let mut high_int = [false; 12];
let mut conv_int = [false; 12];
let mut calibration = [false; 13];
let mut low_int = [false; 13];
let mut high_int = [false; 13];
let mut conv_int = [false; 13];
for (i, stage) in stages.iter().enumerate() {
calibration[i] = stage.global.calibration_enabled;
......@@ -330,7 +330,7 @@ pub enum CdcBias {
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct CalibrationEnable {
stages_enable: [bool; 12],
stages_enable: [bool; 13],
avg_fp_skip: FullPowerSkip,
avg_lp_skip: LowPowerSkip,
}
......@@ -431,7 +431,7 @@ pub enum PowerDownTimeout {
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct StageLowIntEnable {
stages_enable: [bool; 12],
stages_enable: [bool; 13],
gpio_setup: GpioSetup,
gpio_input_config: GpioInputConfig,
}
......@@ -474,7 +474,7 @@ pub enum GpioInputConfig {
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct StageHighIntEnable {
stages_enable: [bool; 12],
stages_enable: [bool; 13],
}
impl StageHighIntEnable {
......@@ -495,7 +495,7 @@ impl StageHighIntEnable {
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct StageCompleteIntEnable {
stages_enable: [bool; 12],
stages_enable: [bool; 13],
}
impl StageCompleteIntEnable {
......
......@@ -42,7 +42,7 @@ where
configuration: DeviceConfiguration<S>,
delay: &mut DELAY,
) -> Result<Ad7147<I2C, Initialized, S>, E> {
let mut data = [0u16; (12 * 8) + 1];
let mut data = [0u16; (13 * 8) + 1];
data[0] = 0x080;
for (i, stage) in configuration.0.stages.iter().enumerate() {
let data_idx = (i * 8) + 1;
......@@ -82,7 +82,7 @@ where
I2C: WriteRead<Error = E> + Write<Error = E>,
{
pub fn read_all_stages(&mut self) -> Result<[u16; S], E> {
let mut result = [0u8; 12 * 2];
let mut result = [0u8; 13 * 2];
self.i2c.write_read(
self.address,
to_be_array([STAGE_CONVERSION_RESULT_REGISTER]).as_byte_slice(),
......
......@@ -216,7 +216,7 @@ fn init_captouch(
i2c_top: I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>,
) -> Result<
(
Ad7147<I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>, Initialized, 12>,
Ad7147<I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>, Initialized, 13>,
Ad7147<I2cProxy<'static, XtensaMutex<I2C<'static, I2C0>>>, Initialized, 12>,
),
hal::i2c::Error,
......@@ -346,6 +346,16 @@ fn init_captouch(
})
.initial_offset_high(55000)
.build(),
StageConfiguration::builder()
.calibration_enabled(true)
.conversion_complete_interrupt_enabled(true)
.pos_afe_offset(26)
.add_input_connection(InputConnection {
cin: CapInput::CIN12,
cdc: CdcInput::Positive,
})
.initial_offset_high(55000)
.build(),
])
.build();
let ad7147_top = Ad7147::new(i2c_top, 0b00101100);
......@@ -560,7 +570,7 @@ async fn update_petals_top(interrupts: u16, measurements: [u16; 12]) {
}
}
static PETAL_MAPPPING_BOT: [(usize, PetalPosition); 12] = [
static PETAL_MAPPPING_BOT: [(usize, PetalPosition); 13] = [
(9, PetalPosition::BASE),
(9, PetalPosition::TIP),
(7, PetalPosition::BASE),
......@@ -573,12 +583,13 @@ static PETAL_MAPPPING_BOT: [(usize, PetalPosition); 12] = [
(1, PetalPosition::TIP),
(2, PetalPosition::BASE),
(2, PetalPosition::CW),
(2, PetalPosition::CCW),
];
async fn update_petals_bot(interrupts: u16, measurements: [u16; 12]) {
async fn update_petals_bot(interrupts: u16, measurements: [u16; 13]) {
let mut petals = PETALS.lock().await;
for (i, m) in PETAL_MAPPPING_BOT.iter().enumerate() {
let pressed = measurements[i] > 40000;
let pressed = measurements[i] > 50000;
match petals[m.0] {
Flow3rPetal::TOP {
ref mut ccw,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment