I wanted to control my DJI Tello drone with a BETAFPV LiteRadio 2 SE controller via USB connected to a computer. So I made this small project when I had some spare time.
Install using `pip`:
pip install literadio2-se-usb
from literadio2_se_usb import LiteRadio2SeUsb
controller = LiteRadio2SeUsb()
# Do not forget to run this method before reading the control outputs
controller.setup()
# Read the control outputs
controls = controller.read_controls()
print(f'{controls.throttle}')
print(f'{controls.yaw}')
print(f'{controls.roll}')
print(f'{controls.pitch}')
print(f'{controls.sa}')
print(f'{controls.sb}')
print(f'{controls.sc}')
print(f'{controls.sd}')
The "read_controls" method returns the "Controls" dataclass. Each attribute of that dataclass outputs an integer between 0 and 2047. You can pass map_to_hundred=True to the "read_controls" method to change the output from -100 to 100.
You can specify the vendor ID and the product ID
from literadio2_se_usb import LiteRadio2SeUsb
controller = LiteRadio2SeUsb(0x0483, 0x5750)
# Or
controller = LiteRadio2SeUsb(id_vendor=0x0483, id_product=0x5750)
Otherwise the program will try to find an appropriate device by its product name (by default it's "BETAFPV Joystick").
You can change this product name if you want to.
from literadio2_se_usb import LiteRadio2SeUsb
controller = LiteRadio2SeUsb(product_string='Product string')