Compare commits

..

No commits in common. "031495cad966d22189b958837cdfd2d3eb8292d9" and "4e1af50ebdb4f7c103eaeb1cdf9160572f68b148" have entirely different histories.

3 changed files with 16 additions and 15 deletions

View file

@ -538,7 +538,7 @@ pub async fn update_button_state_task(
}
/// Task responsible for updating the stick states.
/// Publishes the result to SIGNAL_STICK_STATE.
/// Publishes the result to STICK_SIGNAL.
///
/// Has to run on core0 because it makes use of SPI0.
#[embassy_executor::task]
@ -556,8 +556,8 @@ pub async fn update_stick_states_task(
let mut controller_config = SIGNAL_CONFIG_CHANGE.wait().await;
let mut controlstick_params = StickParams::from(&controller_config.astick_config);
let mut cstick_params = StickParams::from(&controller_config.cstick_config);
let mut controlstick_params = StickParams::from_stick_config(&controller_config.astick_config);
let mut cstick_params = StickParams::from_stick_config(&controller_config.cstick_config);
let mut filter_gains = FILTER_GAINS.get_normalized_gains(&controller_config);
let mut current_stick_state = StickState {
@ -616,14 +616,13 @@ pub async fn update_stick_states_task(
SIGNAL_STICK_STATE.signal(current_stick_state.clone());
// the yield_now is in case we took too long for the ticker
yield_now().await;
ticker.next().await;
if let Some(new_config) = SIGNAL_CONFIG_CHANGE.try_take() {
controller_config = new_config;
controlstick_params = StickParams::from(&controller_config.astick_config);
cstick_params = StickParams::from(&controller_config.cstick_config);
controlstick_params = StickParams::from_stick_config(&controller_config.astick_config);
cstick_params = StickParams::from_stick_config(&controller_config.cstick_config);
filter_gains = FILTER_GAINS.get_normalized_gains(&controller_config);
info!("Controlstick params: {:?}", controlstick_params);

View file

@ -1,3 +1,7 @@
//! This example test the RP Pico on board LED.
//!
//! It does not work with the RP Pico W board. See wifi_blinky.rs.
#![no_std]
#![no_main]
mod config;

View file

@ -32,19 +32,17 @@ pub const NOTCH_ADJUSTMENT_ORDER: [usize; NO_OF_ADJ_NOTCHES] = [2, 6,
#[derive(Clone, Debug, Default, Format)]
pub struct StickParams {
/// these are the linearization coefficients
// these are the linearization coefficients
pub fit_coeffs: XyValuePair<[f32; NUM_COEFFS]>,
// these are the notch remap parameters
/// affine transformation coefficients for all regions of the stick
pub affine_coeffs: [[f32; 4]; 16],
/// angles at the boundaries between regions of the stick (in the plane)
pub boundary_angles: [f32; 16],
pub affine_coeffs: [[f32; 4]; 16], // affine transformation coefficients for all regions of the stick
pub boundary_angles: [f32; 16], // angles at the boundaries between regions of the stick (in the plane)
}
impl From<&StickConfig> for StickParams {
/// Generate a StickParam struct from a stick config
fn from(stick_config: &StickConfig) -> Self {
impl StickParams {
/// Generate StickParams structs for the sticks, returned as a tuple of (analog_stick, c_stick)
pub fn from_stick_config(stick_config: &StickConfig) -> Self {
let cleaned_cal_points = CleanedCalibrationPoints::from_temp_calibration_points(
stick_config.cal_points_x.to_regular_array(),
stick_config.cal_points_y.to_regular_array(),
@ -429,7 +427,7 @@ impl AppliedCalibration {
cal_points_y: &[f32; NO_OF_CALIBRATION_POINTS],
stick_config: &StickConfig,
) -> Self {
let mut stick_params = StickParams::from(stick_config);
let mut stick_params = StickParams::from_stick_config(stick_config);
let (stripped_cal_points_x, stripped_cal_points_y) =
strip_cal_points(cal_points_x, cal_points_y);