canvas.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include <stdint.h>
  3. #include <u8g2.h>
  4. #include <gui/icon.h>
  5. #include <assets_icons_i.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef enum {
  10. ColorWhite = 0x00,
  11. ColorBlack = 0x01,
  12. } Color;
  13. typedef enum { FontPrimary = 0x00, FontSecondary = 0x01, FontGlyph = 0x02 } Font;
  14. typedef struct Canvas Canvas;
  15. /*
  16. * Canvas width
  17. * @return width in pixels.
  18. */
  19. uint8_t canvas_width(Canvas* canvas);
  20. /*
  21. * Canvas height
  22. * @return height in pixels.
  23. */
  24. uint8_t canvas_height(Canvas* canvas);
  25. /*
  26. * Clear canvas, clear rendering buffer
  27. */
  28. void canvas_clear(Canvas* canvas);
  29. /*
  30. * Set drawing color
  31. */
  32. void canvas_set_color(Canvas* canvas, Color color);
  33. /*
  34. * Set drawing font
  35. */
  36. void canvas_set_font(Canvas* canvas, Font font);
  37. /*
  38. * Draw string at position of baseline defined by x, y.
  39. */
  40. void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str);
  41. /*
  42. * Draw stateful icon at position defined by x,y.
  43. */
  44. void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, Icon* icon);
  45. /*
  46. * Draw stateless icon at position defined by x,y.
  47. */
  48. void canvas_draw_icon_name(Canvas* canvas, uint8_t x, uint8_t y, IconName name);
  49. /*
  50. * Draw xbm icon of width, height at position defined by x,y.
  51. */
  52. void canvas_draw_xbm(
  53. Canvas* canvas,
  54. uint8_t x,
  55. uint8_t y,
  56. uint8_t w,
  57. uint8_t h,
  58. const uint8_t* bitmap);
  59. /*
  60. * Draw dot at x,y
  61. */
  62. void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y);
  63. /*
  64. * Draw box of width, height at x,y
  65. */
  66. void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
  67. /*
  68. * Draw frame of width, height at x,y
  69. */
  70. void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
  71. /*
  72. * Draw line from x1,y1 to x2,y2
  73. */
  74. void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
  75. /*
  76. * Draw glyph
  77. */
  78. void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch);
  79. #ifdef __cplusplus
  80. }
  81. #endif