Small bug fixes
This commit is contained in:
parent
87b3da3e89
commit
6cf9bde7e0
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user