mipi_lcd_ILI9806E.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. --- 模块功能:ILI9806E驱动芯片LCD命令配置
  2. -- @author openLuat
  3. -- @module ui.mipi_lcd_ILI9806E
  4. -- @license MIT
  5. -- @copyright openLuat
  6. -- @release 2018.03.27
  7. --[[
  8. 注意:MIPI接口
  9. module(...,package.seeall)
  10. ]]
  11. --[[
  12. 函数名:init
  13. 功能 :初始化LCD参数
  14. 参数 :无
  15. 返回值:无
  16. ]]
  17. local function init()
  18. local para =
  19. {
  20. width = 480, --分辨率宽度,
  21. height = 854, --分辨率高度
  22. bpp = 16, --MIPI LCD直接写16,暂不支持其他配置
  23. bus = disp.BUS_MIPI, --LCD专用SPI引脚接口,不可修改
  24. xoffset = 0, --X轴偏移
  25. yoffset = 0, --Y轴偏移
  26. freq = 125000000, --mipi时钟最高为500000000
  27. pinrst = pio.P0_18, --reset,复位引脚,MIPI屏幕必须填写
  28. pinrs = 0xffff, --mipi不需要rs脚,直接写0xffff
  29. --初始化命令
  30. --前两个字节表示类型:0001表示延时,0000或者0002表示命令,0003表示数据
  31. --延时类型:后两个字节表示延时时间(单位毫秒)
  32. --命令类型:后两个字节命令的值
  33. --数据类型:后两个字节数据的值
  34. --现在MIPI LCD 只支持,lane 2线,RGB565格式
  35. initcmd =
  36. {
  37. --ILI9806E 设置PAGE1指令
  38. 0x000200FF,0x000300FF,0x00030098,0x00030006,0x00030004,0x00030001,
  39. --ILI9806E Interface Mode Control 1
  40. 0x00020008,0x00030010, --bit[4]=SEPT_SDIO=SPI interface transfer data through SDI and SDO pins.
  41. --bitp[3]=SDO_STATUS =0: SDO has output enable , SDO pin output tri-state after data hold time period (timing “toh”).
  42. --ILI9806E CMD=0AH=Interface Mode Control 2 2LANE_EN Enable Data Lane1
  43. --ILI9806E Display Function Control 1
  44. 0x00020020,0x00030000,--bit[0]=SYNC_MODE=SYNC mode
  45. --ILI9806E Display Function Control 2
  46. 0x00020021,0x00030001, --bit[0]=EPL: DE polarity (“0”= Low enable, “1”= High enable)
  47. --bit[1]=DPL: PCLK polarity set (“0”=data fetched at the rising time, “1”=data fetched at the falling time)
  48. --bit[2]=HSPL: HS polarity (“0”=Low level sync clock, “1”=High level sync clock)
  49. --bit[3]=VSPL: VS polarity (“0”= Low level sync clock, “1”= High level sync clock)
  50. --ILI9806E Resolution Control
  51. 0x00020030,0x00030001, --bit[0-2]=480X854
  52. --000 480X864
  53. --001 480X854
  54. --010 480X800
  55. --011 480X640
  56. --100 480X720
  57. --ILI9806E Display Inversion Control
  58. 0x00020031,0x00030002, --bit[0-2]=Display inversion mode setting=2 dot inversion
  59. --ILI9806E Source Timing Adjust 1
  60. 0x00020060,0x00030007,
  61. --ILI9806E Source Timing Adjust 2
  62. 0x00020061,0x00030006,
  63. --ILI9806E Source Timing Adjust 3
  64. 0x00020062,0x00030006,
  65. --ILI9806E Source Timing Adjust 4
  66. 0x00020063,0x00030004,
  67. --ILI9806E CMD 0X40H ~ CMD 0X47H Power Control 1~8
  68. 0x00020040,0x00030018,
  69. 0x00020041,0x00030033,
  70. 0x00020042,0x00030011,
  71. 0x00020043,0x00030009,
  72. 0x00020044,0x0003000c,
  73. 0x00020046,0x00030055,
  74. 0x00020047,0x00030055,
  75. 0x00020045,0x00030014,
  76. --ILI9806E CMD 0X50H ~ CMD 0X53H VCOM Control 1~4
  77. 0x00020050,0x00030050,
  78. 0x00020051,0x00030050,
  79. 0x00020052,0x00030000,
  80. 0x00020053,0x00030038,
  81. --ILI9806E CMD 0XA0H ~ CMD 0XAFH Positive Gamma Control 1~16
  82. 0x000200A0,0x00030000,--// p gama
  83. 0x000200A1,0x00030009,
  84. 0x000200A2,0x0003000C,
  85. 0x000200A3,0x0003000F,
  86. 0x000200A4,0x00030006,
  87. 0x000200A5,0x00030009,
  88. 0x000200A6,0x00030007,
  89. 0x000200A7,0x00030016,
  90. 0x000200A8,0x00030006,
  91. 0x000200A9,0x00030009,
  92. 0x000200AA,0x00030011,
  93. 0x000200AB,0x00030006,
  94. 0x000200AC,0x0003000E,
  95. 0x000200AD,0x00030019,
  96. 0x000200AE,0x0003000E,
  97. 0x000200AF,0x00030000,
  98. --ILI9806E CMD 0XC0H ~ CMD 0XCFH Negative Gamma Correction 1~16
  99. 0x000200C0,0x00030000,--//n gama
  100. 0x000200C1,0x00030009,
  101. 0x000200C2,0x0003000C,
  102. 0x000200C3,0x0003000F,
  103. 0x000200C4,0x00030006,
  104. 0x000200C5,0x00030009,
  105. 0x000200C6,0x00030007,
  106. 0x000200C7,0x00030016,
  107. 0x000200C8,0x00030006,
  108. 0x000200C9,0x00030009,
  109. 0x000200CA,0x00030011,
  110. 0x000200CB,0x00030006,
  111. 0x000200CC,0x0003000E,
  112. 0x000200CD,0x00030019,
  113. 0x000200CE,0x0003000E,
  114. 0x000200CF,0x00030000,
  115. --ILI9806E 设置page0
  116. 0x000200FF,0x000300FF,0x00030098,0x00030006,0x00030004,0x00030000,
  117. --ILI9806E --display on
  118. 0x00020029,
  119. --ILI9806E 退出休眠
  120. 0x00020011,
  121. },
  122. --休眠命令
  123. sleepcmd = {
  124. 0x00020010,
  125. },
  126. --唤醒命令
  127. wakecmd = {
  128. 0x00020011,
  129. }
  130. }
  131. disp.init(para)
  132. disp.clear()
  133. disp.update()
  134. end
  135. -- VLCD电压域配置
  136. pmd.ldoset(15,pmd.LDO_VLCD)
  137. -- 背光配置
  138. function backlightopen(on)
  139. if on then
  140. pins.setup(pio.P0_13,1)
  141. log.info("mipi_lcd_ILI9806E 你打开了背光")
  142. else
  143. pins.setup(pio.P0_13,0)
  144. log.info("mipi_lcd_ILI9806E 你关闭了背光")
  145. end
  146. end
  147. backlightopen(true)
  148. -- 初始化
  149. init()