Display_SH1106_I2C.h 835 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include "Display.h"
  3. #include "Display_Backend.h"
  4. #include <AP_HAL/I2CDevice.h>
  5. #define SH1106_COLUMNS 132 // display columns
  6. #define SH1106_ROWS 64 // display rows
  7. #define SH1106_ROWS_PER_PAGE 8
  8. class Display_SH1106_I2C: public Display_Backend {
  9. public:
  10. static Display_SH1106_I2C *probe(AP_HAL::OwnPtr<AP_HAL::Device> dev);
  11. void hw_update() override;
  12. void set_pixel(uint16_t x, uint16_t y) override;
  13. void clear_pixel(uint16_t x, uint16_t y) override;
  14. void clear_screen() override;
  15. protected:
  16. Display_SH1106_I2C(AP_HAL::OwnPtr<AP_HAL::Device> dev);
  17. ~Display_SH1106_I2C() override;
  18. private:
  19. bool hw_init() override;
  20. void _timer();
  21. AP_HAL::OwnPtr<AP_HAL::Device> _dev;
  22. uint8_t _displaybuffer[SH1106_COLUMNS * SH1106_ROWS_PER_PAGE];
  23. bool _need_hw_update;
  24. };