AP_OSD_Backend.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * This file is free software: you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License as published by the
  4. * Free Software Foundation, either version 3 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * This file is distributed in the hope that it will be useful, but
  8. * WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. * See the GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License along
  13. * with this program. If not, see <http://www.gnu.org/licenses/>.
  14. *
  15. */
  16. #pragma once
  17. #include <AP_HAL/HAL.h>
  18. #include <AP_OSD/AP_OSD.h>
  19. class AP_OSD_Backend {
  20. public:
  21. //constructor
  22. AP_OSD_Backend(AP_OSD &osd): _osd(osd) {};
  23. //destructor
  24. virtual ~AP_OSD_Backend(void) {}
  25. //draw given text to framebuffer
  26. virtual void write(uint8_t x, uint8_t y, const char* text) = 0;
  27. //draw formatted text to framebuffer
  28. virtual void write(uint8_t x, uint8_t y, bool blink, const char *fmt, ...);
  29. //initilize framebuffer and underlying hardware
  30. virtual bool init() = 0;
  31. //update screen
  32. virtual void flush() = 0;
  33. //clear screen
  34. //should match hw blink
  35. virtual void clear()
  36. {
  37. blink_phase = (blink_phase+1)%4;
  38. };
  39. AP_OSD * get_osd()
  40. {
  41. return &_osd;
  42. }
  43. protected:
  44. AP_OSD& _osd;
  45. // get font choice
  46. uint8_t get_font_num(void) const
  47. {
  48. return (uint8_t)_osd.font_num.get();
  49. }
  50. //check option
  51. bool check_option(uint32_t option)
  52. {
  53. return (_osd.options & option) != 0;
  54. }
  55. int8_t blink_phase;
  56. };