sd1329.h 18 KB

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