u8x8_d_t6963.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /*
  2. u8x8_d_t6963.c
  3. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  4. Copyright (c) 2016, olikraus@gmail.com
  5. All rights reserved.
  6. Redistribution and use in source and binary forms, with or without modification,
  7. are permitted provided that the following conditions are met:
  8. * Redistributions of source code must retain the above copyright notice, this list
  9. of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above copyright notice, this
  11. list of conditions and the following disclaimer in the documentation and/or other
  12. materials provided with the distribution.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  14. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  15. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  19. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. The t6963 controller does not support hardware graphics flip.
  27. Contrast adjustment is done by an external resistor --> no support for contrast adjustment
  28. */
  29. #include "u8x8.h"
  30. static const uint8_t u8x8_d_t6963_powersave0_seq[] = {
  31. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  32. U8X8_C(0x098), /* mode register: Display Mode, Graphics on, Text off, Cursor off */
  33. U8X8_END_TRANSFER(), /* disable chip */
  34. U8X8_END() /* end of sequence */
  35. };
  36. static const uint8_t u8x8_d_t6963_powersave1_seq[] = {
  37. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  38. U8X8_C(0x090), /* All Off */
  39. U8X8_END_TRANSFER(), /* disable chip */
  40. U8X8_END() /* end of sequence */
  41. };
  42. uint8_t u8x8_d_t6963_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  43. {
  44. uint8_t c, i;
  45. uint16_t y;
  46. uint8_t *ptr;
  47. switch(msg)
  48. {
  49. /* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
  50. /*
  51. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  52. break;
  53. case U8X8_MSG_DISPLAY_INIT:
  54. break;
  55. */
  56. case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
  57. if ( arg_int == 0 )
  58. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_powersave0_seq);
  59. else
  60. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_powersave1_seq);
  61. break;
  62. case U8X8_MSG_DISPLAY_DRAW_TILE:
  63. y = (((u8x8_tile_t *)arg_ptr)->y_pos);
  64. y*=8;
  65. y*= u8x8->display_info->tile_width;
  66. /* x = ((u8x8_tile_t *)arg_ptr)->x_pos; x is ignored... no u8x8 support */
  67. //u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
  68. u8x8_cad_StartTransfer(u8x8);
  69. //u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
  70. /*
  71. Tile structure is reused here for the t6963, however u8x8 is not supported
  72. tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles)
  73. Buffer is expected to have 8 lines of code fitting to the t6963 internal memory
  74. "cnt" includes the number of horizontal bytes. width is equal to cnt*8
  75. TODO: Consider arg_int, however arg_int is not used by u8g2
  76. */
  77. c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
  78. ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
  79. for( i = 0; i < 8; i++ )
  80. {
  81. u8x8_cad_SendArg(u8x8, y&255);
  82. u8x8_cad_SendArg(u8x8, y>>8);
  83. u8x8_cad_SendCmd(u8x8, 0x024 ); /* set adr */
  84. u8x8_cad_SendCmd(u8x8, 0x0b0 ); /* auto write start */
  85. //c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
  86. u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
  87. u8x8_cad_SendCmd(u8x8, 0x0b2 ); /* auto write reset */
  88. ptr += u8x8->display_info->tile_width;
  89. y += u8x8->display_info->tile_width;
  90. }
  91. u8x8_cad_EndTransfer(u8x8);
  92. //u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */
  93. break;
  94. default:
  95. return 0;
  96. }
  97. return 1;
  98. }
  99. /*=============================================*/
  100. static const u8x8_display_info_t u8x8_t6963_240x128_display_info =
  101. {
  102. /* chip_enable_level = */ 0,
  103. /* chip_disable_level = */ 1,
  104. /* post_chip_enable_wait_ns = */ 110, /* T6963 Datasheet p30 */
  105. /* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
  106. /* reset_pulse_width_ms = */ 1,
  107. /* post_reset_wait_ms = */ 6,
  108. /* sda_setup_time_ns = */ 20,
  109. /* sck_pulse_width_ns = */ 140,
  110. /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  111. /* spi_mode = */ 0,
  112. /* i2c_bus_clock_100kHz = */ 4,
  113. /* data_setup_time_ns = */ 80,
  114. /* write_pulse_width_ns = */ 80,
  115. /* tile_width = */ 30,
  116. /* tile_height = */ 16,
  117. /* default_x_offset = */ 0,
  118. /* flipmode_x_offset = */ 0,
  119. /* pixel_width = */ 240,
  120. /* pixel_height = */ 128
  121. };
  122. /* 240x128 */
  123. static const uint8_t u8x8_d_t6963_240x128_init_seq[] = {
  124. U8X8_DLY(100),
  125. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  126. U8X8_DLY(100),
  127. U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
  128. U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
  129. U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
  130. U8X8_AAC(240/8,0x00,0x041), /* low, high, set text columns */
  131. U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
  132. U8X8_AAC(240/8,0x00,0x043), /* low, high, graphics columns */
  133. U8X8_DLY(2), /* delay 2ms */
  134. // mode set
  135. // 0x080: Internal CG, OR Mode
  136. // 0x081: Internal CG, EXOR Mode
  137. // 0x083: Internal CG, AND Mode
  138. // 0x088: External CG, OR Mode
  139. // 0x089: External CG, EXOR Mode
  140. // 0x08B: External CG, AND Mode
  141. U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
  142. // display mode
  143. // 0x090: Display off
  144. // 0x094: Graphic off, text on, cursor off, blink off
  145. // 0x096: Graphic off, text on, cursor on, blink off
  146. // 0x097: Graphic off, text on, cursor on, blink on
  147. // 0x098: Graphic on, text off, cursor off, blink off
  148. // 0x09a: Graphic on, text off, cursor on, blink off
  149. // ...
  150. // 0x09c: Graphic on, text on, cursor off, blink off
  151. // 0x09f: Graphic on, text on, cursor on, blink on
  152. U8X8_C(0x090), /* All Off */
  153. U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
  154. U8X8_DLY(100),
  155. U8X8_END_TRANSFER(), /* disable chip */
  156. U8X8_DLY(100),
  157. };
  158. uint8_t u8x8_d_t6963_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  159. {
  160. switch(msg)
  161. {
  162. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  163. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_240x128_display_info);
  164. break;
  165. case U8X8_MSG_DISPLAY_INIT:
  166. u8x8_d_helper_display_init(u8x8);
  167. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_240x128_init_seq);
  168. break;
  169. default:
  170. return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
  171. }
  172. return 1;
  173. }
  174. /*=============================================*/
  175. static const u8x8_display_info_t u8x8_t6963_240x64_display_info =
  176. {
  177. /* chip_enable_level = */ 0,
  178. /* chip_disable_level = */ 1,
  179. /* post_chip_enable_wait_ns = */ 110, /* T6963 Datasheet p30 */
  180. /* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
  181. /* reset_pulse_width_ms = */ 1,
  182. /* post_reset_wait_ms = */ 6,
  183. /* sda_setup_time_ns = */ 20,
  184. /* sck_pulse_width_ns = */ 140,
  185. /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  186. /* spi_mode = */ 0,
  187. /* i2c_bus_clock_100kHz = */ 4,
  188. /* data_setup_time_ns = */ 80,
  189. /* write_pulse_width_ns = */ 80,
  190. /* tile_width = */ 30,
  191. /* tile_height = */ 8,
  192. /* default_x_offset = */ 0,
  193. /* flipmode_x_offset = */ 0,
  194. /* pixel_width = */ 240,
  195. /* pixel_height = */ 64
  196. };
  197. /* 240x64 */
  198. static const uint8_t u8x8_d_t6963_240x64_init_seq[] = {
  199. U8X8_DLY(100),
  200. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  201. U8X8_DLY(100),
  202. U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
  203. U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
  204. U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
  205. U8X8_AAC(240/8,0x00,0x041), /* low, high, set text columns */
  206. U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
  207. U8X8_AAC(240/8,0x00,0x043), /* low, high, graphics columns */
  208. U8X8_DLY(2), /* delay 2ms */
  209. // mode set
  210. // 0x080: Internal CG, OR Mode
  211. // 0x081: Internal CG, EXOR Mode
  212. // 0x083: Internal CG, AND Mode
  213. // 0x088: External CG, OR Mode
  214. // 0x089: External CG, EXOR Mode
  215. // 0x08B: External CG, AND Mode
  216. U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
  217. // display mode
  218. // 0x090: Display off
  219. // 0x094: Graphic off, text on, cursor off, blink off
  220. // 0x096: Graphic off, text on, cursor on, blink off
  221. // 0x097: Graphic off, text on, cursor on, blink on
  222. // 0x098: Graphic on, text off, cursor off, blink off
  223. // 0x09a: Graphic on, text off, cursor on, blink off
  224. // ...
  225. // 0x09c: Graphic on, text on, cursor off, blink off
  226. // 0x09f: Graphic on, text on, cursor on, blink on
  227. U8X8_C(0x090), /* All Off */
  228. U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
  229. U8X8_DLY(100),
  230. U8X8_END_TRANSFER(), /* disable chip */
  231. U8X8_DLY(100),
  232. };
  233. uint8_t u8x8_d_t6963_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  234. {
  235. switch(msg)
  236. {
  237. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  238. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_240x64_display_info);
  239. break;
  240. case U8X8_MSG_DISPLAY_INIT:
  241. u8x8_d_helper_display_init(u8x8);
  242. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_240x64_init_seq);
  243. break;
  244. default:
  245. return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
  246. }
  247. return 1;
  248. }
  249. /*=============================================*/
  250. static const u8x8_display_info_t u8x8_t6963_256x64_display_info =
  251. {
  252. /* chip_enable_level = */ 0,
  253. /* chip_disable_level = */ 1,
  254. /* post_chip_enable_wait_ns = */ 110, /* T6963 Datasheet p30 */
  255. /* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
  256. /* reset_pulse_width_ms = */ 1,
  257. /* post_reset_wait_ms = */ 6,
  258. /* sda_setup_time_ns = */ 20,
  259. /* sck_pulse_width_ns = */ 140,
  260. /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  261. /* spi_mode = */ 0,
  262. /* i2c_bus_clock_100kHz = */ 4,
  263. /* data_setup_time_ns = */ 80,
  264. /* write_pulse_width_ns = */ 80,
  265. /* tile_width = */ 32,
  266. /* tile_height = */ 8,
  267. /* default_x_offset = */ 0,
  268. /* flipmode_x_offset = */ 0,
  269. /* pixel_width = */ 256,
  270. /* pixel_height = */ 64
  271. };
  272. /* 256x64 */
  273. static const uint8_t u8x8_d_t6963_256x64_init_seq[] = {
  274. U8X8_DLY(100),
  275. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  276. U8X8_DLY(100),
  277. U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
  278. U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
  279. U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
  280. U8X8_AAC(256/8,0x00,0x041), /* low, high, set text columns */
  281. U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
  282. U8X8_AAC(256/8,0x00,0x043), /* low, high, graphics columns */
  283. U8X8_DLY(2), /* delay 2ms */
  284. // mode set
  285. // 0x080: Internal CG, OR Mode
  286. // 0x081: Internal CG, EXOR Mode
  287. // 0x083: Internal CG, AND Mode
  288. // 0x088: External CG, OR Mode
  289. // 0x089: External CG, EXOR Mode
  290. // 0x08B: External CG, AND Mode
  291. U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
  292. // display mode
  293. // 0x090: Display off
  294. // 0x094: Graphic off, text on, cursor off, blink off
  295. // 0x096: Graphic off, text on, cursor on, blink off
  296. // 0x097: Graphic off, text on, cursor on, blink on
  297. // 0x098: Graphic on, text off, cursor off, blink off
  298. // 0x09a: Graphic on, text off, cursor on, blink off
  299. // ...
  300. // 0x09c: Graphic on, text on, cursor off, blink off
  301. // 0x09f: Graphic on, text on, cursor on, blink on
  302. U8X8_C(0x090), /* All Off */
  303. U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
  304. U8X8_DLY(100),
  305. U8X8_END_TRANSFER(), /* disable chip */
  306. U8X8_DLY(100),
  307. };
  308. uint8_t u8x8_d_t6963_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  309. {
  310. switch(msg)
  311. {
  312. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  313. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_256x64_display_info);
  314. break;
  315. case U8X8_MSG_DISPLAY_INIT:
  316. u8x8_d_helper_display_init(u8x8);
  317. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_256x64_init_seq);
  318. break;
  319. default:
  320. return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
  321. }
  322. return 1;
  323. }
  324. /*=============================================*/
  325. static const u8x8_display_info_t u8x8_t6963_128x64_display_info =
  326. {
  327. /* chip_enable_level = */ 1,
  328. /* chip_disable_level = */ 0,
  329. /* post_chip_enable_wait_ns = */ 10, /* T6963 Datasheet p30 */
  330. /* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
  331. /* reset_pulse_width_ms = */ 1,
  332. /* post_reset_wait_ms = */ 6,
  333. /* sda_setup_time_ns = */ 20,
  334. /* sck_pulse_width_ns = */ 140,
  335. /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  336. /* spi_mode = */ 0,
  337. /* i2c_bus_clock_100kHz = */ 4,
  338. /* data_setup_time_ns = */ 80,
  339. /* write_pulse_width_ns = */ 80,
  340. /* tile_width = */ 16,
  341. /* tile_height = */ 8,
  342. /* default_x_offset = */ 0,
  343. /* flipmode_x_offset = */ 0,
  344. /* pixel_width = */ 128,
  345. /* pixel_height = */ 64
  346. };
  347. /* 128x64 */
  348. static const uint8_t u8x8_d_t6963_128x64_init_seq[] = {
  349. U8X8_DLY(100),
  350. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  351. U8X8_DLY(100),
  352. U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
  353. U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
  354. U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
  355. U8X8_AAC(128/8,0x00,0x041), /* low, high, set text columns */
  356. U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
  357. U8X8_AAC(128/8,0x00,0x043), /* low, high, graphics columns */
  358. U8X8_DLY(2), /* delay 2ms */
  359. // mode set
  360. // 0x080: Internal CG, OR Mode
  361. // 0x081: Internal CG, EXOR Mode
  362. // 0x083: Internal CG, AND Mode
  363. // 0x088: External CG, OR Mode
  364. // 0x089: External CG, EXOR Mode
  365. // 0x08B: External CG, AND Mode
  366. U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
  367. // display mode
  368. // 0x090: Display off
  369. // 0x094: Graphic off, text on, cursor off, blink off
  370. // 0x096: Graphic off, text on, cursor on, blink off
  371. // 0x097: Graphic off, text on, cursor on, blink on
  372. // 0x098: Graphic on, text off, cursor off, blink off
  373. // 0x09a: Graphic on, text off, cursor on, blink off
  374. // ...
  375. // 0x09c: Graphic on, text on, cursor off, blink off
  376. // 0x09f: Graphic on, text on, cursor on, blink on
  377. U8X8_C(0x090), /* All Off */
  378. U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
  379. U8X8_DLY(100),
  380. U8X8_END_TRANSFER(), /* disable chip */
  381. U8X8_DLY(100),
  382. };
  383. uint8_t u8x8_d_t6963_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  384. {
  385. switch(msg)
  386. {
  387. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  388. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_128x64_display_info);
  389. break;
  390. case U8X8_MSG_DISPLAY_INIT:
  391. u8x8_d_helper_display_init(u8x8);
  392. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_128x64_init_seq);
  393. break;
  394. default:
  395. return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
  396. }
  397. return 1;
  398. }
  399. /*=============================================*/
  400. static const u8x8_display_info_t u8x8_t6963_160x80_display_info =
  401. {
  402. /* chip_enable_level = */ 0,
  403. /* chip_disable_level = */ 1,
  404. /* post_chip_enable_wait_ns = */ 10, /* T6963 Datasheet p30 */
  405. /* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
  406. /* reset_pulse_width_ms = */ 1,
  407. /* post_reset_wait_ms = */ 6,
  408. /* sda_setup_time_ns = */ 20,
  409. /* sck_pulse_width_ns = */ 140,
  410. /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  411. /* spi_mode = */ 0,
  412. /* i2c_bus_clock_100kHz = */ 4,
  413. /* data_setup_time_ns = */ 80,
  414. /* write_pulse_width_ns = */ 80,
  415. /* tile_width = */ 20,
  416. /* tile_height = */ 10,
  417. /* default_x_offset = */ 0,
  418. /* flipmode_x_offset = */ 0,
  419. /* pixel_width = */ 160,
  420. /* pixel_height = */ 80
  421. };
  422. /* 128x64 */
  423. static const uint8_t u8x8_d_t6963_160x80_init_seq[] = {
  424. U8X8_DLY(100),
  425. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  426. U8X8_DLY(100),
  427. U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
  428. U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
  429. U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
  430. U8X8_AAC(160/8,0x00,0x041), /* low, high, set text columns */
  431. U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
  432. U8X8_AAC(160/8,0x00,0x043), /* low, high, graphics columns */
  433. U8X8_DLY(2), /* delay 2ms */
  434. // mode set
  435. // 0x080: Internal CG, OR Mode
  436. // 0x081: Internal CG, EXOR Mode
  437. // 0x083: Internal CG, AND Mode
  438. // 0x088: External CG, OR Mode
  439. // 0x089: External CG, EXOR Mode
  440. // 0x08B: External CG, AND Mode
  441. U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
  442. // display mode
  443. // 0x090: Display off
  444. // 0x094: Graphic off, text on, cursor off, blink off
  445. // 0x096: Graphic off, text on, cursor on, blink off
  446. // 0x097: Graphic off, text on, cursor on, blink on
  447. // 0x098: Graphic on, text off, cursor off, blink off
  448. // 0x09a: Graphic on, text off, cursor on, blink off
  449. // ...
  450. // 0x09c: Graphic on, text on, cursor off, blink off
  451. // 0x09f: Graphic on, text on, cursor on, blink on
  452. U8X8_C(0x090), /* All Off */
  453. U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
  454. U8X8_DLY(100),
  455. U8X8_END_TRANSFER(), /* disable chip */
  456. U8X8_DLY(100),
  457. };
  458. uint8_t u8x8_d_t6963_160x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  459. {
  460. switch(msg)
  461. {
  462. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  463. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_160x80_display_info);
  464. break;
  465. case U8X8_MSG_DISPLAY_INIT:
  466. u8x8_d_helper_display_init(u8x8);
  467. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_160x80_init_seq);
  468. break;
  469. default:
  470. return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
  471. }
  472. return 1;
  473. }
  474. /* alternative version for the 128x64 t6963 display: use the 160x80 init sequence */
  475. uint8_t u8x8_d_t6963_128x64_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  476. {
  477. switch(msg)
  478. {
  479. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  480. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_128x64_display_info);
  481. break;
  482. case U8X8_MSG_DISPLAY_INIT:
  483. u8x8_d_helper_display_init(u8x8);
  484. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_160x80_init_seq);
  485. break;
  486. default:
  487. return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
  488. }
  489. return 1;
  490. }
  491. /*=============================================*/
  492. static const u8x8_display_info_t u8x8_t6963_128x128_display_info =
  493. {
  494. /* chip_enable_level = */ 1,
  495. /* chip_disable_level = */ 0,
  496. /* post_chip_enable_wait_ns = */ 10, /* T6963 Datasheet p30 */
  497. /* pre_chip_disable_wait_ns = */ 100, /* T6963 Datasheet p30 */
  498. /* reset_pulse_width_ms = */ 1,
  499. /* post_reset_wait_ms = */ 6,
  500. /* sda_setup_time_ns = */ 20,
  501. /* sck_pulse_width_ns = */ 140,
  502. /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  503. /* spi_mode = */ 0,
  504. /* i2c_bus_clock_100kHz = */ 4,
  505. /* data_setup_time_ns = */ 80,
  506. /* write_pulse_width_ns = */ 80,
  507. /* tile_width = */ 16,
  508. /* tile_height = */ 16,
  509. /* default_x_offset = */ 0,
  510. /* flipmode_x_offset = */ 0,
  511. /* pixel_width = */ 128,
  512. /* pixel_height = */ 128
  513. };
  514. /* 128x64 */
  515. static const uint8_t u8x8_d_t6963_128x128_init_seq[] = {
  516. U8X8_DLY(100),
  517. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  518. U8X8_DLY(100),
  519. U8X8_AAC(0x00,0x00,0x021), /* low, high, set cursor pos */
  520. U8X8_AAC(0x00,0x00,0x022), /* low, high, set offset */
  521. U8X8_AAC(0x00,0x00,0x040), /* low, high, set text home */
  522. U8X8_AAC(128/8,0x00,0x041), /* low, high, set text columns */
  523. U8X8_AAC(0x00,0x00,0x042), /* low, high, graphics home */
  524. U8X8_AAC(128/8,0x00,0x043), /* low, high, graphics columns */
  525. U8X8_DLY(2), /* delay 2ms */
  526. // mode set
  527. // 0x080: Internal CG, OR Mode
  528. // 0x081: Internal CG, EXOR Mode
  529. // 0x083: Internal CG, AND Mode
  530. // 0x088: External CG, OR Mode
  531. // 0x089: External CG, EXOR Mode
  532. // 0x08B: External CG, AND Mode
  533. U8X8_C(0x080), /* mode register: OR Mode, Internal Character Mode */
  534. // display mode
  535. // 0x090: Display off
  536. // 0x094: Graphic off, text on, cursor off, blink off
  537. // 0x096: Graphic off, text on, cursor on, blink off
  538. // 0x097: Graphic off, text on, cursor on, blink on
  539. // 0x098: Graphic on, text off, cursor off, blink off
  540. // 0x09a: Graphic on, text off, cursor on, blink off
  541. // ...
  542. // 0x09c: Graphic on, text on, cursor off, blink off
  543. // 0x09f: Graphic on, text on, cursor on, blink on
  544. U8X8_C(0x090), /* All Off */
  545. U8X8_AAC(0x00,0x00,0x024), /* low, high, set adr pointer */
  546. U8X8_DLY(100),
  547. U8X8_END_TRANSFER(), /* disable chip */
  548. U8X8_DLY(100),
  549. };
  550. uint8_t u8x8_d_t6963_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  551. {
  552. switch(msg)
  553. {
  554. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  555. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_t6963_128x128_display_info);
  556. break;
  557. case U8X8_MSG_DISPLAY_INIT:
  558. u8x8_d_helper_display_init(u8x8);
  559. u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_128x128_init_seq);
  560. break;
  561. default:
  562. return u8x8_d_t6963_common(u8x8, msg, arg_int, arg_ptr);
  563. }
  564. return 1;
  565. }