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.

47 lines
948 B

3 years ago
  1. #include "motor_drive.h"
  2. bool motor_cmd_set_position(int speed_level, double position, int direction)
  3. {
  4. int last_direction = direction;
  5. if (!motor_validation_set_position_parameters(speed_level, position, direction))
  6. {
  7. return false;
  8. }
  9. if (direction == 0)
  10. {
  11. last_direction = motor_find_short_path_direction(position);
  12. }
  13. motor_set_position(speed_level, position, last_direction);
  14. return true;
  15. }
  16. void motor_set_position(int speed_level, double position, int direction)
  17. {
  18. }
  19. bool motor_validation_set_position_parameters(int speed_level, double position, int direction)
  20. {
  21. return true;
  22. }
  23. int motor_find_short_path_direction(double position)
  24. {
  25. double encoder_position = 0.0;
  26. encoder_position = motor_read_encoder();
  27. if (encoder_position > position)
  28. {
  29. return 2;
  30. }
  31. else
  32. {
  33. return 1;
  34. }
  35. return;
  36. }
  37. double motor_read_encoder()
  38. {
  39. return 0.0;
  40. }