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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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_io.h"
  24. #include "../../inc/MarlinConfig.h"
  25. #define ST7796S_MADCTL_MY 0x80 // Row Address Order
  26. #define ST7796S_MADCTL_MX 0x40 // Column Address Order
  27. #define ST7796S_MADCTL_MV 0x20 // Row/Column Exchange
  28. #define ST7796S_MADCTL_ML 0x10 // Vertical Refresh Order
  29. #define ST7796S_MADCTL_BGR 0x08 // RGB-BGR ORDER
  30. #define ST7796S_MADCTL_RGB 0x00
  31. #define ST7796S_MADCTL_MH 0x04 // Horizontal Refresh Order
  32. #define ST7796S_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7796S_MADCTL_MV) | \
  33. IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7796S_MADCTL_MX) | \
  34. IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7796S_MADCTL_MY)
  35. #if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
  36. #define ST7796S_COLOR ST7796S_MADCTL_BGR
  37. #elif TFT_COLOR == TFT_COLOR_RGB
  38. #define ST7796S_COLOR ST7796S_MADCTL_RGB
  39. #endif
  40. #define ST7796S_MADCTL_DATA (ST7796S_ORIENTATION) | (ST7796S_COLOR)
  41. #define ST7796S_NOP 0x00 // No Operation
  42. #define ST7796S_SWRESET 0x01 // Software reset
  43. #define ST7796S_RDDID 0x04 // Read Display ID
  44. #define ST7796S_RDNUMED 0x05 // Read Number of the Errors on DSI
  45. #define ST7796S_RDDST 0x09 // Read Display Status
  46. #define ST7796S_RDDPM 0x0A // Read Display Power Mode
  47. #define ST7796S_RDDMADCTL 0x0B // Read Display MADCTL
  48. #define ST7796S_RDDCOLMOD 0x0C // Read Display Pixel Format
  49. #define ST7796S_RDDIM 0x0D // Read Display Image Mode
  50. #define ST7796S_RDDSM 0x0E // Read Display Signal Status
  51. #define ST7796S_RDDSDR 0x0F // Read Display Self-Diagnostic Result
  52. #define ST7796S_SLPIN 0x10 // Sleep In
  53. #define ST7796S_SLPOUT 0x11 // Sleep Out
  54. #define ST7796S_PTLON 0x12 // Partial Display Mode On
  55. #define ST7796S_NORON 0x13 // Normal Display Mode On
  56. #define ST7796S_INVOFF 0x20 // Display Inversion Off
  57. #define ST7796S_INVON 0x21 // Display Inversion On
  58. #define ST7796S_DISPOFF 0x28 // Display Off
  59. #define ST7796S_DISPON 0x29 // Display On
  60. #define ST7796S_CASET 0x2A // Column Address Set
  61. #define ST7796S_RASET 0x2B // Row Address Set
  62. #define ST7796S_RAMWR 0x2C // Memory Write
  63. #define ST7796S_RAMRD 0x2E // Memory Read
  64. #define ST7796S_PTLAR 0x30 // Partial Area
  65. #define ST7796S_VSCRDEF 0x33 // Vertical Scrolling Definition
  66. #define ST7796S_TEOFF 0x34 // Tearing Effect Line OFF
  67. #define ST7796S_TEON 0x35 // Tearing Effect Line On
  68. #define ST7796S_MADCTL 0x36 // Memory Data Access Control
  69. #define ST7796S_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
  70. #define ST7796S_IDMOFF 0x38 // Idle Mode Off
  71. #define ST7796S_IDMON 0x39 // Idle Mode On
  72. #define ST7796S_COLMOD 0x3A // Interface Pixel Format
  73. #define ST7796S_WRMEMC 0x3C // Write Memory Continue
  74. #define ST7796S_RDMEMC 0x3E // Read Memory Continue
  75. #define ST7796S_STE 0x44 // Set Tear ScanLine
  76. #define ST7796S_GSCAN 0x45 // Get ScanLine
  77. #define ST7796S_WRDISBV 0x51 // Write Display Brightness
  78. #define ST7796S_RDDISBV 0x52 // Read Display Brightness Value
  79. #define ST7796S_WRCTRLD 0x53 // Write CTRL Display
  80. #define ST7796S_RDCTRLD 0x54 // Read CTRL value Display
  81. #define ST7796S_WRCABC 0x55 // Write Adaptive Brightness Control
  82. #define ST7796S_RDCABC 0x56 // Read Content Adaptive Brightness Control
  83. #define ST7796S_WRCABCMB 0x5E // Write CABC Minimum Brightness
  84. #define ST7796S_RDCABCMB 0x5F // Read CABC Minimum Brightness
  85. #define ST7796S_RDFCS 0xAA // Read First Checksum
  86. #define ST7796S_RDCFCS 0xAF // Read Continue Checksum
  87. #define ST7796S_RDID1 0xDA // Read ID1
  88. #define ST7796S_RDID2 0xDB // Read ID2
  89. #define ST7796S_RDID3 0xDC // Read ID3
  90. #define ST7796S_IFMODE 0xB0 // Interface Mode Control
  91. #define ST7796S_FRMCTR1 0xB1 // Frame Rate Control (In Normal Mode/Full Colors)
  92. #define ST7796S_FRMCTR2 0xB2 // Frame Rate Control 2 (In Idle Mode/8 colors)
  93. #define ST7796S_FRMCTR3 0xB3 // Frame Rate Control 3(In Partial Mode/Full Colors)
  94. #define ST7796S_DIC 0xB4 // Display Inversion Control
  95. #define ST7796S_BPC 0xB5 // Blanking Porch Control
  96. #define ST7796S_DFC 0xB6 // Display Function Control
  97. #define ST7796S_EM 0xB7 // Entry Mode Set
  98. #define ST7796S_PWR1 0xC0 // Power Control 1
  99. #define ST7796S_PWR2 0xC1 // Power Control 2
  100. #define ST7796S_PWR3 0xC2 // Power Control 3
  101. #define ST7796S_VCMPCTL 0xC5 // VCOM Control
  102. #define ST7796S_VCMOST 0xC6 // VCOM Offset Register
  103. #define ST7796S_NVMADW 0xD0 // NVM Address/Data Write
  104. #define ST7796S_NVMBPROG 0xD1 // NVM Byte Program
  105. #define ST7796S_NVMSTRD 0xD2 // NVM Status Read
  106. #define ST7796S_RDID4 0xD3 // Read ID4
  107. #define ST7796S_PGC 0xE0 // Positive Gamma Control
  108. #define ST7796S_NGC 0xE1 // Negative Gamma Control
  109. #define ST7796S_DGC1 0xE2 // Digital Gamma Control 1
  110. #define ST7796S_DGC2 0xE3 // Digital Gamma Control 2
  111. #define ST7796S_DOCA 0xE8 // Display Output Ctrl Adjust
  112. #define ST7796S_CSCON 0xF0 // Command Set Control
  113. #define ST7796S_SPIRC 0xFB // SPI Read Control
  114. static const uint16_t st7796s_init[] = {
  115. DATASIZE_8BIT,
  116. ESC_REG(ST7796S_SWRESET), ESC_DELAY(100),
  117. ESC_REG(ST7796S_SLPOUT), ESC_DELAY(20),
  118. ESC_REG(ST7796S_CSCON), 0x00C3, // enable command 2 part I
  119. ESC_REG(ST7796S_CSCON), 0x0096, // enable command 2 part II
  120. ESC_REG(ST7796S_MADCTL), ST7796S_MADCTL_DATA,
  121. ESC_REG(ST7796S_COLMOD), 0x0055,
  122. ESC_REG(ST7796S_DIC), 0x0001, // 1-dot inversion
  123. ESC_REG(ST7796S_EM), 0x00C6,
  124. ESC_REG(ST7796S_PWR2), 0x0015,
  125. ESC_REG(ST7796S_PWR3), 0x00AF,
  126. ESC_REG(ST7796S_VCMPCTL), 0x0022,
  127. ESC_REG(ST7796S_VCMOST), 0x0000,
  128. ESC_REG(ST7796S_DOCA), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033,
  129. /* Gamma Correction. */
  130. ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D,
  131. ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D,
  132. ESC_REG(ST7796S_NORON),
  133. ESC_REG(ST7796S_WRCTRLD), 0x0024,
  134. ESC_REG(ST7796S_CSCON), 0x003C, // disable command 2 part I
  135. ESC_REG(ST7796S_CSCON), 0x0069, // disable command 2 part II
  136. ESC_REG(ST7796S_DISPON),
  137. ESC_END
  138. };
  139. static const uint16_t lerdge_st7796s_init[] = {
  140. DATASIZE_8BIT,
  141. ESC_REG(ST7796S_CSCON), 0x00C3, // enable command 2 part I
  142. ESC_REG(ST7796S_CSCON), 0x0096, // enable command 2 part II
  143. ESC_REG(ST7796S_MADCTL), ST7796S_MADCTL_DATA,
  144. ESC_REG(ST7796S_COLMOD), 0x0055,
  145. ESC_REG(ST7796S_DIC), 0x0001, // 1-dot inversion
  146. ESC_REG(ST7796S_EM), 0x00C6,
  147. ESC_REG(ST7796S_PWR2), 0x0015,
  148. ESC_REG(ST7796S_PWR3), 0x00AF,
  149. ESC_REG(0xC3), 0x0009, // Register not documented in datasheet
  150. ESC_REG(ST7796S_VCMPCTL), 0x0022,
  151. ESC_REG(ST7796S_VCMOST), 0x0000,
  152. ESC_REG(ST7796S_DOCA), 0x0040, 0x008A, 0x0000, 0x0000, 0x0029, 0x0019, 0x00A5, 0x0033,
  153. /* Gamma Correction. */
  154. ESC_REG(ST7796S_PGC), 0x00F0, 0x0004, 0x0008, 0x0009, 0x0008, 0x0015, 0x002F, 0x0042, 0x0046, 0x0028, 0x0015, 0x0016, 0x0029, 0x002D,
  155. ESC_REG(ST7796S_NGC), 0x00F0, 0x0004, 0x0009, 0x0009, 0x0008, 0x0015, 0x002E, 0x0046, 0x0046, 0x0028, 0x0015, 0x0015, 0x0029, 0x002D,
  156. ESC_REG(ST7796S_INVON), // Display inversion ON
  157. ESC_REG(ST7796S_WRCTRLD), 0x0024,
  158. ESC_REG(ST7796S_CSCON), 0x003C, // disable command 2 part I
  159. ESC_REG(ST7796S_CSCON), 0x0069, // disable command 2 part II
  160. ESC_REG(ST7796S_DISPON),
  161. ESC_END
  162. };