From a2d5620fd01e6ea10e54cef99134ed17b3f30394 Mon Sep 17 00:00:00 2001 From: Naxdy Date: Wed, 3 Apr 2024 17:27:08 +0200 Subject: [PATCH] clippy: input.rs --- src/input.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/input.rs b/src/input.rs index b43e141..caec497 100644 --- a/src/input.rs +++ b/src/input.rs @@ -117,7 +117,7 @@ pub fn read_ext_adc< spi_ccs.set_high(); } - return temp_value; + temp_value } /// Gets the average stick state over a 1ms interval in a non-blocking fashion. @@ -198,7 +198,7 @@ async fn update_stick_states( trace!("Raw Stick Values 001: {:?}", raw_stick_values); let (x_pos_filt, y_pos_filt) = - kalman_state.run_kalman(x_z, y_z, &controller_config.astick_config, &filter_gains); + kalman_state.run_kalman(x_z, y_z, &controller_config.astick_config, filter_gains); let shaped_astick = match run_waveshaping( x_pos_filt, @@ -206,7 +206,7 @@ async fn update_stick_states( controller_config.astick_config.x_waveshaping, controller_config.astick_config.y_waveshaping, controlstick_waveshaping_values, - &filter_gains, + filter_gains, ) { (x, y) => XyValuePair { x, y }, }; @@ -226,7 +226,7 @@ async fn update_stick_states( controller_config.cstick_config.x_waveshaping, controller_config.cstick_config.y_waveshaping, cstick_waveshaping_values, - &filter_gains, + filter_gains, ) { (x, y) => XyValuePair { x, y }, }; @@ -309,20 +309,20 @@ async fn update_stick_states( let mut out_stick_state = current_stick_state.clone(); let diff_x = (remapped.x + FLOAT_ORIGIN) - current_stick_state.ax as f32; - if (diff_x > (1.0 + STICK_HYST_VAL)) || (diff_x < -STICK_HYST_VAL) { + if !(-STICK_HYST_VAL..=(1.0 + STICK_HYST_VAL)).contains(&diff_x) { out_stick_state.ax = (remapped.x + FLOAT_ORIGIN) as u8; } let diff_y = (remapped.y + FLOAT_ORIGIN) - current_stick_state.ay as f32; - if (diff_y > (1.0 + STICK_HYST_VAL)) || (diff_y < -STICK_HYST_VAL) { + if !(-STICK_HYST_VAL..=(1.0 + STICK_HYST_VAL)).contains(&diff_y) { out_stick_state.ay = (remapped.y + FLOAT_ORIGIN) as u8; } let diff_cx = (remapped_c.x + FLOAT_ORIGIN) - current_stick_state.cx as f32; - if (diff_cx > (1.0 + STICK_HYST_VAL)) || (diff_cx < -STICK_HYST_VAL) { + if !(-STICK_HYST_VAL..=(1.0 + STICK_HYST_VAL)).contains(&diff_cx) { out_stick_state.cx = (remapped_c.x + FLOAT_ORIGIN) as u8; } let diff_cy = (remapped_c.y + FLOAT_ORIGIN) - current_stick_state.cy as f32; - if (diff_cy > (1.0 + STICK_HYST_VAL)) || (diff_cy < -STICK_HYST_VAL) { + if !(-STICK_HYST_VAL..=(1.0 + STICK_HYST_VAL)).contains(&diff_cy) { out_stick_state.cy = (remapped_c.y + FLOAT_ORIGIN) as u8; } @@ -474,7 +474,7 @@ pub async fn update_button_state_task( }; if let Some(override_state) = &override_stick_state { - let mut overriden_gcc_state = gcc_state.clone(); + let mut overriden_gcc_state = gcc_state; match override_state.which_stick { Stick::ControlStick => { overriden_gcc_state.stick_x = override_state.x;