Control drones with a proper joystick
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. * Check if a valid PID/VID device has been found.
  39. */
  40. void initialize();
  41. /*
  42. * Set brightness of LEDs and MFD backlight.
  43. * Three states, 0=off, 1=dim, 2=on.
  44. */
  45. void setLEDBrightness(uint16_t val) { sendCommand(X52_LED_BRIGHTNESS, val); }
  46. void setMFDBrightness(uint16_t val) { sendCommand(X52_MFD_BRIGHTNESS, val); }
  47. /*
  48. * Print text on the MFD lines (0 - 2).
  49. * Maximum of 16 characters per line.
  50. */
  51. void setMFDText(uint8_t line, const char* text = " ");
  52. /*
  53. * Enable (1) or Disable(0) the MFD shift indicator.
  54. */
  55. void setShift(uint8_t state);
  56. /*
  57. * Fast blinking of Info and Hat LEDs.
  58. * State can be 0=off or 1=on.
  59. */
  60. void setBlink(uint8_t state);
  61. /*
  62. * Set date. The third digit seems to be broken in hardware?
  63. */
  64. void setDate(uint8_t dd, uint8_t mm, uint8_t yy);
  65. /*
  66. * Set time. There seems to be a problem with time offsets
  67. * and the 12h/24h time format conflicting...?
  68. */
  69. void setTime(uint8_t h, uint8_t m);
  70. void setTimeOffset(uint8_t cl, int16_t offset);
  71. private:
  72. uint8_t sendCommand(uint16_t command, uint16_t val);
  73. USB* usb;
  74. HID* hid;
  75. uint8_t ready;
  76. };
  77. #endif // __X52_H__