u8x8_d_lc7981.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /*
  2. u8x8_d_lc7981.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. */
  27. #include "u8x8.h"
  28. /* no powersave mode for the LC7981 */
  29. // static const uint8_t u8x8_d_lc7981_powersave0_seq[] = {
  30. // U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  31. // U8X8_END_TRANSFER(), /* disable chip */
  32. // U8X8_END() /* end of sequence */
  33. // };
  34. // static const uint8_t u8x8_d_lc7981_powersave1_seq[] = {
  35. // U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  36. // U8X8_END_TRANSFER(), /* disable chip */
  37. // U8X8_END() /* end of sequence */
  38. // };
  39. /* no hardware flip for the LC7981 */
  40. // static const uint8_t u8x8_d_lc7981_flip0_seq[] = {
  41. // U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  42. // U8X8_END_TRANSFER(), /* disable chip */
  43. // U8X8_END() /* end of sequence */
  44. // };
  45. // static const uint8_t u8x8_d_lc7981_flip1_seq[] = {
  46. // U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  47. // U8X8_END_TRANSFER(), /* disable chip */
  48. // U8X8_END() /* end of sequence */
  49. // };
  50. /* http://graphics.stanford.edu/~seander/bithacks.html */
  51. static uint8_t reverse_byte(uint8_t v)
  52. {
  53. // if ( v != 0 && v != 255 ) does not help much
  54. {
  55. // swap odd and even bits
  56. v = ((v >> 1) & 0x055) | ((v & 0x055) << 1);
  57. // swap consecutive pairs
  58. v = ((v >> 2) & 0x033) | ((v & 0x033) << 2);
  59. // swap nibbles ...
  60. v = ((v >> 4) & 0x00F) | ((v & 0x00F) << 4);
  61. }
  62. return v;
  63. }
  64. static uint8_t u8x8_d_lc7981_common(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
  65. {
  66. uint8_t c, i, j;
  67. uint16_t y;
  68. uint8_t *ptr;
  69. switch(msg)
  70. {
  71. case U8X8_MSG_DISPLAY_DRAW_TILE:
  72. y = (((u8x8_tile_t *)arg_ptr)->y_pos);
  73. y*=8;
  74. y*= u8x8->display_info->tile_width;
  75. /* x = ((u8x8_tile_t *)arg_ptr)->x_pos; x is ignored... no u8x8 support */
  76. u8x8_cad_StartTransfer(u8x8);
  77. /*
  78. Tile structure is reused here for the t6963, however u8x8 is not supported
  79. tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles)
  80. Buffer is expected to have 8 lines of code fitting to the t6963 internal memory
  81. "cnt" includes the number of horizontal bytes. width is equal to cnt*8
  82. x is assumed to be zero
  83. TODO: Consider arg_int, however arg_int is not used by u8g2
  84. */
  85. c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
  86. ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
  87. for( i = 0; i < 8; i++ )
  88. {
  89. u8x8_cad_SendCmd(u8x8, 0x0a ); /* display ram (cursor) address low byte */
  90. u8x8_cad_SendArg(u8x8, y&255);
  91. u8x8_cad_SendCmd(u8x8, 0x0b ); /* display ram (cursor) address high byte */
  92. u8x8_cad_SendArg(u8x8, y>>8);
  93. u8x8_cad_SendCmd(u8x8, 0x0c ); /* write start */
  94. /*
  95. The LC7981 has the MSB at the right position, which is exactly the opposite to the T6963.
  96. Instead of writing a third hvline procedure for this device, we just revert the bytes before
  97. transmit. This is slow because:
  98. - the bit reverse itself
  99. - the single byte transfer
  100. The one byte is transmitted via SendArg, which is ok, because CAD = 100
  101. */
  102. for( j = 0; j < c; j++ )
  103. u8x8_cad_SendArg(u8x8, reverse_byte(*ptr++));
  104. //u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */
  105. //ptr += u8x8->display_info->tile_width;
  106. y += u8x8->display_info->tile_width;
  107. }
  108. u8x8_cad_EndTransfer(u8x8);
  109. break;
  110. /* handled in the calling procedure
  111. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  112. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_128x64_display_info);
  113. break;
  114. case U8X8_MSG_DISPLAY_INIT:
  115. u8x8_d_helper_display_init(u8x8);
  116. u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
  117. break;
  118. */
  119. /* power save is not there...
  120. case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
  121. if ( arg_int == 0 )
  122. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_powersave0_seq);
  123. else
  124. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_powersave1_seq);
  125. break;
  126. */
  127. /* hardware flip not is not available
  128. case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
  129. if ( arg_int == 0 )
  130. {
  131. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_flip0_seq);
  132. u8x8->x_offset = u8x8->display_info->default_x_offset;
  133. }
  134. else
  135. {
  136. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_flip1_seq);
  137. u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
  138. }
  139. break;
  140. */
  141. #ifdef U8X8_WITH_SET_CONTRAST
  142. /* no contrast setting :-(
  143. case U8X8_MSG_DISPLAY_SET_CONTRAST:
  144. u8x8_cad_StartTransfer(u8x8);
  145. u8x8_cad_SendCmd(u8x8, 0x081 );
  146. u8x8_cad_SendArg(u8x8, arg_int );
  147. u8x8_cad_EndTransfer(u8x8);
  148. break;
  149. */
  150. #endif
  151. default:
  152. return 0;
  153. }
  154. return 1;
  155. }
  156. /*================================================*/
  157. /* LC7981 160x80 LCD*/
  158. static const u8x8_display_info_t u8x8_lc7981_160x80_display_info =
  159. {
  160. /* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
  161. /* chip_disable_level = */ 1,
  162. /* from here... */
  163. /* post_chip_enable_wait_ns = */ 20,
  164. /* pre_chip_disable_wait_ns = */ 20,
  165. /* reset_pulse_width_ms = */ 1,
  166. /* post_reset_wait_ms = */ 10,
  167. /* sda_setup_time_ns = */ 30,
  168. /* sck_pulse_width_ns = */ 65, /* half of cycle time */
  169. /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  170. /* spi_mode = */ 0, /* active high, rising edge */
  171. /* i2c_bus_clock_100kHz = */ 4,
  172. /* ... to here, values are ignored, because this is a parallel interface only */
  173. /* data_setup_time_ns = */ 220,
  174. /* write_pulse_width_ns = */ 20,
  175. /* tile_width = */ 20, /* width of 20*8=160 pixel */
  176. /* tile_height = */ 10,
  177. /* default_x_offset = */ 0,
  178. /* flipmode_x_offset = */ 0,
  179. /* pixel_width = */ 160,
  180. /* pixel_height = */ 80
  181. };
  182. static const uint8_t u8x8_d_lc7981_160x80_init_seq[] = {
  183. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  184. U8X8_DLY(50),
  185. U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
  186. U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
  187. U8X8_CA(0x02, 160/8-1), /* number of chars/byte width of the screen */
  188. U8X8_CA(0x03, 0x50), /* time division: 50 (1/80 duty cycle) */
  189. U8X8_CA(0x08, 0x00), /* display start low */
  190. U8X8_CA(0x09, 0x00), /* display start high */
  191. U8X8_DLY(10),
  192. U8X8_END_TRANSFER(), /* disable chip */
  193. U8X8_END() /* end of sequence */
  194. };
  195. uint8_t u8x8_d_lc7981_160x80(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  196. {
  197. /* call common procedure first and handle messages there */
  198. if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
  199. {
  200. /* msg not handled, then try here */
  201. switch(msg)
  202. {
  203. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  204. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_160x80_display_info);
  205. break;
  206. case U8X8_MSG_DISPLAY_INIT:
  207. u8x8_d_helper_display_init(u8x8);
  208. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_160x80_init_seq);
  209. break;
  210. default:
  211. return 0; /* msg unknown */
  212. }
  213. }
  214. return 1;
  215. }
  216. /*================================================*/
  217. /* LC7981 160x160 LCD*/
  218. static const u8x8_display_info_t u8x8_lc7981_160x160_display_info =
  219. {
  220. /* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
  221. /* chip_disable_level = */ 1,
  222. /* from here... */
  223. /* post_chip_enable_wait_ns = */ 20,
  224. /* pre_chip_disable_wait_ns = */ 20,
  225. /* reset_pulse_width_ms = */ 1,
  226. /* post_reset_wait_ms = */ 10,
  227. /* sda_setup_time_ns = */ 30,
  228. /* sck_pulse_width_ns = */ 65, /* half of cycle time */
  229. /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  230. /* spi_mode = */ 0, /* active high, rising edge */
  231. /* i2c_bus_clock_100kHz = */ 4,
  232. /* ... to here, values are ignored, because this is a parallel interface only */
  233. /* data_setup_time_ns = */ 220,
  234. /* write_pulse_width_ns = */ 20,
  235. /* tile_width = */ 20, /* width of 20*8=160 pixel */
  236. /* tile_height = */ 20,
  237. /* default_x_offset = */ 0,
  238. /* flipmode_x_offset = */ 0,
  239. /* pixel_width = */ 160,
  240. /* pixel_height = */ 160
  241. };
  242. static const uint8_t u8x8_d_lc7981_160x160_init_seq[] = {
  243. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  244. U8X8_DLY(50),
  245. U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
  246. U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
  247. U8X8_CA(0x02, 160/8-1), /* number of chars/byte width of the screen */
  248. U8X8_CA(0x03, 159), /* time division */
  249. U8X8_CA(0x08, 0x00), /* display start low */
  250. U8X8_CA(0x09, 0x00), /* display start high */
  251. U8X8_DLY(10),
  252. U8X8_END_TRANSFER(), /* disable chip */
  253. U8X8_END() /* end of sequence */
  254. };
  255. uint8_t u8x8_d_lc7981_160x160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  256. {
  257. /* call common procedure first and handle messages there */
  258. if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
  259. {
  260. /* msg not handled, then try here */
  261. switch(msg)
  262. {
  263. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  264. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_160x160_display_info);
  265. break;
  266. case U8X8_MSG_DISPLAY_INIT:
  267. u8x8_d_helper_display_init(u8x8);
  268. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_160x160_init_seq);
  269. break;
  270. default:
  271. return 0; /* msg unknown */
  272. }
  273. }
  274. return 1;
  275. }
  276. /*================================================*/
  277. /* LC7981 240x128 LCD*/
  278. static const u8x8_display_info_t u8x8_lc7981_240x128_display_info =
  279. {
  280. /* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
  281. /* chip_disable_level = */ 1,
  282. /* from here... */
  283. /* post_chip_enable_wait_ns = */ 20,
  284. /* pre_chip_disable_wait_ns = */ 20,
  285. /* reset_pulse_width_ms = */ 1,
  286. /* post_reset_wait_ms = */ 10,
  287. /* sda_setup_time_ns = */ 30,
  288. /* sck_pulse_width_ns = */ 65, /* half of cycle time */
  289. /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  290. /* spi_mode = */ 0, /* active high, rising edge */
  291. /* i2c_bus_clock_100kHz = */ 4,
  292. /* ... to here, values are ignored, because this is a parallel interface only */
  293. /* data_setup_time_ns = */ 220,
  294. /* write_pulse_width_ns = */ 20,
  295. /* tile_width = */ 30, /* width of 30*8=240 pixel */
  296. /* tile_height = */ 16,
  297. /* default_x_offset = */ 0,
  298. /* flipmode_x_offset = */ 0,
  299. /* pixel_width = */ 240,
  300. /* pixel_height = */ 128
  301. };
  302. static const uint8_t u8x8_d_lc7981_240x128_init_seq[] = {
  303. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  304. U8X8_DLY(50),
  305. U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
  306. U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
  307. U8X8_CA(0x02, 240/8-1), /* number of chars/byte width of the screen */
  308. U8X8_CA(0x03, 16*8-1), /* time division */
  309. U8X8_CA(0x08, 0x00), /* display start low */
  310. U8X8_CA(0x09, 0x00), /* display start high */
  311. U8X8_DLY(10),
  312. U8X8_END_TRANSFER(), /* disable chip */
  313. U8X8_END() /* end of sequence */
  314. };
  315. uint8_t u8x8_d_lc7981_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  316. {
  317. /* call common procedure first and handle messages there */
  318. if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
  319. {
  320. /* msg not handled, then try here */
  321. switch(msg)
  322. {
  323. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  324. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_240x128_display_info);
  325. break;
  326. case U8X8_MSG_DISPLAY_INIT:
  327. u8x8_d_helper_display_init(u8x8);
  328. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_240x128_init_seq);
  329. break;
  330. default:
  331. return 0; /* msg unknown */
  332. }
  333. }
  334. return 1;
  335. }
  336. /*================================================*/
  337. /* LC7981 240x64 LCD*/
  338. /* https://github.com/olikraus/u8g2/issues/642 */
  339. static const u8x8_display_info_t u8x8_lc7981_240x64_display_info =
  340. {
  341. /* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
  342. /* chip_disable_level = */ 1,
  343. /* from here... */
  344. /* post_chip_enable_wait_ns = */ 20,
  345. /* pre_chip_disable_wait_ns = */ 20,
  346. /* reset_pulse_width_ms = */ 1,
  347. /* post_reset_wait_ms = */ 10,
  348. /* sda_setup_time_ns = */ 30,
  349. /* sck_pulse_width_ns = */ 65, /* half of cycle time */
  350. /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  351. /* spi_mode = */ 0, /* active high, rising edge */
  352. /* i2c_bus_clock_100kHz = */ 4,
  353. /* ... to here, values are ignored, because this is a parallel interface only */
  354. /* data_setup_time_ns = */ 220,
  355. /* write_pulse_width_ns = */ 20,
  356. /* tile_width = */ 30, /* width of 30*8=240 pixel */
  357. /* tile_height = */ 8,
  358. /* default_x_offset = */ 0,
  359. /* flipmode_x_offset = */ 0,
  360. /* pixel_width = */ 240,
  361. /* pixel_height = */ 64
  362. };
  363. static const uint8_t u8x8_d_lc7981_240x64_init_seq[] = {
  364. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  365. U8X8_DLY(50),
  366. U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
  367. U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
  368. U8X8_CA(0x02, 240/8-1), /* number of chars/byte width of the screen */
  369. U8X8_CA(0x03, 0x7f), /* time division */
  370. U8X8_CA(0x08, 0x00), /* display start low */
  371. U8X8_CA(0x09, 0x00), /* display start high */
  372. U8X8_DLY(10),
  373. U8X8_END_TRANSFER(), /* disable chip */
  374. U8X8_END() /* end of sequence */
  375. };
  376. uint8_t u8x8_d_lc7981_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  377. {
  378. /* call common procedure first and handle messages there */
  379. if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
  380. {
  381. /* msg not handled, then try here */
  382. switch(msg)
  383. {
  384. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  385. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_240x64_display_info);
  386. break;
  387. case U8X8_MSG_DISPLAY_INIT:
  388. u8x8_d_helper_display_init(u8x8);
  389. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_240x64_init_seq);
  390. break;
  391. default:
  392. return 0; /* msg unknown */
  393. }
  394. }
  395. return 1;
  396. }
  397. /*================================================*/
  398. /* LC7981 128x128 LCD, https://github.com/olikraus/u8g2/issues/1913*/
  399. static const u8x8_display_info_t u8x8_lc7981_128x128_display_info =
  400. {
  401. /* chip_enable_level = */ 0, /* LC7981 has a low active CS*/
  402. /* chip_disable_level = */ 1,
  403. /* from here... */
  404. /* post_chip_enable_wait_ns = */ 20,
  405. /* pre_chip_disable_wait_ns = */ 20,
  406. /* reset_pulse_width_ms = */ 1,
  407. /* post_reset_wait_ms = */ 10,
  408. /* sda_setup_time_ns = */ 30,
  409. /* sck_pulse_width_ns = */ 65, /* half of cycle time */
  410. /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  411. /* spi_mode = */ 0, /* active high, rising edge */
  412. /* i2c_bus_clock_100kHz = */ 4,
  413. /* ... to here, values are ignored, because this is a parallel interface only */
  414. /* data_setup_time_ns = */ 220,
  415. /* write_pulse_width_ns = */ 20,
  416. /* tile_width = */ 16, /* width of 16*8=128 pixel */
  417. /* tile_height = */ 16,
  418. /* default_x_offset = */ 0,
  419. /* flipmode_x_offset = */ 0,
  420. /* pixel_width = */ 128,
  421. /* pixel_height = */ 128
  422. };
  423. static const uint8_t u8x8_d_lc7981_128x128_init_seq[] = {
  424. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  425. U8X8_DLY(50),
  426. U8X8_CA(0x00, 0x32), /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1) */
  427. U8X8_CA(0x01, 0x07), /* character/bits per pixel pitch */
  428. U8X8_CA(0x02, 128/8-1), /* number of chars/byte width of the screen */
  429. U8X8_CA(0x03, 128), /* time division, issue https://github.com/olikraus/u8g2/issues/1581 */
  430. U8X8_CA(0x08, 0x00), /* display start low */
  431. U8X8_CA(0x09, 0x00), /* display start high */
  432. U8X8_DLY(10),
  433. U8X8_END_TRANSFER(), /* disable chip */
  434. U8X8_END() /* end of sequence */
  435. };
  436. uint8_t u8x8_d_lc7981_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  437. {
  438. /* call common procedure first and handle messages there */
  439. if ( u8x8_d_lc7981_common(u8x8, msg, arg_int, arg_ptr) == 0 )
  440. {
  441. /* msg not handled, then try here */
  442. switch(msg)
  443. {
  444. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  445. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_lc7981_128x128_display_info);
  446. break;
  447. case U8X8_MSG_DISPLAY_INIT:
  448. u8x8_d_helper_display_init(u8x8);
  449. u8x8_cad_SendSequence(u8x8, u8x8_d_lc7981_128x128_init_seq);
  450. break;
  451. default:
  452. return 0; /* msg unknown */
  453. }
  454. }
  455. return 1;
  456. }