My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

tft_io.h 4.5KB

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