My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

tft.h 3.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/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. #ifndef TFT_BUFFER_SIZE
  40. #ifdef STM32F103xB
  41. #define TFT_BUFFER_SIZE 1024
  42. #elif defined(STM32F103xE)
  43. #define TFT_BUFFER_SIZE 19200 // 320 * 60
  44. #elif defined(STM32F1)
  45. #define TFT_BUFFER_SIZE 8192
  46. #else
  47. #define TFT_BUFFER_SIZE 19200 // 320 * 60
  48. #endif
  49. #endif
  50. #if TFT_BUFFER_SIZE > 65535
  51. // DMA Count parameter is uint16_t
  52. #error "TFT_BUFFER_SIZE can not exceed 65535"
  53. #endif
  54. class TFT {
  55. private:
  56. static TFT_String string;
  57. static TFT_IO io;
  58. public:
  59. static TFT_Queue queue;
  60. static uint16_t buffer[TFT_BUFFER_SIZE];
  61. static void init();
  62. static inline void set_font(const uint8_t *Font) { string.set_font(Font); }
  63. static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); }
  64. static inline bool is_busy() { return io.isBusy(); }
  65. static inline void abort() { io.Abort(); }
  66. static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); }
  67. static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }
  68. static inline void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); }
  69. 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); }
  70. static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); }
  71. static inline void set_background(uint16_t color) { queue.set_background(color); }
  72. 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); }
  73. 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); }
  74. static inline void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) { queue.add_image(x, y, image, colors); }
  75. 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); }
  76. 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); }
  77. 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); }
  78. };
  79. extern TFT tft;