AP_IRLock_I2C.h 837 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * AP_IRLock_I2C.h
  3. *
  4. */
  5. #pragma once
  6. #include "IRLock.h"
  7. #include <AP_HAL/AP_HAL.h>
  8. class AP_IRLock_I2C : public IRLock
  9. {
  10. public:
  11. // init - initialize sensor library
  12. void init(int8_t bus) override;
  13. // retrieve latest sensor data - returns true if new data is available
  14. bool update() override;
  15. private:
  16. AP_HAL::OwnPtr<AP_HAL::Device> dev;
  17. struct PACKED frame {
  18. uint16_t checksum;
  19. uint16_t signature;
  20. uint16_t pixel_x;
  21. uint16_t pixel_y;
  22. uint16_t pixel_size_x;
  23. uint16_t pixel_size_y;
  24. };
  25. bool timer(void);
  26. bool sync_frame_start(void);
  27. bool read_block(struct frame &irframe);
  28. void read_frames(void);
  29. void pixel_to_1M_plane(float pix_x, float pix_y, float &ret_x, float &ret_y);
  30. HAL_Semaphore sem;
  31. uint32_t _last_read_ms;
  32. };