sd1329.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /****************************************************************************
  2. * drivers/lcd/sd1329.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __DRIVERS_LCD_SD1329_H
  21. #define __DRIVERS_LCD_SD1329_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. #include <stdint.h>
  27. /****************************************************************************
  28. * Pre-processor Definitions
  29. ****************************************************************************/
  30. /* SD1329 Commands **********************************************************/
  31. /* Set column Address.
  32. *
  33. * This triple byte command specifies column start address and end address of
  34. * the display data RAM. This command also sets the column address pointer to
  35. * column start address. This pointer is used to define the current
  36. * read/write column address in graphic display data RAM. If horizontal
  37. * address increment mode is enabled by command 0xa0, after finishing
  38. * read/write one column data, it is incremented automatically to the next
  39. * column address. Whenever the column address pointer finishes accessing the
  40. * end column address, it is reset back to start column address and the row
  41. * address is incremented to the next row.
  42. *
  43. * Byte 1: 0x15
  44. * Byte 2: A[5:0]: Start Address, range: 0x00-0x3f
  45. * Byte 3: B[5:0]: End Address, range: 0x00-0x3f
  46. */
  47. #define SSD1329_SET_COLADDR 0x15
  48. /* Set Row Address.
  49. *
  50. * This triple byte command specifies row start address and end address of
  51. * the display data RAM. This command also sets the row address pointer to
  52. * row start address. This pointer is used to define the current read/write
  53. * row address in graphic display data RAM. If vertical address increment
  54. * mode is enabled by command 0xa0, after finishing read/write one row data,
  55. * it is incremented automatically to the next row address. Whenever the row
  56. * address pointer finishes accessing the end row address, it is reset back
  57. * to start row address.
  58. *
  59. * Byte 1: 0x75
  60. * Byte 2: A[6:0]: Start Address, range: 0x00-0x7f
  61. * Byte 3: B[6:0]: End Address, range: 0x00-0x7f
  62. */
  63. #define SSD1329_SET_ROWADDR 0x75
  64. /* Set Contract Current
  65. *
  66. * This double byte command is to set Contrast Setting of the display. The
  67. * chip has 256 contrast steps from 0x00 to 0xff. The segment output current
  68. * increases linearly with the increase of contrast step.
  69. *
  70. * Byte 1: 0x81
  71. * Byte 2: A[7:0]: Contrast Value, range: 0-255
  72. */
  73. #define SSD1329_SET_CONTRAST 0x81
  74. /* Set Second Pre-Charge Speed
  75. *
  76. * This command is used to set the speed of second pre-charge in phase 3.
  77. * This speed can be doubled to achieve faster pre-charging through setting
  78. * 0x82 A[0].
  79. *
  80. * Byte 1: 0x82
  81. * Byte 2: A[7:1]: Second Pre-charge Speed
  82. * A[0] = 1, Enable doubling the Second Pre-charge speed
  83. */
  84. #define SSD1329_PRECHRG2_SPEED 0x82
  85. # define SSD1329_PRECHRG2_DBL 0x01
  86. /* Set Master Icon Control
  87. *
  88. * This double command is used to set the ON / OFF conditions of internal
  89. * charge pump, icon circuits and overall icon status.
  90. *
  91. * Byte 1: 0x90
  92. * Byte 2: Icon control (OR of bits 0-1,4-5)
  93. */
  94. #define SSD1329_ICON_CONTROL 0x90
  95. # define SSD1329_ICON_NORMAL 0x00 /* A[1:0]1=00: Icon RESET to normal display */
  96. # define SSD1329_ICON_ALLON 0x01 /* A[1:0]1=01: Icon All ON */
  97. # define SSD1329_ICON_ALLOFF 0x02 /* A[1:0]=10: Icon All OFF */
  98. # define SSD1329_ICON_DISABLE 0x00 /* A[4]=0: Disable Icon display */
  99. # define SSD1329_ICON_ENABLE 0x10 /* A[4]=1: Enable Icon display */
  100. # define SSD1329_VICON_DISABLE 0x00 /* A[5]=0: Disable VICON charge pump circuit */
  101. # define SSD1329_VICON_ENABLE 0x20 /* A[5]=1: Enable VICON charge pump circuit */
  102. /* Set Icon Current Range
  103. *
  104. * This double byte command is used to set one fix current range for all
  105. * icons between the range of 0uA and 127.5uA. The uniformity improves as
  106. * the icon current range increases.
  107. *
  108. * Byte 1: 0x91
  109. * Byte 2: A[7:0]: Max icon current:
  110. * 00 = 0.0 uA
  111. * 01 = 0.5 uA
  112. * ...
  113. * ff = 127.5 uA
  114. */
  115. #define SSD1329_ICON_CURRRNG 0x91
  116. /* Set Individual Icon Current
  117. *
  118. * This multiple byte command is used to fine tune the current for each of
  119. * the 64 icons. Command 0x92 followed by 64 single byte data. These 64 byte
  120. * data have to be entered in order to make this command function. Below is
  121. * the formula for calculating the icon current.
  122. *
  123. * Icon Current = Single byte value / 127 x Maximum icon current set with
  124. * command 0x91
  125. *
  126. * Byte 1: 0x92
  127. * Byte 2-65: An[6:0]: icon current for ICSn, range: 0x00-0x7f
  128. * Icon Current of ICSn = An[6:0]/127) x max icon current
  129. */
  130. #define SSD1329_ICON_CURRENT 0x92
  131. /* Set Individual Icon ON / OFF Register
  132. *
  133. * This double byte command is used to select one of the 64 icons and choose
  134. * the ON, OFF or blinking condition of the selected icon.
  135. *
  136. * Byte 1: 0x93
  137. * Byte 2: A[5:0]: Select one of the 64 icons from ICS0 ~ ICS63
  138. * A[7:6]: OFF/ON/BLINK
  139. */
  140. #define SSD1329_ICON_SELECT 0x93
  141. # define SSD1329_ICON_OFF 0x00
  142. # define SSD1329_ICON_ON 0x40
  143. # define SSD1329_ICON_BLINK 0xc0
  144. /* Set Icon ON / OFF Registers
  145. *
  146. * This double byte command is used to set the ON / OFF status of all 64
  147. * icons.
  148. *
  149. * Byte 1: 0x94
  150. * Byte 2: A[7:6]: OFF/ON/BLINK (Same as 0x93)
  151. */
  152. #define SSD1329_ICON_ALL 0x94
  153. /* Set Icon Blinking Cycle
  154. *
  155. * This double byte command is used to set icon oscillator frequency and
  156. * blinking cycle selected with above command 0x93.
  157. *
  158. * Byte 1: 0x95
  159. * Byte 2:
  160. * - A[2:0]:Icon Blinking cycle
  161. * - A[5:4]:Icon oscillation frequency
  162. */
  163. #define SSD1329_ICON_BLINKING 0x95
  164. # define SSD1329_ICON_BLINK_0p25S 0x00 /* 0.25 sec */
  165. # define SSD1329_ICON_BLINK_0p50S 0x01 /* 0.50 sec */
  166. # define SSD1329_ICON_BLINK_0p75S 0x02 /* 0.75 sec */
  167. # define SSD1329_ICON_BLINK_0p100S 0x03 /* 1.00 sec */
  168. # define SSD1329_ICON_BLINK_0p125S 0x04 /* 1.25 sec */
  169. # define SSD1329_ICON_BLINK_0p150S 0x05 /* 1.50 sec */
  170. # define SSD1329_ICON_BLINK_0p175S 0x06 /* 1.75 sec */
  171. # define SSD1329_ICON_BLINK_0p200S 0x07 /* 2.00 sec */
  172. # define SSD1329_ICON_BLINK_61KHZ 0x00 /* 61 KHz */
  173. # define SSD1329_ICON_BLINK_64KHZ 0x10 /* 64 KHz */
  174. # define SSD1329_ICON_BLINK_68KHZ 0x20 /* 68 KHz */
  175. # define SSD1329_ICON_BLINK_73KHZ 0x30 /* 73 KHz */
  176. /* Set Icon Duty
  177. *
  178. * This double byte command is used to set the icon frame frequency and icon
  179. * AC drive duty ratio.
  180. *
  181. * Byte 1: 0x96
  182. * Byte 2:
  183. * - A[2:0]: AC Drive
  184. * - A[7:4]: con frame frequency
  185. */
  186. #define SSD1329_ICON_ACDRIVE 0x96
  187. # define SSD1329_ICON_DUTY_DC 0x00
  188. # define SSD1329_ICON_DUTY_63_64 0x01
  189. # define SSD1329_ICON_DUTY_62_64 0x02
  190. # define SSD1329_ICON_DUTY_61_64 0x03
  191. # define SSD1329_ICON_DUTY_60_64 0x04
  192. # define SSD1329_ICON_DUTY_59_64 0x05
  193. # define SSD1329_ICON_DUTY_58_64 0x06
  194. # define SSD1329_ICON_DUTY_57_64 0x07
  195. /* Set Re-map
  196. *
  197. * This double command has multiple configurations and each bit setting is
  198. * described as follows:
  199. *
  200. * Column Address Remapping (A[0])
  201. * This bit is made for increase the flexibility layout of segment signals
  202. * in OLED module with segment arranged from left to right (when A[0] is
  203. * set to 0) or from right to left (when A[0] is set to 1).
  204. *
  205. * Nibble Remapping (A[1])
  206. * When A[1] is set to 1, the two nibbles of the data bus for RAM access
  207. * are re-mapped, such that (D7, D6, D5, D4, D3, D2, D1, D0) acts like
  208. * (D3, D2, D1, D0, D7, D6, D5, D4) If this feature works together with
  209. * Column Address Re-map, it would produce an effect of flipping the
  210. * outputs from SEG0-127 to SEG127-SEG0.
  211. *
  212. * Address increment mode (A[2])
  213. * When A[2] is set to 0, the driver is set as horizontal address incremen
  214. * mode. After the display RAM is read/written, the column address pointer
  215. * is increased automatically by 1. If the column address pointer reaches
  216. * column end address, the column address pointer is reset to column start
  217. * address and row address pointer is increased by 1.
  218. *
  219. * When A[2] is set to 1, the driver is set to vertical address increment
  220. * mode.
  221. * After the display RAM is read/written, the row address pointer is
  222. * increased automatically by 1. If the row address pointer reaches the row
  223. * end address, the row address pointer is reset to row start address and
  224. * column address pointer is increased by 1.
  225. *
  226. * COM Remapping (A[4])
  227. * This bit defines the scanning direction of the common for flexible
  228. * layout of common signals in OLED module either from up to down (when
  229. * A[4] is set to 0) or from bottom to up (when A[4] is set to 1).
  230. *
  231. * Splitting of Odd / Even COM Signals (A[6])
  232. * This bit is made to match the COM layout connection on the panel.
  233. * When A[6] is set to 0, no splitting odd / even of the COM signal is
  234. * performed. When A[6] is set to 1, splitting odd / even of the COM signal
  235. * is performed, output pin assignment sequence is shown as below
  236. * (for 128MUX ratio):
  237. *
  238. * Byte 1: 0xa0
  239. * Byte 2: A[7:0]
  240. */
  241. #define SSD1329_GDDRAM_REMAP 0xa0
  242. # define SSD1329_COLADDR_REMAP 0x01 /* A[0]: Enable column re-map */
  243. # define SSD1329_NIBBLE_REMAP 0x02 /* A[1]: Enable nibble re-map */
  244. # define SSD1329_VADDR_INCR 0x04 /* A[1]: Enable vertical address increment */
  245. # define SSD1329_COM_REMAP 0x10 /* A[4]: Enable COM re-map */
  246. # define SSD1329_COM_SPLIT 0x40 /* A[6]: Enable COM slip even/odd */
  247. /* Set Display Start Line
  248. *
  249. * This double byte command is to set Display Start Line register for
  250. * determining the starting address of display RAM to be displayed by
  251. * selecting a value from 0 to 127.
  252. *
  253. * Byte 1: 0xa1
  254. * Byte 2: A[6:0]: Vertical scroll by setting the starting address of
  255. * display RAM from 0-127
  256. */
  257. #define SSD1329_VERT_START 0xa1
  258. /* Set Display Offset
  259. *
  260. * This double byte command specifies the mapping of display start line
  261. * (it is assumed that COM0 is the display start line, display start line
  262. * register equals to 0) to one of COM0-COM127.
  263. *
  264. * Byte 1: 0xa2
  265. * Byte 2: A[6:0]: Set vertical offset by COM from 0-127
  266. */
  267. #define SSD1329_VERT_OFFSET 0xa2
  268. /* Set Display Mode - Normal, all on, all off, inverse
  269. *
  270. * These are single byte commands and are used to set display status to
  271. * Normal Display, Entire Display ON, Entire Display OFF or Inverse Display.
  272. *
  273. * Normal Display (0xa4)
  274. * Reset the “Entire Display ON, Entire Display OFF or Inverse Display”
  275. * effects and turn the data to ON at the corresponding gray level.
  276. *
  277. * Set Entire Display ON (0xa5)
  278. * Force the entire display to be at gray scale level GS15, regardless
  279. * of the contents of the display data RAM.
  280. *
  281. * Set Entire Display OFF (0xa6)
  282. * Force the entire display to be at gray scale level GS0, regardless
  283. * of the contents of the display data RAM.
  284. *
  285. * Inverse Display (0xa7)
  286. * The gray scale level of display data are swapped such that
  287. * “GS0” <-> “GS15”, “GS1” <-> “GS14”, etc.
  288. *
  289. * Byte 1: Display mode command
  290. */
  291. #define SSD1329_DISP_NORMAL 0xa4
  292. #define SSD1329_DISP_OFF 0xa5
  293. #define SSD1329_DISP_ON 0xa6
  294. #define SSD1329_DISP_INVERT 0xa7
  295. /* Set MUX Ratio
  296. *
  297. * This double byte command sets multiplex ratio (MUX ratio) from 16MUX to
  298. * 128MUX. In POR, multiplex ratio is 128MUX.
  299. *
  300. * Byte 1: 0xa8
  301. * Byte 2: A[6:0] 15-127 representing 16-128 MUX
  302. */
  303. #define SSD1329_MUX_RATIO 0xa8
  304. /* Set Sleep mode ON / OFF
  305. *
  306. * These single byte commands are used to turn the matrix display on the OLED
  307. * panel display either ON or OFF. When the sleep mode is set to ON (0xae),
  308. * the display is OFF, the segment and common output are in high impedance
  309. * state and circuits will be turned OFF. When the sleep mode is set to OFF
  310. * (0xaf), the display is ON.
  311. *
  312. * Byte 1: sleep mode command
  313. */
  314. #define SSD1329_SLEEP_ON 0xae
  315. #define SSD1329_SLEEP_OFF 0xaf
  316. /* Set Phase Length
  317. *
  318. * In the second byte of this double command, lower nibble and higher nibble
  319. * is defined separately. The lower nibble adjusts the phase length of Reset
  320. * (phase 1). The higher nibble is used to select the phase length of first
  321. * pre-charge phase (phase 2). The phase length is ranged from 1 to 16
  322. * DCLK's. RESET for A[3:0] is set to 3 which means 4 DCLK’s selected for
  323. * Reset phase. POR for A[7:4] is set to 5 which means 6 DCLK’s is selected
  324. * for first pre-charge phase.
  325. * Please refer to Table 9-1 for detail breakdown levels of each step.
  326. *
  327. * Byte 1: 0xb1
  328. * Byte 2: A[3:0]: Phase 1 period of 1~16 DCLK’s
  329. * A[7:4]: Phase 2 period of 1~16 DCLK’s
  330. */
  331. #define SSD1329_PHASE_LENGTH 0xb1
  332. /* Set Frame Frequency
  333. *
  334. * This double byte command is used to set the number of DCLK’s per row
  335. * between the range of 0x14 and 0x7f. Then the Frame frequency of the
  336. * matrix display is equal to DCLK frequency / A[6:0].
  337. *
  338. * Byte 1: 0xb2
  339. * Byte 2: A[6:0]:Total number of DCLK’s per row. Ranging from
  340. * 0x14 to 0x4e DCLK’s. frame Frequency = DCLK freq /A[6:0].
  341. */
  342. #define SSD1329_FRAME_FREQ 0xb2
  343. /* Set Front Clock Divider / Oscillator Frequency
  344. *
  345. * This double command is used to set the frequency of the internal display
  346. * clocks, DCLK's. It is defined by dividing the oscillator frequency by the
  347. * divide ratio (Value from 1 to 16). Frame frequency is determined by divide
  348. * ratio, number of display clocks per row, MUX ratio and oscillator
  349. * frequency.
  350. * The lower nibble of the second byte is used to select the oscillator
  351. * frequency. Please refer to Table 9-1 for detail breakdown levels of each
  352. * step.
  353. *
  354. * Byte 1: 0xb3
  355. * Byte 2: A[3:0]: Define divide ratio (D) of display clock (DCLK)
  356. * Divide ratio=A[3:0]+1
  357. * A[7:4] : Set the Oscillator Frequency, FOSC. Range:0-15
  358. */
  359. #define SSD1329_DCLK_DIV 0xb3
  360. /* Set Default Gray Scale Table
  361. *
  362. * This single byte command is used to set the gray scale table to initial
  363. * default setting.
  364. *
  365. * Byte 1: 0xb7
  366. */
  367. #define SSD1329_GSCALE_TABLE 0xb7
  368. /* Look Up Table for Gray Scale Pulse width
  369. *
  370. * This command is used to set each individual gray scale level for the
  371. * display.
  372. * Except gray scale level GS0 that has no pre-charge and current drive, each
  373. * gray scale level is programmed in the length of current drive stage pulse
  374. * width with unit of DCLK. The longer the length of the pulse width, the
  375. * brighter the OLED pixel when it’s turned ON.
  376. *
  377. * The setting of gray scale table entry can perform gamma correction on OLED
  378. * panel display. Normally, it is desired that the brightness response of the
  379. * panel is linearly proportional to the image data value in display data
  380. * RAM. However, the OLED panel is somehow responded in non-linear way.
  381. * Appropriate gray scale table setting like example below can compensate
  382. * this effect.
  383. *
  384. * Byte 1: 0xb8
  385. * Bytes 2-16: An[5:0], value for GSn level Pulse width
  386. */
  387. #define SSD1329_GSCALE_LOOKUP 0xb8
  388. /* Set Second Pre-charge Period
  389. *
  390. * This double byte command is used to set the phase 3 second pre-charge
  391. * period. The period of phase 3 can be programmed by command 0xbb and it
  392. * is ranged from 0 to 15 DCLK's.
  393. *
  394. * Byte 1: 0xbb
  395. * Byte 2: 0-15 DCLKs
  396. */
  397. #define SSD1329_PRECHRG2_PERIOD 0xbb
  398. /* Set First Precharge voltage, VP
  399. *
  400. * This double byte command is used to set phase 2 first pre-charge voltage
  401. * level. It can be programmed to set the first pre-charge voltage reference
  402. * to VCC or VCOMH.
  403. *
  404. * Byte 1: 0xbc
  405. * Byte 2: A[5] == 0, Pre-charge voltage is (0.30 + A[4:0]) * Vcc
  406. * A{5] == 1, 1.00 x VCC or connect to VCOMH if VCC > VCOMH
  407. */
  408. #define SSD1329_PRECHRG1_VOLT 0xbc
  409. /* Set VCOMH
  410. *
  411. * This double byte command sets the high voltage level of common pins,
  412. * VCOMH. The level of VCOMH is programmed with reference to VCC.
  413. *
  414. * Byte 1: 0xbe
  415. * Byte 2: (0.51 + A[5:0]) * Vcc
  416. */
  417. #define SSD1329_COM_HIGH 0xbe
  418. /* NOOP
  419. *
  420. * This is a no operation command.
  421. *
  422. * Byte 1: 0xe3
  423. */
  424. #define SSD1329_NOOP 0xe3
  425. /* Set Command Lock
  426. *
  427. * This command is used to lock the MCU from accepting any command.
  428. *
  429. * Byte 1: 0xfd
  430. * Byte 2: 0x12 | A[2]
  431. * A[2] == 1, Enable locking the MCU from entering command
  432. */
  433. #define SSD1329_CMD_LOCK 0xfd
  434. # define SSD1329_LOCK_ON 0x13
  435. # define SSD1329_LOCK_OFF 0x12
  436. /* SD1329 Status ************************************************************/
  437. #define SDD1329_STATUS_ON 0x00 /* D[6]=0: indicates the display is ON */
  438. #define SDD1329_STATUS_OFF 0x40 /* D[6]=1: indicates the display is OFF */
  439. /****************************************************************************
  440. * Public Types
  441. ****************************************************************************/
  442. /****************************************************************************
  443. * Public Functions Definitions
  444. ****************************************************************************/
  445. #undef EXTERN
  446. #if defined(__cplusplus)
  447. #define EXTERN extern "C"
  448. extern "C"
  449. {
  450. #else
  451. #define EXTERN extern
  452. #endif
  453. #undef EXTERN
  454. #if defined(__cplusplus)
  455. }
  456. #endif
  457. #endif /* __DRIVERS_LCD_SD1329_H */