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.

89 lines
3.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #pragma once
  2. #include <stdint.h>
  3. #include <functional>
  4. #include "basic_type.hpp"
  5. //
  6. namespace iflytop {
  7. using namespace std;
  8. class I_StepMotorCtrlModule {
  9. public:
  10. typedef enum { hbot, corexy } RobotType_t;
  11. typedef enum { kNormalStop, kBreakStop } StopType_t;
  12. /*******************************************************************************
  13. * ACTION *
  14. *******************************************************************************/
  15. #pragma pack(1)
  16. /*******************************************************************************
  17. * READ *
  18. *******************************************************************************/
  19. typedef struct {
  20. int32_t version;
  21. } version_t;
  22. typedef struct {
  23. uint8_t status;
  24. uint8_t io_state; // x_zero_io x_end_io
  25. int32_t x;
  26. } status_t;
  27. typedef struct {
  28. uint8_t status;
  29. uint8_t io_state; // x_zero_io x_end_io
  30. int32_t x;
  31. } detailed_status_t;
  32. /*******************************************************************************
  33. * CFG *
  34. *******************************************************************************/
  35. typedef struct {
  36. u8 x_shaft;
  37. u8 ihold;
  38. u8 irun;
  39. u16 iholddelay;
  40. s32 distance_scale; // 0.001
  41. s32 shift_x;
  42. s32 acc;
  43. s32 dec;
  44. s32 maxspeed;
  45. s32 min_x;
  46. s32 max_x;
  47. } run_param_t;
  48. typedef struct {
  49. uint8_t pad;
  50. } warning_limit_param_t;
  51. typedef struct {
  52. u32 move_to_zero_max_d;
  53. u32 leave_from_zero_max_d;
  54. u32 speed;
  55. u32 dec;
  56. } run_to_zero_param_t;
  57. #pragma pack()
  58. public:
  59. virtual bool isbusy() = 0;
  60. virtual int32_t get_last_exec_status() = 0;
  61. virtual int32_t move_to(int32_t x, action_cb_status_t status_cb) = 0;
  62. virtual int32_t move_by(int32_t dx, action_cb_status_t status_cb) = 0;
  63. virtual int32_t move_to_zero(action_cb_status_t status_cb) = 0;
  64. virtual int32_t move_to_zero_with_calibrate(int32_t x, action_cb_status_t status_cb) = 0;
  65. virtual int32_t rotate(int32_t speed, int32_t lastforms, action_cb_status_t status_cb) = 0;
  66. virtual int32_t enable(bool venable) = 0;
  67. virtual int32_t stop(uint8_t stopType) = 0;
  68. virtual int32_t force_change_current_pos(int32_t x) = 0;
  69. virtual int32_t read_version(version_t& version) = 0;
  70. virtual int32_t read_status(status_t& status) = 0;
  71. virtual int32_t read_detailed_status(detailed_status_t& debug_info) = 0;
  72. virtual int32_t set_run_param(uint8_t operation, const run_param_t& param, run_param_t& ack) = 0;
  73. virtual int32_t set_run_to_zero_param(uint8_t operation, const run_to_zero_param_t& param, run_to_zero_param_t& ack) = 0;
  74. virtual int32_t set_warning_limit_param(uint8_t operation, const warning_limit_param_t& param, warning_limit_param_t& ack) = 0;
  75. };
  76. } // namespace iflytop