diff --git a/rp2040/src/axis.rs b/rp2040/src/axis.rs index 5865f27..7493d91 100644 --- a/rp2040/src/axis.rs +++ b/rp2040/src/axis.rs @@ -174,13 +174,14 @@ impl VirtualAxis { } else if (self.value != AXIS_CENTER && !up_pressed && !down_pressed) || (up_pressed && down_pressed) { - // Return to center when no buttons pressed or both pressed - if self.value < AXIS_CENTER + self.step { - self.value += self.step; - } else if self.value > AXIS_CENTER - self.step { - self.value -= self.step; + // Return to center when no buttons are pressed or both are pressed + let before = self.value; + if self.value > AXIS_CENTER { + self.value = self.value.saturating_sub(self.step); + } else if self.value < AXIS_CENTER { + self.value = self.value.saturating_add(self.step); } - activity = true; + activity |= self.value != before; } activity diff --git a/rp2040/src/hardware.rs b/rp2040/src/hardware.rs index c569908..97f3c20 100644 --- a/rp2040/src/hardware.rs +++ b/rp2040/src/hardware.rs @@ -79,9 +79,6 @@ pub mod timers { /// Status LED update interval (250ms) pub const STATUS_LED_INTERVAL_MS: u32 = 250; - /// Millisecond timer interval (1ms) - pub const MS_INTERVAL_MS: u32 = 1; - /// Scan timer interval (200us) pub const SCAN_INTERVAL_US: u32 = 200; diff --git a/rp2040/src/main.rs b/rp2040/src/main.rs index d58d47b..8d796f5 100644 --- a/rp2040/src/main.rs +++ b/rp2040/src/main.rs @@ -271,8 +271,7 @@ fn main() -> ! { let mut status_led_count_down = timer.count_down(); status_led_count_down.start(timers::STATUS_LED_INTERVAL_MS.millis()); - let mut ms_count_down = timer.count_down(); - ms_count_down.start(timers::MS_INTERVAL_MS.millis()); + // Removed unused millisecond countdown timer let mut scan_count_down = timer.count_down(); scan_count_down.start(timers::SCAN_INTERVAL_US.micros()); diff --git a/rp2040/src/usb_report.rs b/rp2040/src/usb_report.rs index ede9c9e..b6f14e2 100644 --- a/rp2040/src/usb_report.rs +++ b/rp2040/src/usb_report.rs @@ -62,8 +62,8 @@ pub fn get_joystick_report( let mut slider: i16 = axis_12bit_to_i16(ADC_MIN); let mut hat: u8 = 8; // Hat center position - // Virtual axis control: Disables z and rx axis and uses right gimbal Y axis to control - // slider axis. Values from center stick to max or min will be recalculated to min to max. + // Virtual axis control: Disables z axis and uses right gimbal X axis to control + // the slider axis. Values from center stick to max or min will be recalculated to min to max. if *vt_enable { if axis[GIMBAL_AXIS_RIGHT_X].value >= AXIS_CENTER { slider = axis_12bit_to_i16(remap( @@ -379,4 +379,4 @@ mod tests { assert_eq!(report.buttons & (1 << 7), 1 << 7); // Button 8 assert_eq!(report.hat, 0); // HAT up direction } -} \ No newline at end of file +}