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_io.h 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #if HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT
  25. #if HAS_SPI_TFT
  26. #include HAL_PATH(../../HAL, tft/tft_spi.h)
  27. #elif HAS_FSMC_TFT
  28. #include HAL_PATH(../../HAL, tft/tft_fsmc.h)
  29. #elif HAS_LTDC_TFT
  30. #include HAL_PATH(../../HAL, tft/tft_ltdc.h)
  31. #else
  32. #error "TFT IO only supports SPI, FSMC or LTDC interface"
  33. #endif
  34. #define TFT_EXCHANGE_XY (1UL << 1)
  35. #define TFT_INVERT_X (1UL << 2)
  36. #define TFT_INVERT_Y (1UL << 3)
  37. #define TFT_NO_ROTATION (0x00)
  38. #define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X)
  39. #define TFT_ROTATE_180 (TFT_INVERT_X | TFT_INVERT_Y)
  40. #define TFT_ROTATE_270 (TFT_EXCHANGE_XY | TFT_INVERT_Y)
  41. #define TFT_MIRROR_X (TFT_INVERT_Y)
  42. #define TFT_MIRROR_Y (TFT_INVERT_X)
  43. #define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_INVERT_Y)
  44. #define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_INVERT_X)
  45. #define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_INVERT_Y)
  46. #define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_INVERT_X)
  47. #define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_INVERT_Y)
  48. #define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_INVERT_X)
  49. // TFT_ROTATION is user configurable
  50. #ifndef TFT_ROTATION
  51. #define TFT_ROTATION TFT_NO_ROTATION
  52. #endif
  53. // TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION
  54. #define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION))
  55. #define TFT_COLOR_RGB (1UL << 3)
  56. #define TFT_COLOR_BGR (1UL << 4)
  57. // Each TFT Driver is responsible for its default color mode.
  58. // #ifndef TFT_COLOR
  59. // #define TFT_COLOR TFT_COLOR_RGB
  60. // #endif
  61. #define TOUCH_ORIENTATION_NONE 0
  62. #define TOUCH_LANDSCAPE 1
  63. #define TOUCH_PORTRAIT 2
  64. #ifndef TOUCH_CALIBRATION_X
  65. #define TOUCH_CALIBRATION_X 0
  66. #endif
  67. #ifndef TOUCH_CALIBRATION_Y
  68. #define TOUCH_CALIBRATION_Y 0
  69. #endif
  70. #ifndef TOUCH_OFFSET_X
  71. #define TOUCH_OFFSET_X 0
  72. #endif
  73. #ifndef TOUCH_OFFSET_Y
  74. #define TOUCH_OFFSET_Y 0
  75. #endif
  76. #ifndef TOUCH_ORIENTATION
  77. #define TOUCH_ORIENTATION TOUCH_LANDSCAPE
  78. #endif
  79. #define LTDC_RGB 0xABAB
  80. #define SSD1963 0x5761
  81. #define ST7735 0x89F0
  82. #define ST7789 0x8552
  83. #define ST7796 0x7796
  84. #define R61505 0x1505
  85. #define ILI9328 0x9328
  86. #define ILI9341 0x9341
  87. #define ILI9488 0x9488
  88. #define ILI9488_ID1 0x8066 //Some ILI9488 have 0x8066 in the 0x04
  89. #define LERDGE_ST7796 0xFFFE
  90. #define AUTO 0xFFFF
  91. #ifndef TFT_DRIVER
  92. #define TFT_DRIVER AUTO
  93. #endif
  94. #define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
  95. #define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
  96. #define ESC_END 0xFFFF, 0x7FFF
  97. #define ESC_FFFF 0xFFFF, 0xFFFF
  98. class TFT_IO {
  99. public:
  100. static TFT_IO_DRIVER io;
  101. static void InitTFT();
  102. static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax);
  103. static void write_esc_sequence(const uint16_t *Sequence);
  104. // Deletaged methods
  105. inline static void Init() { io.Init(); io.Abort(); };
  106. inline static bool isBusy() { return io.isBusy(); };
  107. inline static void Abort() { io.Abort(); };
  108. inline static uint32_t GetID() { return io.GetID(); };
  109. inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); }
  110. inline static void DataTransferEnd() { io.DataTransferEnd(); };
  111. // inline static void DataTransferAbort() { io.DataTransferAbort(); };
  112. inline static void WriteData(uint16_t Data) { io.WriteData(Data); };
  113. inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); };
  114. inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); };
  115. // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
  116. inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); };
  117. protected:
  118. static uint32_t lcd_id;
  119. };
  120. #endif // HAS_SPI_TFT || HAS_FSMC_TFT