From 03d5c478ef990190c727c3cbb4e4d63a6323c300 Mon Sep 17 00:00:00 2001 From: Naxdy Date: Mon, 1 Apr 2024 23:03:08 +0200 Subject: [PATCH] change(config): remove notch adjustment logic (for now) --- Cargo.toml | 4 ++-- src/config.rs | 62 +++++++++++++-------------------------------------- src/input.rs | 3 ++- 3 files changed, 20 insertions(+), 49 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ccf65e3..dcd1b66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ codegen-units = 1 debug = 2 debug-assertions = true incremental = false -opt-level = 3 +opt-level = 1 lto = "fat" overflow-checks = true @@ -72,7 +72,7 @@ debug = 2 debug-assertions = false incremental = false lto = 'fat' -opt-level = 3 +opt-level = 1 overflow-checks = false # do not optimize proc-macro crates = faster builds from scratch diff --git a/src/config.rs b/src/config.rs index d74c27e..bbf49ea 100644 --- a/src/config.rs +++ b/src/config.rs @@ -19,7 +19,7 @@ use crate::{ }, stick::{ calc_stick_values, legalize_notches, AppliedCalibration, NotchStatus, CALIBRATION_ORDER, - NOTCH_ADJUSTMENT_ORDER, NO_OF_ADJ_NOTCHES, NO_OF_CALIBRATION_POINTS, NO_OF_NOTCHES, + NO_OF_CALIBRATION_POINTS, NO_OF_NOTCHES, }, ADDR_OFFSET, FLASH_SIZE, }; @@ -484,32 +484,6 @@ impl<'a> StickCalibrationProcess<'a> { } if self.calibration_step >= NO_OF_CALIBRATION_POINTS as u8 { - let mut notch_idx = NOTCH_ADJUSTMENT_ORDER[min( - self.calibration_step - NO_OF_CALIBRATION_POINTS as u8, - NO_OF_ADJ_NOTCHES as u8 - 1, - ) as usize]; - - while self.applied_calibration.cleaned_calibration.notch_status[notch_idx] - == NotchStatus::TertInactive - && self.calibration_step < NO_OF_CALIBRATION_POINTS as u8 + NO_OF_ADJ_NOTCHES as u8 - { - stick_config.angles = *legalize_notches( - self.calibration_step as usize, - &self.applied_calibration.measured_notch_angles, - &stick_config.angles.map(|e| *e), - ) - .to_packed_float_array(); - - self.calibration_step += 1; - - notch_idx = NOTCH_ADJUSTMENT_ORDER[min( - self.calibration_step - NO_OF_CALIBRATION_POINTS as u8, - NO_OF_ADJ_NOTCHES as u8 - 1, - ) as usize]; - } - } - - if self.calibration_step >= NO_OF_CALIBRATION_POINTS as u8 + NO_OF_ADJ_NOTCHES as u8 { stick_config.cal_points_x = self.cal_points.map(|p| p.x.into()); stick_config.cal_points_y = self.cal_points.map(|p| p.y.into()); @@ -528,30 +502,26 @@ impl<'a> StickCalibrationProcess<'a> { SIGNAL_IS_CALIBRATING.signal(true); while { - if self.calibration_step < NO_OF_CALIBRATION_POINTS as u8 { - let (x, y) = get_stick_display_coords(self.calibration_step as usize); - debug!( - "Raw display coords for step {}: {}, {}", - self.calibration_step, x, y - ); - SIGNAL_OVERRIDE_STICK_STATE.signal(Some(OverrideStickState { - x: x as u8, - y: y as u8, - which_stick: match self.which_stick { - Stick::ControlStick => Stick::CStick, - Stick::CStick => Stick::ControlStick, - }, - })); - } else { - // TODO: phob calls `adjustNotch` here - } + let (x, y) = get_stick_display_coords(self.calibration_step as usize); + debug!( + "Raw display coords for step {}: {}, {}", + self.calibration_step, x, y + ); + SIGNAL_OVERRIDE_STICK_STATE.signal(Some(OverrideStickState { + x: x as u8, + y: y as u8, + which_stick: match self.which_stick { + Stick::ControlStick => Stick::CStick, + Stick::CStick => Stick::ControlStick, + }, + })); gcc_subscriber .wait_for_button_release(&AwaitableButtons::A) .await; // Prevent accidental double presses - Timer::after_millis(100).await; + Timer::after_millis(20).await; gcc_subscriber .wait_for_button_press(&AwaitableButtons::A) @@ -659,7 +629,7 @@ pub async fn config_task( }); // Wait for the user to release the buttons - Timer::after_millis(500).await; + Timer::after_millis(1500).await; configuration_main_loop(¤t_config, &mut flash, &mut gcc_subscriber).await; diff --git a/src/input.rs b/src/input.rs index 482b02e..7bb8d56 100644 --- a/src/input.rs +++ b/src/input.rs @@ -494,6 +494,7 @@ pub async fn update_button_state_task( /// /// Has to run on core0 because it makes use of SPI0. #[embassy_executor::task] +#[link_section = ".time_critical.update_stick_states_task"] pub async fn update_stick_states_task( spi: Spi<'static, SPI0, embassy_rp::spi::Blocking>, spi_acs: Output<'static, AnyPin>, @@ -554,7 +555,7 @@ pub async fn update_stick_states_task( match Instant::now() { n => { match (n - last_loop_time).as_micros() { - a if a > 19999 => debug!("Loop took {} us", a), + a if a > 1999 => debug!("Loop took {} us", a), _ => {} }; last_loop_time = n;