Control drones with a proper joystick
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Saitek-X52-PPM.ino 875B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <hid.h>
  2. #include <hiduniversal.h>
  3. #include <usbhub.h>
  4. // Satisfy IDE, which only needs to see the include statment in the ino.
  5. #ifdef dobogusinclude
  6. #include <spi4teensy3.h>
  7. #include <SPI.h>
  8. #endif
  9. #include "hidjoystickrptparser.h"
  10. USB Usb;
  11. USBHub Hub(&Usb);
  12. HIDUniversal Hid(&Usb);
  13. JoystickEvents JoyEvents;
  14. JoystickReportParser Joy(&JoyEvents);
  15. void setup() {
  16. Serial.begin(115200);
  17. #if !defined(__MIPSEL__)
  18. while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
  19. #endif
  20. Serial.println("Start");
  21. if (Usb.Init() == -1)
  22. Serial.println("OSC did not start.");
  23. delay(200);
  24. if (!Hid.SetReportParser(0, &Joy))
  25. ErrorMessage<uint8_t > (PSTR("SetReportParser"), 1);
  26. }
  27. void loop() {
  28. Usb.Task();
  29. }