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.

st7789v.h 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 ST7789V_MADCTL_MY 0x80 // Row Address Order
  26. #define ST7789V_MADCTL_MX 0x40 // Column Address Order
  27. #define ST7789V_MADCTL_MV 0x20 // Row/Column Exchange
  28. #define ST7789V_MADCTL_ML 0x10 // Vertical Refresh Order
  29. #define ST7789V_MADCTL_BGR 0x08 // RGB-BGR ORDER
  30. #define ST7789V_MADCTL_RGB 0x00
  31. #define ST7789V_MADCTL_MH 0x04 // Horizontal Refresh Order
  32. #define ST7789V_ORIENTATION_UP ST7789V_MADCTL_MX | ST7789V_MADCTL_MY // 240x320 ; Cable on the upper side
  33. #define ST7789V_ORIENTATION_RIGHT ST7789V_MADCTL_MX | ST7789V_MADCTL_MV // 320x240 ; Cable on the right side
  34. #define ST7789V_ORIENTATION_LEFT ST7789V_MADCTL_MY | ST7789V_MADCTL_MV // 320x240 ; Cable on the left side
  35. #define ST7789V_ORIENTATION_DOWN 0 // 240x320 ; Cable on the lower side
  36. #define ST7789V_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ST7789V_MADCTL_MV) | \
  37. IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ST7789V_MADCTL_MX) | \
  38. IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ST7789V_MADCTL_MY)
  39. #if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB
  40. #define ST7789V_COLOR ST7789V_MADCTL_RGB
  41. #elif TFT_COLOR == TFT_COLOR_BGR
  42. #define ST7789V_COLOR ST7789V_MADCTL_BGR
  43. #endif
  44. #define ST7789V_MADCTL_DATA (ST7789V_ORIENTATION) | (ST7789V_COLOR)
  45. #define ST7789V_NOP 0x00 // No Operation
  46. #define ST7789V_SWRESET 0x01 // Software reset
  47. #define ST7789V_RDDID 0x04 // Read Display ID
  48. #define ST7789V_RDDST 0x09 // Read Display Status
  49. #define ST7789V_RDDPM 0x0A // Read Display Power Mode
  50. #define ST7789V_RDDMADCTL 0x0B // Read Display MADCTL
  51. #define ST7789V_RDDCOLMOD 0x0C // Read Display Pixel Format
  52. #define ST7789V_RDDIM 0x0D // Read Display Image Mode
  53. #define ST7789V_RDDSM 0x0E // Read Display Signal Mode
  54. #define ST7789V_RDDSDR 0x0F // Read Display Self-Diagnostic Result
  55. #define ST7789V_SLPIN 0x10 // Sleep In
  56. #define ST7789V_SLPOUT 0x11 // Sleep Out
  57. #define ST7789V_PTLON 0x12 // Partial Display Mode On
  58. #define ST7789V_NORON 0x13 // Normal Display Mode On
  59. #define ST7789V_INVOFF 0x20 // Display Inversion Off
  60. #define ST7789V_INVON 0x21 // Display Inversion On
  61. #define ST7789V_GAMSET 0x26 // Gamma Set
  62. #define ST7789V_DISPOFF 0x28 // Display Off
  63. #define ST7789V_DISPON 0x29 // Display On
  64. #define ST7789V_CASET 0x2A // Column Address Set
  65. #define ST7789V_RASET 0x2B // Row Address Set
  66. #define ST7789V_RAMWR 0x2C // Memory Write
  67. #define ST7789V_RAMRD 0x2E // Memory Read
  68. #define ST7789V_PTLAR 0x30 // Partial Area
  69. #define ST7789V_VSCRDEF 0x33 // Vertical Scrolling Definition
  70. #define ST7789V_TEOFF 0x34 // Tearing Effect Line OFF
  71. #define ST7789V_TEON 0x35 // Tearing Effect Line ON
  72. #define ST7789V_MADCTL 0x36 // Memory Data Access Control
  73. #define ST7789V_VSCSAD 0x37 // Vertical Scroll Start Address of RAM
  74. #define ST7789V_IDMOFF 0x38 // Idle Mode Off
  75. #define ST7789V_IDMON 0x39 // Idle Mode On
  76. #define ST7789V_COLMOD 0x3A // Interface Pixel Format
  77. #define ST7789V_WRMEMC 0x3C // Write Memory Continue
  78. #define ST7789V_RDMEMC 0x3E // Read Memory Continue
  79. #define ST7789V_STE 0x44 // Set Tear Scanline
  80. #define ST7789V_GSCAN 0x45 // Get Scanline
  81. #define ST7789V_WRDISBV 0x51 // Write Display Brightness
  82. #define ST7789V_RDDISBV 0x52 // Read Display Brightness
  83. #define ST7789V_WRCTRLD 0x53 // Write CTRL Display
  84. #define ST7789V_RDCTRLD 0x54 // Read CTRL Value Display
  85. #define ST7789V_WRCACE 0x55 // Write Content Adaptive Brightness Control and Color Enhancement
  86. #define ST7789V_RDCABC 0x56 // Read Content Adaptive Brightness Control
  87. #define ST7789V_WRCABCMB 0x5E // Write CABC Minimum Brightness
  88. #define ST7789V_RDCABCMB 0x5F // Read CABC Minimum Brightness
  89. #define ST7789V_RDABCSDR 0x68 // Read Automatic Brightness Control Self-Diagnostic Result
  90. #define ST7789V_RDID1 0xDA // Read ID1 Value
  91. #define ST7789V_RDID2 0xDB // Read ID2 Value
  92. #define ST7789V_RDID3 0xDC // Read ID3 Value
  93. #define ST7789V_RAMCTRL 0xB0 // RAM Control
  94. #define ST7789V_RGBCTRL 0xB1 // RGB Interface Control
  95. #define ST7789V_PORCTRL 0xB2 // Porch Setting
  96. #define ST7789V_FRCTRL1 0xB3 // Frame Rate Control 1 (In partial mode/ idle colors)
  97. #define ST7789V_GCTRL 0xB7 // Gate Control
  98. #define ST7789V_DGMEN 0xBA // Digital Gamma Enable
  99. #define ST7789V_VCOMS 0xBB // VCOM Setting
  100. #define ST7789V_LCMCTRL 0xC0 // LCM Control
  101. #define ST7789V_IDSET 0xC1 // ID Code Setting
  102. #define ST7789V_VDVVRHEN 0xC2 // VDV and VRH Command Enable
  103. #define ST7789V_VRHS 0xC3 // VRH Set
  104. #define ST7789V_VDVS 0xC4 // VDV Set
  105. #define ST7789V_VCMOFSET 0xC5 // VCOM Offset Set
  106. #define ST7789V_FRCTRL2 0xC6 // Frame Rate Control in Normal Mode
  107. #define ST7789V_CABCCTRL 0xC7 // CABC Control
  108. #define ST7789V_REGSEL1 0xC8 // Register Value Selection 1
  109. #define ST7789V_REGSEL2 0xCA // Register Value Selection 2
  110. #define ST7789V_PWMFRSEL 0xCC // PWM Frequency Selection
  111. #define ST7789V_PWCTRL1 0xD0 // Power Control 1
  112. #define ST7789V_VAPVANEN 0xD2 // Enable VAP/VAN signal output
  113. #define ST7789V_CMD2EN 0xDF // Command 2 Enable
  114. #define ST7789V_PVGAMCTRL 0xE0 // Positive Voltage Gamma Control
  115. #define ST7789V_NVGAMCTRL 0xE1 // Negative Voltage Gamma Control
  116. #define ST7789V_DGMLUTR 0xE2 // Digital Gamma Look-up Table for Red
  117. #define ST7789V_DGMLUTB 0xE3 // Digital Gamma Look-up Table for Blue
  118. #define ST7789V_GATECTRL 0xE4 // Gate Control
  119. #define ST7789V_SPI2EN 0xE7 // SPI2 Enable
  120. #define ST7789V_PWCTRL2 0xE8 // Power Control 2
  121. #define ST7789V_EQCTRL 0xE9 // Equalize time control
  122. #define ST7789V_PROMCTRL 0xEC // Program Mode Control
  123. #define ST7789V_PROMEN 0xFA // Program Mode Enable
  124. #define ST7789V_NVMSET 0xFC // NVM Setting
  125. #define ST7789V_PROMACT 0xFE // Program action
  126. static const uint16_t st7789v_init[] = {
  127. DATASIZE_8BIT,
  128. ESC_REG(ST7789V_SWRESET), ESC_DELAY(100),
  129. ESC_REG(ST7789V_SLPOUT), ESC_DELAY(20),
  130. ESC_REG(ST7789V_PORCTRL), 0x000C, 0x000C, 0x0000, 0x0033, 0x0033,
  131. ESC_REG(ST7789V_GCTRL), 0x0035,
  132. ESC_REG(ST7789V_VCOMS), 0x001F,
  133. ESC_REG(ST7789V_LCMCTRL), 0x002C,
  134. ESC_REG(ST7789V_VDVVRHEN), 0x0001, 0x00C3,
  135. ESC_REG(ST7789V_VDVS), 0x0020,
  136. ESC_REG(ST7789V_FRCTRL2), 0x000F,
  137. ESC_REG(ST7789V_PWCTRL1), 0x00A4, 0x00A1,
  138. ESC_REG(ST7789V_MADCTL), ST7789V_MADCTL_DATA,
  139. ESC_REG(ST7789V_COLMOD), 0x0055,
  140. ESC_REG(ST7789V_NORON),
  141. ESC_REG(ST7789V_DISPON),
  142. ESC_END
  143. };