Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease mixer period for USB Joystick mode, increase report rate #831

Merged
merged 2 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions radio/src/mixer_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ uint16_t getMixerSchedulerPeriod()
if (mixerSchedules[EXTERNAL_MODULE].period) {
return mixerSchedules[EXTERNAL_MODULE].period;
}
#endif
#if defined(STM32) && !defined(SIMU)
if (getSelectedUsbMode() == USB_JOYSTICK_MODE) {
return MIXER_SCHEDULER_JOYSTICK_PERIOD_US;
}
#endif
return MIXER_SCHEDULER_DEFAULT_PERIOD_US;
}
Expand Down
3 changes: 2 additions & 1 deletion radio/src/mixer_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#ifndef _MIXER_SCHEDULER_H_
#define _MIXER_SCHEDULER_H_

#define MIXER_SCHEDULER_DEFAULT_PERIOD_US 4000u // 4ms
#define MIXER_SCHEDULER_DEFAULT_PERIOD_US 4000u // 4ms
#define MIXER_SCHEDULER_JOYSTICK_PERIOD_US 2000u // 2ms
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when this is 1000u :)


#define MIN_REFRESH_RATE 1750 /* us */
#define MAX_REFRESH_RATE 50000 /* us */
Expand Down
6 changes: 3 additions & 3 deletions radio/src/pulses/pulses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ void enablePulsesExternalModule(uint8_t protocol)
#endif

default:
// external module stopped, set period to 50ms (necessary for USB Joystick, for instance)
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 50000/*us*/);
// external module stopped, use default mixer period
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 0);
break;
}
}
Expand Down Expand Up @@ -500,7 +500,7 @@ static void enablePulsesInternalModule(uint8_t protocol)
#endif

default:
// internal module stopped, set internal period to 0 and start the scheduler
// internal module stopped, use default mixer period
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion radio/src/targets/common/arm/stm32/usbd_hid_joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ __ALIGN_BEGIN static const uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __A
0x03, /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET, /*wMaxPacketSize: 4 Byte max */
0x00,
0x0A, /*bInterval: Polling Interval (10 ms)*/
0x01, /*bInterval: Polling Interval (1 ms)*/
/* 34 */
} ;

Expand Down