My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tft_queue.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #include "../../inc/MarlinConfig.h"
  24. #include "tft_string.h"
  25. #include "tft_image.h"
  26. #define QUEUE_SIZE 8192
  27. enum QueueTaskType : uint8_t {
  28. TASK_END_OF_QUEUE = 0x00,
  29. TASK_FILL,
  30. TASK_CANVAS,
  31. };
  32. enum QueueTaskState : uint8_t {
  33. TASK_STATE_READY = 0x00,
  34. TASK_STATE_IN_PROGRESS,
  35. TASK_STATE_COMPLETED,
  36. TASK_STATE_SKETCH = 0xFF,
  37. };
  38. enum CanvasSubtype : uint8_t {
  39. CANVAS_SET_BACKGROUND = 0x00,
  40. CANVAS_ADD_TEXT,
  41. CANVAS_ADD_IMAGE,
  42. CANVAS_ADD_BAR,
  43. CANVAS_ADD_RECTANGLE,
  44. };
  45. typedef struct __attribute__((__packed__)) {
  46. QueueTaskType type;
  47. QueueTaskState state;
  48. uint8_t *nextTask;
  49. } queueTask_t;
  50. typedef struct __attribute__((__packed__)) {
  51. uint16_t x;
  52. uint16_t y;
  53. uint16_t width;
  54. uint16_t height;
  55. uint16_t color;
  56. uint32_t count;
  57. } parametersFill_t;
  58. typedef struct __attribute__((__packed__)) {
  59. uint16_t x;
  60. uint16_t y;
  61. uint16_t width;
  62. uint16_t height;
  63. uint32_t count;
  64. } parametersCanvas_t;
  65. typedef struct __attribute__((__packed__)) {
  66. CanvasSubtype type;
  67. uint16_t color;
  68. } parametersCanvasBackground_t;
  69. typedef struct __attribute__((__packed__)) {
  70. CanvasSubtype type;
  71. uint16_t x;
  72. uint16_t y;
  73. uint16_t color;
  74. uint32_t count;
  75. uint16_t maxWidth;
  76. uint16_t stringLength;
  77. } parametersCanvasText_t;
  78. typedef struct __attribute__((__packed__)) {
  79. CanvasSubtype type;
  80. int16_t x;
  81. int16_t y;
  82. MarlinImage image;
  83. } parametersCanvasImage_t;
  84. typedef struct __attribute__((__packed__)) {
  85. CanvasSubtype type;
  86. uint16_t x;
  87. uint16_t y;
  88. uint16_t width;
  89. uint16_t height;
  90. uint16_t color;
  91. } parametersCanvasBar_t;
  92. typedef struct __attribute__((__packed__)) {
  93. CanvasSubtype type;
  94. uint16_t x;
  95. uint16_t y;
  96. uint16_t width;
  97. uint16_t height;
  98. uint16_t color;
  99. } parametersCanvasRectangle_t;
  100. class TFT_Queue {
  101. private:
  102. static uint8_t queue[QUEUE_SIZE];
  103. static uint8_t *end_of_queue;
  104. static uint8_t *current_task;
  105. static uint8_t *last_task;
  106. static void finish_sketch();
  107. static void fill(queueTask_t *task);
  108. static void canvas(queueTask_t *task);
  109. public:
  110. static void reset();
  111. static void async();
  112. static void sync() { while (current_task != NULL) async(); }
  113. static void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
  114. static void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
  115. static void set_background(uint16_t color);
  116. static void add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string, uint16_t maxWidth);
  117. static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors);
  118. static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main, uint16_t color_background, uint16_t color_shadow);
  119. static void add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
  120. static void add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
  121. };