tcode.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <furi.h>
  3. typedef enum {
  4. Device,
  5. Magnitude,
  6. MagnitudeTimeInterval,
  7. MagnitudeSpeed,
  8. Unknown,
  9. } TCodeCommandType;
  10. typedef enum {
  11. DeviceIdentification,
  12. TCodeVersion,
  13. ListAxesAndUserRangePreferences,
  14. Stop,
  15. } DeviceCommand;
  16. typedef enum {
  17. Linear,
  18. Rotate,
  19. Vibrate,
  20. Auxiliary,
  21. } TCodeCommandMotionType;
  22. typedef struct {
  23. TCodeCommandMotionType motion_type;
  24. uint8_t channel_id;
  25. float magnitude;
  26. } TCodeMagnitudeCommand;
  27. typedef struct {
  28. TCodeCommandMotionType motion_type;
  29. uint8_t channel_id;
  30. float magnitude;
  31. uint16_t time_interval_milliseconds;
  32. } TCodeMagnitudeTimeIntervalCommand;
  33. typedef struct {
  34. TCodeCommandMotionType motion_type;
  35. uint8_t channel_id;
  36. float magnitude;
  37. uint16_t speed_per_hundred_milliseconds;
  38. } TCodeMagnitudeSpeedCommand;
  39. typedef struct {
  40. TCodeCommandType command_type;
  41. union {
  42. DeviceCommand device_command;
  43. TCodeMagnitudeCommand magnitude_command;
  44. TCodeMagnitudeTimeIntervalCommand magnitude_time_interval_command;
  45. TCodeMagnitudeSpeedCommand magnitude_speed_command;
  46. } data;
  47. } TCodeCommand;
  48. typedef struct {
  49. uint16_t size;
  50. TCodeCommand* commands;
  51. } TCodeCommandArray;
  52. TCodeCommandArray tcode_decode(uint8_t* buffer, uint16_t size);