bala.h 725 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _BALA_H__
  2. #define _BALA_H__
  3. #include "Arduino.h"
  4. #include "freertos/FreeRTOS.h"
  5. class Bala {
  6. public:
  7. int32_t wheel_left_encoder, wheel_right_encoder;
  8. public:
  9. Bala();
  10. void ClearEncoder();
  11. void GetEncoder(int32_t* wheel_left, int32_t* wheel_right);
  12. void SetEncoder(int32_t wheel_left, int32_t wheel_right);
  13. void UpdateEncoder();
  14. // -1023 ~ 1024
  15. void SetSpeed(int16_t wheel_left, int16_t wheel_right);
  16. // 500 ~ 2500 -> 0 ~ 180
  17. void SetServoAngle(uint8_t pos, uint8_t angle);
  18. // 500 ~ 2500
  19. void SetServoPulse(uint8_t pos, uint16_t width);
  20. // used i2c lock
  21. void SetMutex(SemaphoreHandle_t* mutex);
  22. private:
  23. SemaphoreHandle_t i2c_mutex;
  24. };
  25. #endif