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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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
  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. #else
  30. #error "TFT IO only supports SPI or FSMC interface"
  31. #endif
  32. #define TFT_EXCHANGE_XY (1UL << 1)
  33. #define TFT_INVERT_X (1UL << 2)
  34. #define TFT_INVERT_Y (1UL << 3)
  35. #define TFT_NO_ROTATION (0x00)
  36. #define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X)
  37. #define TFT_ROTATE_180 (TFT_INVERT_X | TFT_INVERT_Y)
  38. #define TFT_ROTATE_270 (TFT_EXCHANGE_XY | TFT_INVERT_Y)
  39. #define TFT_MIRROR_X (TFT_INVERT_Y)
  40. #define TFT_MIRROR_Y (TFT_INVERT_X)
  41. #define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_INVERT_Y)
  42. #define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_INVERT_X)
  43. #define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_INVERT_Y)
  44. #define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_INVERT_X)
  45. #define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_INVERT_Y)
  46. #define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_INVERT_X)
  47. // TFT_ROTATION is user configurable
  48. #ifndef TFT_ROTATION
  49. #define TFT_ROTATION TFT_NO_ROTATION
  50. #endif
  51. // TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION
  52. #define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION))
  53. #define TFT_COLOR_RGB (1UL << 3)
  54. #define TFT_COLOR_BGR (1UL << 4)
  55. // Each TFT Driver is responsible for its default color mode.
  56. // #ifndef TFT_COLOR
  57. // #define TFT_COLOR TFT_COLOR_RGB
  58. // #endif
  59. #define SSD1963 0x5761
  60. #define ST7735 0x89F0
  61. #define ST7789 0x8552
  62. #define ST7796 0x7796
  63. #define R61505 0x1505
  64. #define ILI9328 0x9328
  65. #define ILI9341 0x9341
  66. #define ILI9488 0x9488
  67. #define ILI9488_ID1 0x8066 //Some ILI9488 have 0x8066 in the 0x04
  68. #define LERDGE_ST7796 0xFFFE
  69. #define AUTO 0xFFFF
  70. #ifndef TFT_DRIVER
  71. #define TFT_DRIVER AUTO
  72. #endif
  73. #define ESC_REG(x) 0xFFFF, 0x00FF & (uint16_t)x
  74. #define ESC_DELAY(x) 0xFFFF, 0x8000 | (x & 0x7FFF)
  75. #define ESC_END 0xFFFF, 0x7FFF
  76. #define ESC_FFFF 0xFFFF, 0xFFFF
  77. class TFT_IO {
  78. public:
  79. static TFT_IO_DRIVER io;
  80. static void InitTFT();
  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. // Deletaged methods
  84. inline static void Init() { io.Init(); };
  85. inline static bool isBusy() { return io.isBusy(); };
  86. inline static void Abort() { io.Abort(); };
  87. inline static uint32_t GetID() { return io.GetID(); };
  88. inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); }
  89. inline static void DataTransferEnd() { io.DataTransferEnd(); };
  90. // inline static void DataTransferAbort() { io.DataTransferAbort(); };
  91. inline static void WriteData(uint16_t Data) { io.WriteData(Data); };
  92. inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); };
  93. inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); };
  94. // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
  95. inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); };
  96. protected:
  97. static uint32_t lcd_id;
  98. };
  99. #endif // HAS_SPI_TFT || HAS_FSMC_TFT