canvas_i.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "canvas.h"
  3. #include <u8g2.h>
  4. struct Canvas {
  5. u8g2_t fb;
  6. CanvasOrientation orientation;
  7. uint8_t offset_x;
  8. uint8_t offset_y;
  9. uint8_t width;
  10. uint8_t height;
  11. };
  12. /*
  13. * Allocate memory and initialize canvas
  14. */
  15. Canvas* canvas_init();
  16. /*
  17. * Free canvas memory
  18. */
  19. void canvas_free(Canvas* canvas);
  20. /*
  21. * Reset canvas drawing tools configuration
  22. */
  23. void canvas_reset(Canvas* canvas);
  24. /*
  25. * Commit canvas. Send buffer to display
  26. */
  27. void canvas_commit(Canvas* canvas);
  28. /*
  29. * Get canvas buffer.
  30. * @return pointer to buffer
  31. */
  32. uint8_t* canvas_get_buffer(Canvas* canvas);
  33. /*
  34. * Get canvas buffer size.
  35. * @return size of canvas in bytes
  36. */
  37. size_t canvas_get_buffer_size(Canvas* canvas);
  38. /*
  39. * Set drawing region relative to real screen buffer
  40. */
  41. void canvas_frame_set(
  42. Canvas* canvas,
  43. uint8_t offset_x,
  44. uint8_t offset_y,
  45. uint8_t width,
  46. uint8_t height);
  47. /*
  48. * Set canvas orientation
  49. */
  50. void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation);
  51. /*
  52. * Get canvas orientation
  53. */
  54. CanvasOrientation canvas_get_orientation(const Canvas* canvas);