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.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "tft_queue.h"
  24. #include "canvas.h"
  25. #include "tft_color.h"
  26. #include "tft_string.h"
  27. #include "tft_image.h"
  28. #include "tft_io.h"
  29. #include "../../inc/MarlinConfig.h"
  30. #if HAS_UI_320x240
  31. #define TFT_WIDTH 320
  32. #define TFT_HEIGHT 240
  33. #elif HAS_UI_480x320
  34. #define TFT_WIDTH 480
  35. #define TFT_HEIGHT 320
  36. #else
  37. #error "Unsupported display resolution!"
  38. #endif
  39. #define ST7735 0x89F0
  40. #define ST7789 0x8552
  41. #define ST7796 0x7796
  42. #define R61505 0x1505
  43. #define ILI9328 0x9328
  44. #define ILI9341 0x9341
  45. #define ILI9488 0x9488
  46. #define LERDGE_ST7796 0xFFFE
  47. #define AUTO 0xFFFF
  48. #ifndef TFT_DRIVER
  49. #define TFT_DRIVER AUTO
  50. #endif
  51. #ifndef TFT_BUFFER_SIZE
  52. #ifdef STM32F103xB
  53. #define TFT_BUFFER_SIZE 1024
  54. #elif defined(STM32F103xE)
  55. #define TFT_BUFFER_SIZE 19200 // 320 * 60
  56. #elif defined(STM32F1)
  57. #define TFT_BUFFER_SIZE 8192
  58. #else
  59. #define TFT_BUFFER_SIZE 19200 // 320 * 60
  60. #endif
  61. #endif
  62. #if TFT_BUFFER_SIZE > 65535
  63. // DMA Count parameter is uint16_t
  64. #error "TFT_BUFFER_SIZE can not exceed 65535"
  65. #endif
  66. #define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
  67. #define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
  68. #define ESC_END 0xFFFF, 0x7FFF
  69. #define ESC_FFFF 0xFFFF, 0xFFFF
  70. class TFT {
  71. private:
  72. static uint32_t lcd_id;
  73. static TFT_String string;
  74. static TFT_IO io;
  75. public:
  76. static TFT_Queue queue;
  77. static uint16_t buffer[TFT_BUFFER_SIZE];
  78. static void init();
  79. static inline void set_font(const uint8_t *Font) { string.set_font(Font); }
  80. static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); }
  81. static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax);
  82. static void write_esc_sequence(const uint16_t *Sequence);
  83. static inline bool is_busy() { return io.isBusy(); }
  84. static inline void abort() { io.Abort(); }
  85. static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); }
  86. static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }
  87. static inline void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); }
  88. static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); }
  89. static inline void set_background(uint16_t color) { queue.set_background(color); }
  90. static inline void add_text(uint16_t x, uint16_t y, uint16_t color, TFT_String tft_string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, tft_string.string(), maxWidth); }
  91. static inline void add_text(uint16_t x, uint16_t y, uint16_t color, const char *string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, (uint8_t *)string, maxWidth); }
  92. static inline void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) { queue.add_image(x, y, image, colors); }
  93. static inline void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main = COLOR_WHITE, uint16_t color_background = COLOR_BACKGROUND, uint16_t color_shadow = COLOR_BLACK) { queue.add_image(x, y, image, color_main, color_background, color_shadow); }
  94. static inline void add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_bar(x, y, width, height, color); }
  95. static inline void add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_rectangle(x, y, width, height, color); }
  96. };
  97. extern TFT tft;