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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Saitek X52 Arduino USB Host Shield Library.
  3. * Copyright 2016 by Thomas Buck <xythobuz@xythobuz.de>
  4. *
  5. * Based on "x52pro-linux" by Nirenjan Krishnan
  6. * https://github.com/nirenjan/x52pro-linux
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation, version 2.
  11. */
  12. #ifndef __X52_H__
  13. #define __X52_H__
  14. #include <hid.h>
  15. #define X52_VENDOR_REQUEST 0x91
  16. #define X52_MFD_BRIGHTNESS 0xB1
  17. #define X52_LED_BRIGHTNESS 0xB2
  18. #define X52_MFD_CLEAR_LINE 0x08
  19. #define X52_MFD_WRITE_LINE 0x00
  20. #define X52_MFD_LINE1 0xD1
  21. #define X52_MFD_LINE2 0xD2
  22. #define X52_MFD_LINE3 0xD4
  23. #define X52_SHIFT_INDICATOR 0xFD
  24. #define X52_SHIFT_ON 0x51
  25. #define X52_SHIFT_OFF 0x50
  26. #define X52_BLINK_INDICATOR 0xB4
  27. #define X52_BLINK_ON 0x51
  28. #define X52_BLINK_OFF 0x50
  29. #define X52_DATE_DDMM 0xC4
  30. #define X52_DATE_YEAR 0xC8
  31. #define X52_TIME_CLOCK1 0xC0
  32. #define X52_OFFS_CLOCK2 0xC1
  33. #define X52_OFFS_CLOCK3 0xC2
  34. class X52 {
  35. public:
  36. X52(USB* u, HID* h);
  37. /*
  38. * Set brightness of LEDs and MFD backlight.
  39. * Three states, 0=off, 1=dim, 2=on.
  40. */
  41. void setLEDBrightness(uint16_t val) { sendCommand(X52_LED_BRIGHTNESS, val); }
  42. void setMFDBrightness(uint16_t val) { sendCommand(X52_MFD_BRIGHTNESS, val); }
  43. /*
  44. * Print text on the MFD lines (0 - 2).
  45. * Maximum of 16 characters per line.
  46. */
  47. void setMFDText(uint8_t line, const char* text);
  48. /*
  49. * Enable (1) or Disable(0) the MFD shift indicator.
  50. */
  51. void setShift(uint8_t state);
  52. /*
  53. * Fast blinking of Info and Hat LEDs.
  54. * State can be 0=off or 1=on.
  55. */
  56. void setBlink(uint8_t state);
  57. /*
  58. * Set date. The third digit seems to be broken in hardware?
  59. */
  60. void setDate(uint8_t dd, uint8_t mm, uint8_t yy);
  61. /*
  62. * Set time. There seems to be a problem with time offsets
  63. * and the 12h/24h time format conflicting...?
  64. */
  65. void setTime(uint8_t h, uint8_t m);
  66. void setTimeOffset(uint8_t cl, int16_t offset);
  67. private:
  68. uint8_t sendCommand(uint16_t command, uint16_t val);
  69. USB* usb;
  70. HID* hid;
  71. };
  72. #endif // __X52_H__