Fixed some bugs

This commit is contained in:
Christoffer Martinsson 2023-08-06 16:39:05 +02:00
parent a8f5b605d3
commit 64ddd03ad0

View File

@ -140,10 +140,10 @@ fn main() -> ! {
// Configure ADC input pins // Configure ADC input pins
// Have not figured out hov to store the adc pins in an array yet // Have not figured out hov to store the adc pins in an array yet
// TODO: Find a way to store adc pins in an array // TODO: Find a way to store adc pins in an array
let mut adc_pin_left_x = pins.gp26.into_floating_input(); let mut adc_pin_left_x = pins.gp29.into_floating_input();
let mut adc_pin_left_y = pins.gp27.into_floating_input(); let mut adc_pin_left_y = pins.gp28.into_floating_input();
let mut adc_pin_right_x = pins.gp28.into_floating_input(); let mut adc_pin_right_x = pins.gp27.into_floating_input();
let mut adc_pin_right_y = pins.gp29.into_floating_input(); let mut adc_pin_right_y = pins.gp26.into_floating_input();
// Setting up array with pins connected to button rows // Setting up array with pins connected to button rows
let button_matrix_row_pins: &[&dyn InputPin<Error = Infallible>; BUTTON_ROWS] = &[ let button_matrix_row_pins: &[&dyn InputPin<Error = Infallible>; BUTTON_ROWS] = &[
@ -259,6 +259,22 @@ fn main() -> ! {
buttons[index].pressed = *key; buttons[index].pressed = *key;
} }
if button_matrix.buttons_pressed()[0]
&& button_matrix.buttons_pressed()[1]
&& button_matrix.buttons_pressed()[5]
&& button_matrix.buttons_pressed()[6]
&& button_matrix.buttons_pressed()[8]
&& button_matrix.buttons_pressed()[9]
{
status_led.update(StatusMode::Bootloader);
let gpio_activity_pin_mask: u32 = 0;
let disable_interface_mask: u32 = 0;
rp2040_hal::rom_data::reset_to_usb_boot(
gpio_activity_pin_mask,
disable_interface_mask,
);
}
match usb_hid_joystick.device().write_report(&get_joystick_report( match usb_hid_joystick.device().write_report(&get_joystick_report(
&mut buttons, &mut buttons,
&mut axis, &mut axis,
@ -354,9 +370,9 @@ fn get_mode(pressed_keys: [bool; NUMBER_OF_BUTTONS]) -> u8 {
if fn_l_active && fn_r_active { if fn_l_active && fn_r_active {
mode = 3; mode = 3;
} else if fn_l_active {
mode = 2;
} else if fn_r_active { } else if fn_r_active {
mode = 2;
} else if fn_l_active {
mode = 1; mode = 1;
} }
@ -417,12 +433,13 @@ fn get_joystick_report(
} else if mode & 0x10 == 0x10 } else if mode & 0x10 == 0x10
&& (axis[GIMBAL_AXIS_LEFT_Y].fn_mode == 1 || axis[GIMBAL_AXIS_LEFT_Y].fn_mode == 3) && (axis[GIMBAL_AXIS_LEFT_Y].fn_mode == 1 || axis[GIMBAL_AXIS_LEFT_Y].fn_mode == 3)
{ {
rz = remap( rz = AXIS_MAX
- remap(
axis[GIMBAL_AXIS_LEFT_Y].value, axis[GIMBAL_AXIS_LEFT_Y].value,
AXIS_MIN, AXIS_MIN,
AXIS_MAX, AXIS_MAX,
AXIS_CENTER, AXIS_CENTER,
AXIS_MIN, AXIS_MAX,
); );
} }