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.

ili9488.h 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 ILI9488_MADCTL_MY 0x80 // Row Address Order
  26. #define ILI9488_MADCTL_MX 0x40 // Column Address Order
  27. #define ILI9488_MADCTL_MV 0x20 // Row/Column Exchange
  28. #define ILI9488_MADCTL_ML 0x10 // Vertical Refresh Order
  29. #define ILI9488_MADCTL_BGR 0x08 // RGB-BGR ORDER
  30. #define ILI9488_MADCTL_RGB 0x00
  31. #define ILI9488_MADCTL_MH 0x04 // Horizontal Refresh Order
  32. #define ILI9488_ORIENTATION_UP ILI9488_MADCTL_MY // 320x480 ; Cable on the upper side
  33. #define ILI9488_ORIENTATION_RIGHT ILI9488_MADCTL_MV // 480x320 ; Cable on the right side
  34. #define ILI9488_ORIENTATION_LEFT ILI9488_MADCTL_MY | ILI9488_MADCTL_MX | ILI9488_MADCTL_MV // 480x320 ; Cable on the left side
  35. #define ILI9488_ORIENTATION_DOWN ILI9488_MADCTL_MX // 320x480 ; Cable on the upper side
  36. #define ILI9488_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9488_MADCTL_MV) | \
  37. IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9488_MADCTL_MX) | \
  38. IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9488_MADCTL_MY)
  39. #if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
  40. #define ILI9488_COLOR ILI9488_MADCTL_BGR
  41. #elif TFT_COLOR == TFT_COLOR_RGB
  42. #define ILI9488_COLOR ILI9488_MADCTL_RGB
  43. #endif
  44. #define ILI9488_MADCTL_DATA (ILI9488_ORIENTATION) | (ILI9488_COLOR)
  45. #define ILI9488_NOP 0x00 // No Operation
  46. #define ILI9488_SWRESET 0x01 // Software Reset
  47. #define ILI9488_RDDIDIF 0x04 // Read Display Identification Information
  48. #define ILI9488_RDNUMED 0x05 // Read Number of the Errors on DSI
  49. #define ILI9488_RDDST 0x09 // Read Display Status
  50. #define ILI9488_RDDPM 0x0A // Read Display Power Mode
  51. #define ILI9488_RDDMADCTL 0x0B // Read Display MADCTL
  52. #define ILI9488_RDDCOLMOD 0x0C // Read Display COLMOD
  53. #define ILI9488_RDDIM 0x0D // Read Display Image Mode
  54. #define ILI9488_RDDSM 0x0E // Read Display Signal Mode
  55. #define ILI9488_RDDSDR 0x0F // Read Display Self-Diagnostic Result
  56. #define ILI9488_SLPIN 0x10 // Sleep IN
  57. #define ILI9488_SLPOUT 0x11 // Sleep OUT
  58. #define ILI9488_PTLON 0x12 // Partial Mode ON
  59. #define ILI9488_NORON 0x13 // Normal Display Mode ON
  60. #define ILI9488_INVOFF 0x20 // Display Inversion OFF
  61. #define ILI9488_INVON 0x21 // Display Inversion ON
  62. #define ILI9488_ALLPOFF 0x22 // All Pixels OFF
  63. #define ILI9488_ALLPON 0x23 // All Pixels ON
  64. #define ILI9488_DISOFF 0x28 // Display OFF
  65. #define ILI9488_DISON 0x29 // Display ON
  66. #define ILI9488_CASET 0x2A // Column Address Set
  67. #define ILI9488_PASET 0x2B // Page Address Set
  68. #define ILI9488_RAMWR 0x2C // Memory Write
  69. #define ILI9488_RAMRD 0x2E // Memory Read
  70. #define ILI9488_PLTAR 0x30 // Partial Area
  71. #define ILI9488_VSCRDEF 0x33 // Vertical Scrolling Definition
  72. #define ILI9488_TEOFF 0x34 // Tearing Effect Line OFF
  73. #define ILI9488_TEON 0x35 // Tearing Effect Line ON
  74. #define ILI9488_MADCTL 0x36 // Memory Access Control
  75. #define ILI9488_VSCRSADD 0x37 // Vertical Scrolling Start Address
  76. #define ILI9488_IDMOFF 0x38 // Idle Mode OFF
  77. #define ILI9488_IDMON 0x39 // Idle Mode ON
  78. #define ILI9488_COLMOD 0x3A // Interface Pixel Format
  79. #define ILI9488_RAMWRC 0x3C // Memory Write Continue
  80. #define ILI9488_RAMRDRC 0x3E // Memory Read Continue
  81. #define ILI9488_TESLWR 0x44 // Write Tear Scan Line
  82. #define ILI9488_TESLRD 0x45 // Read Scan Line
  83. #define ILI9488_WRDISBV 0x51 // Write Display Brightness Value
  84. #define ILI9488_RDDISBV 0x52 // Read Display Brightness Value
  85. #define ILI9488_WRCTRLD 0x53 // Write Control Display Value
  86. #define ILI9488_RDCTRLD 0x54 // Read Control Display Value
  87. #define ILI9488_WRCABC 0x55 // Write Content Adaptive Brightness Control Value
  88. #define ILI9488_RDCABC 0x56 // Read Content Adaptive Brightness Control Value
  89. #define ILI9488_WRCABCMB 0x5E // Write CABC Minimum Brightness
  90. #define ILI9488_RDCABCMB 0x5F // Read CABC Minimum Brightness
  91. #define ILI9488_RDABCSDR 0x68 // Read Automatic Brightness Control Self-diagnostic Result
  92. #define ILI9488_RDID1 0xDA // Read ID1
  93. #define ILI9488_RDID2 0xDB // Read ID2
  94. #define ILI9488_RDID3 0xDC // Read ID3
  95. #define ILI9488_IFMODE 0xB0 // Interface Mode Control
  96. #define ILI9488_FRMCTR1 0xB1 // Frame Rate Control (In Normal Mode/Full Colors)
  97. #define ILI9488_FRMCTR2 0xB2 // Frame Rate Control (In Idle Mode/8 Colors)
  98. #define ILI9488_FRMCTR3 0xB3 // Frame Rate Control (In Partial Mode/Full Colors)
  99. #define ILI9488_INVTR 0xB4 // Display Inversion Control
  100. #define ILI9488_PRCTR 0xB5 // Blanking Porch Control
  101. #define ILI9488_DISCTRL 0xB6 // Display Function Control
  102. #define ILI9488_ETMOD 0xB7 // Entry Mode Set
  103. #define ILI9488_CECTRL1 0xB9 // Color Enhancement Control 1
  104. #define ILI9488_CECTRL2 0xBA // Color Enhancement Control 2
  105. #define ILI9488_HSLCTRL 0xBE // HS Lanes Control
  106. #define ILI9488_PWCTRL1 0xC0 // Power Control 1
  107. #define ILI9488_PWCTRL2 0xC1 // Power Control 2
  108. #define ILI9488_PWCTRL3 0xC2 // Power Control 3 (For Normal Mode)
  109. #define ILI9488_PWCTRL4 0xC3 // Power Control 4 (For Idle Mode)
  110. #define ILI9488_PWCTRL5 0xC4 // Power Control 5 (For Partial Mode)
  111. #define ILI9488_VMCTRL 0xC5 // VCOM Control
  112. #define ILI9488_CABCCTRL1 0xC6 // CABC Control 1
  113. #define ILI9488_CABCCTRL2 0xC8 // CABC Control 2
  114. #define ILI9488_CABCCTRL3 0xC9 // CABC Control 3
  115. #define ILI9488_CABCCTRL4 0xCA // CABC Control 4
  116. #define ILI9488_CABCCTRL5 0xCB // CABC Control 5
  117. #define ILI9488_CABCCTRL6 0xCC // CABC Control 6
  118. #define ILI9488_CABCCTRL7 0xCD // CABC Control 7
  119. #define ILI9488_CABCCTRL8 0xCE // CABC Control 8
  120. #define ILI9488_CABCCTRL9 0xCF // CABC Control 9
  121. #define ILI9488_NVMWR 0xD0 // NV Memory Write
  122. #define ILI9488_NVMPKEY 0xD1 // NV Memory Protection Key
  123. #define ILI9488_RDNVM 0xD2 // NV Memory Status Read
  124. #define ILI9488_RDID4 0xD3 // Read ID4 - 0x009488
  125. #define ILI9488_ADJCTL1 0xD7 // Adjust Control 1
  126. #define ILI9488_RDIDV 0xD8 // Read ID Version
  127. #define ILI9488_PGAMCTRL 0xE0 // Positive Gamma Control
  128. #define ILI9488_NGAMCTRL 0xE1 // Negative Gamma Control
  129. #define ILI9488_DGAMCTRL1 0xE2 // Ditigal Gamma Control 1
  130. #define ILI9488_DGAMCTRL2 0xE3 // Ditigal Gamma Control 2
  131. #define ILI9488_SETIMAGE 0xE9 // Set Image Function
  132. #define ILI9488_ADJCTL2 0xF2 // Adjust Control 2
  133. #define ILI9488_ADJCTL3 0xF7 // Adjust Control 3
  134. #define ILI9488_ADJCTL4 0xF8 // Adjust Control 4
  135. #define ILI9488_ADJCTL5 0xF9 // Adjust Control 5
  136. #define ILI9488_RDEXTC 0xFB // Read EXTC command is SPI mode
  137. #define ILI9488_ADJCTL6 0xFC // Adjust Control 6
  138. #define ILI9488_ADJCTL7 0xFF // Adjust Control 7
  139. static const uint16_t ili9488_init[] = {
  140. DATASIZE_8BIT,
  141. ESC_REG(ILI9488_SWRESET), ESC_DELAY(120),
  142. ESC_REG(ILI9488_SLPOUT), ESC_DELAY(20),
  143. ESC_REG(ILI9488_MADCTL), ILI9488_MADCTL_DATA,
  144. ESC_REG(ILI9488_COLMOD), 0x0055,
  145. /* Gamma Correction. */
  146. ESC_REG(ILI9488_PGAMCTRL), 0x0000, 0x0003, 0x0009, 0x0008, 0x0016, 0x000A, 0x003F, 0x0078, 0x004C, 0x0009, 0x000A, 0x0008, 0x0016, 0x001A, 0x000F,
  147. ESC_REG(ILI9488_NGAMCTRL), 0x0000, 0x0016, 0x0019, 0x0003, 0x000F, 0x0005, 0x0032, 0x0045, 0x0046, 0x0004, 0x000E, 0x000D, 0x0035, 0x0037, 0x000F,
  148. ESC_REG(ILI9488_NORON),
  149. ESC_REG(ILI9488_DISON),
  150. ESC_END
  151. };