chore: refactor according to clippy & clean up config #6

Merged
Naxdy merged 8 commits from clippy-fixes into main 2024-04-03 16:53:52 +00:00
Showing only changes of commit 4fce6d6132 - Show all commits

View file

@ -19,7 +19,7 @@ pub const NO_OF_CALIBRATION_POINTS: usize = 32;
const MAX_ORDER: usize = 20; const MAX_ORDER: usize = 20;
/// 28 degrees; this is the max angular deflection of the stick. /// 28 degrees; this is the max angular deflection of the stick.
const MAX_STICK_ANGLE: f32 = 0.4886921906; const MAX_STICK_ANGLE: f32 = 0.488_692_2;
#[rustfmt::skip] #[rustfmt::skip]
// right notch 1 up right notch 2 up notch 3 up left notch 4 left notch 5 down left notch 6 down notch 7 down right notch 8 // right notch 1 up right notch 2 up notch 3 up left notch 4 left notch 5 down left notch 6 down notch 7 down right notch 8
@ -263,7 +263,7 @@ impl LinearizedCalibration {
fit_points_x[1] = (in_x[6 + 1] + in_x[10 + 1]) / 2.0f64; fit_points_x[1] = (in_x[6 + 1] + in_x[10 + 1]) / 2.0f64;
fit_points_x[2] = in_x[0]; fit_points_x[2] = in_x[0];
fit_points_x[3] = (in_x[2 + 1] + in_x[14 + 1]) / 2.0f64; fit_points_x[3] = (in_x[2 + 1] + in_x[14 + 1]) / 2.0f64;
fit_points_x[4] = in_x[0 + 1]; fit_points_x[4] = in_x[1];
fit_points_y[0] = in_y[12 + 1]; fit_points_y[0] = in_y[12 + 1];
fit_points_y[1] = (in_y[10 + 1] + in_y[14 + 1]) / 2.0f64; fit_points_y[1] = (in_y[10 + 1] + in_y[14 + 1]) / 2.0f64;
@ -282,8 +282,8 @@ impl LinearizedCalibration {
let x_zero_error = linearize(fit_points_x[2] as f32, &fit_coeffs_x.map(|e| e as f32)); let x_zero_error = linearize(fit_points_x[2] as f32, &fit_coeffs_x.map(|e| e as f32));
let y_zero_error = linearize(fit_points_y[2] as f32, &fit_coeffs_y.map(|e| e as f32)); let y_zero_error = linearize(fit_points_y[2] as f32, &fit_coeffs_y.map(|e| e as f32));
fit_coeffs_x[3] = fit_coeffs_x[3] - x_zero_error as f64; fit_coeffs_x[3] -= x_zero_error as f64;
fit_coeffs_y[3] = fit_coeffs_y[3] - y_zero_error as f64; fit_coeffs_y[3] -= y_zero_error as f64;
let mut linearized_points_x = [0f32; NO_OF_NOTCHES + 1]; let mut linearized_points_x = [0f32; NO_OF_NOTCHES + 1];
let mut linearized_points_y = [0f32; NO_OF_NOTCHES + 1]; let mut linearized_points_y = [0f32; NO_OF_NOTCHES + 1];
@ -798,9 +798,7 @@ fn trianglize<const N: usize>(matrix: &mut [[f64; N]; N]) -> i32 {
} }
if max > 0 { if max > 0 {
sign = -sign; sign = -sign;
let tmp = matrix[i]; matrix.swap(i, max);
matrix[i] = matrix[max];
matrix[max] = tmp;
} }
if matrix[i][i] == 0. { if matrix[i][i] == 0. {
return 0; return 0;