u8x8_d_il3820_296x128.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. /*
  2. u8x8_d_il3820_296x128.c
  3. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  4. Copyright (c) 2017, 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. il3820: 200x300x1
  27. command
  28. 0x22: assign actions
  29. 0x20: execute actions
  30. action for command 0x022 are (more or less guessed)
  31. bit 7: Enable Clock
  32. bit 6: Enable Charge Pump
  33. bit 5: Load Temparture Value (???)
  34. bit 4: Load LUT (???)
  35. bit 3: Initial Display (???)
  36. bit 2: Pattern Display --> Requires about 945ms with the LUT from below
  37. bit 1: Disable Charge Pump
  38. bit 0: Disable Clock
  39. Disable Charge Pump and Clock require about 10ms
  40. Enable Charge Pump and Clock require about 100 to 300ms
  41. Notes:
  42. - Introduced a refresh display message, which copies RAM to display
  43. - Charge pump is always enabled. Charge pump can be enabled/disabled via power save message
  44. - U8x8 will not really work because of the two buffers in the SSD1606, however U8g2 should be ok.
  45. LUT for the 296x128 device (IL3820)
  46. LUT (cmd: 0x032 has 30 bytes)
  47. section 6.8 of the datasheet mentions 256 bits = 32 bytes for the LUT
  48. chapter 7 tells 30 bytes
  49. according to section 6.8:
  50. 20 bytes waveform
  51. 10 bytes timing
  52. 1 byte named as VSH/VSL
  53. 1 empty byte
  54. according to the command table, the lut has 240 bits (=30 bytes * 8 bits)
  55. LUT / Refresh time
  56. total_refresh_time = (refresh_lines + dummy_lines*2)*TGate*TS_Sum/f_OSC
  57. f_OSC=1MHz (according to the datasheets)
  58. refreh_lines = 296 (for the waveshare display, 0x045 cmd)
  59. dummy_lines = 22 (for the upcoming u8g2 code, 0x03a cmd)
  60. TGate = 62 (POR default, 0x03b cmd)
  61. TS_Sum: Sum of all TS entries of the second part of the LUT
  62. f_OSC: 1MHz according to the datasheet.
  63. so we have
  64. total_refresh_time = 21080*TS_Sum/1000000 = 21ms * TS_Sum
  65. This file includes two devices:
  66. u8x8_d_il3820_296x128 --> includes LUT which is probably from the WaveShare 2.9 Vendor
  67. u8x8_d_il3820_v2_296x128 --> includes LUT which was optimized for faster speed and lesser flicker
  68. */
  69. /* Waveform part of the LUT (20 bytes) */
  70. /* bit 7/6: 1 - 1 transition */
  71. /* bit 5/4: 1 - 0 transition */
  72. /* bit 3/2: 0 - 1 transition */
  73. /* bit 1/0: 0 - 0 transition */
  74. /* 00 – VSS */
  75. /* 01 – VSH */
  76. /* 10 – VSL */
  77. /* 11 – NA */
  78. #include "u8x8.h"
  79. /*=================================================*/
  80. /* common code for all devices */
  81. static const uint8_t u8x8_d_il3820_296x128_powersave0_seq[] = {
  82. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  83. U8X8_CA(0x22, 0xc0), /* enable clock and charge pump */
  84. U8X8_C(0x20), /* execute sequence */
  85. U8X8_DLY(200), /* according to my measures it may take up to 150ms */
  86. U8X8_DLY(100), /* but it might take longer */
  87. U8X8_END_TRANSFER(), /* disable chip */
  88. U8X8_END() /* end of sequence */
  89. };
  90. static const uint8_t u8x8_d_il3820_296x128_powersave1_seq[] = {
  91. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  92. /* disable clock and charge pump only, deep sleep is not entered, because we will loose RAM content */
  93. U8X8_CA(0x22, 0x02), /* only disable charge pump, HW reset seems to be required if the clock is disabled */
  94. U8X8_C(0x20), /* execute sequence */
  95. U8X8_DLY(20),
  96. U8X8_END_TRANSFER(), /* disable chip */
  97. U8X8_END() /* end of sequence */
  98. };
  99. // static const uint8_t u8x8_d_il3820_296x128_flip0_seq[] = {
  100. // U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  101. // U8X8_END_TRANSFER(), /* disable chip */
  102. // U8X8_END() /* end of sequence */
  103. // };
  104. // static const uint8_t u8x8_d_il3820_296x128_flip1_seq[] = {
  105. // U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  106. // U8X8_END_TRANSFER(), /* disable chip */
  107. // U8X8_END() /* end of sequence */
  108. // };
  109. static const u8x8_display_info_t u8x8_il3820_296x128_display_info =
  110. {
  111. /* chip_enable_level = */ 0,
  112. /* chip_disable_level = */ 1,
  113. /* post_chip_enable_wait_ns = */ 120,
  114. /* pre_chip_disable_wait_ns = */ 60,
  115. /* reset_pulse_width_ms = */ 100,
  116. /* post_reset_wait_ms = */ 100,
  117. /* sda_setup_time_ns = */ 50, /* IL3820 */
  118. /* sck_pulse_width_ns = */ 125, /* IL3820: 125ns, clock cycle = 250ns */
  119. /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
  120. /* spi_mode = */ 0, /* active high, rising edge */
  121. /* i2c_bus_clock_100kHz = */ 4,
  122. /* data_setup_time_ns = */ 40,
  123. /* write_pulse_width_ns = */ 150,
  124. /* tile_width = */ 37, /* 37*8 = 296 */
  125. /* tile_hight = */ 16, /* 16*8 = 128 */
  126. /* default_x_offset = */ 0,
  127. /* flipmode_x_offset = */ 0,
  128. /* pixel_width = */ 296,
  129. /* pixel_height = */ 128
  130. };
  131. static uint8_t *u8x8_convert_tile_for_il3820(uint8_t *t)
  132. {
  133. uint8_t i;
  134. static uint8_t buf[8];
  135. uint8_t *pbuf = buf;
  136. for( i = 0; i < 8; i++ )
  137. {
  138. *pbuf++ = ~(*t++);
  139. }
  140. return buf;
  141. }
  142. static void u8x8_d_il3820_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr) U8X8_NOINLINE;
  143. static void u8x8_d_il3820_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr)
  144. {
  145. uint16_t x;
  146. uint8_t c, page;
  147. uint8_t *ptr;
  148. u8x8_cad_StartTransfer(u8x8);
  149. page = u8x8->display_info->tile_height;
  150. page --;
  151. page -= (((u8x8_tile_t *)arg_ptr)->y_pos);
  152. x = ((u8x8_tile_t *)arg_ptr)->x_pos;
  153. x *= 8;
  154. x += u8x8->x_offset;
  155. //u8x8_cad_SendCmd(u8x8, 0x011 ); /* cursor increment mode */
  156. //u8x8_cad_SendArg(u8x8, 7);
  157. u8x8_cad_SendCmd(u8x8, 0x04f ); /* set cursor column */
  158. u8x8_cad_SendArg(u8x8, x&255);
  159. u8x8_cad_SendArg(u8x8, x>>8);
  160. u8x8_cad_SendCmd(u8x8, 0x04e ); /* set cursor row */
  161. u8x8_cad_SendArg(u8x8, page);
  162. u8x8_cad_SendCmd(u8x8, 0x024 );
  163. do
  164. {
  165. c = ((u8x8_tile_t *)arg_ptr)->cnt;
  166. ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
  167. do
  168. {
  169. u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_il3820(ptr));
  170. ptr += 8;
  171. x += 8;
  172. c--;
  173. } while( c > 0 );
  174. arg_int--;
  175. } while( arg_int > 0 );
  176. u8x8_cad_EndTransfer(u8x8);
  177. }
  178. static const uint8_t u8x8_d_il3820_exec_1000dly_seq[] = {
  179. // assumes, that the start transfer has happend
  180. U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display */
  181. U8X8_C(0x20), /* execute sequence */
  182. U8X8_DLY(250),
  183. U8X8_DLY(250),
  184. U8X8_DLY(250),
  185. U8X8_DLY(250),
  186. U8X8_END_TRANSFER(), /* disable chip */
  187. U8X8_END() /* end of sequence */
  188. };
  189. static void u8x8_d_il3820_first_init(u8x8_t *u8x8)
  190. {
  191. u8x8_ClearDisplay(u8x8);
  192. u8x8_cad_StartTransfer(u8x8);
  193. u8x8_cad_SendCmd(u8x8, 0x032); // program update sequence
  194. u8x8_cad_SendMultipleArg(u8x8, 8, 0x055); // all black
  195. u8x8_cad_SendMultipleArg(u8x8, 12, 0x0aa); // all white
  196. u8x8_cad_SendMultipleArg(u8x8, 10, 0x022); // 830ms
  197. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_exec_1000dly_seq);
  198. }
  199. #ifdef OBSOLETE
  200. static void u8x8_d_il3820_second_init(u8x8_t *u8x8)
  201. {
  202. u8x8_ClearDisplay(u8x8);
  203. u8x8_cad_StartTransfer(u8x8);
  204. u8x8_cad_SendCmd(u8x8, 0x032); // program update sequence
  205. u8x8_cad_SendMultipleArg(u8x8, 20, 0x000); // do nothing
  206. u8x8_cad_SendMultipleArg(u8x8, 10, 0x011); // 414ms dly
  207. /* reuse sequence from above, ok some time is wasted here, */
  208. /* delay could be lesser */
  209. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_exec_1000dly_seq);
  210. }
  211. #endif
  212. /*=================================================*/
  213. /* first version, LUT from WaveShare */
  214. /* http://www.waveshare.com/wiki/File:2.9inch_e-Paper_Module_code.7z */
  215. static const uint8_t u8x8_d_il3820_296x128_init_seq[] = {
  216. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  217. U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: Disable */
  218. U8X8_C(0x01),
  219. U8X8_A(295 % 256), U8X8_A(295/256), U8X8_A(0),
  220. U8X8_CA(0x03, 0x00), /* Gate Driving voltage: 15V (lowest value)*/
  221. U8X8_CA(0x04, 0x0a), /* Source Driving voltage: 15V (mid value and POR)*/
  222. //U8X8_CA(0x22, 0xc0), /* display update seq. option: enable clk, enable CP, .... todo: this is never activated */
  223. //U8X8_CA(0x0b, 7), /* Set Delay of gate and source non overlap period, POR = 7 */
  224. U8X8_CA(0x2c, 0xa8), /* write vcom value*/
  225. U8X8_CA(0x3a, 0x16), /* dummy lines POR=22 (0x016) */
  226. U8X8_CA(0x3b, 0x08), /* gate time POR=0x08*/
  227. U8X8_CA(0x3c, 0x33), /* select boarder waveform */
  228. //U8X8_CA(0x22, 0xc4), /* display update seq. option: clk -> CP -> LUT -> initial display -> pattern display */
  229. U8X8_CA(0x11, 0x07), /* Define data entry mode, x&y inc, x first*/
  230. U8X8_CAA(0x44, 0, 29), /* RAM x start & end, issue 920: end should be (128/8)-1=15. */
  231. U8X8_CAAAA(0x45, 0, 0, 295&255, 295>>8), /* RAM y start & end */
  232. //U8X8_CA(0x4e, 0), /* set x pos, 0..29? */
  233. //U8X8_CAA(0x4f, 0, 0), /* set y pos, 0...320??? */
  234. U8X8_END_TRANSFER(), /* disable chip */
  235. U8X8_END() /* end of sequence */
  236. };
  237. static const uint8_t u8x8_d_il3820_to_display_seq[] = {
  238. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  239. /*
  240. 0x50, 0xAA, 0x55, 0xAA, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
  241. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  242. 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  243. measured 1582 ms
  244. */
  245. U8X8_C(0x32), /* write LUT register*/
  246. /* original values */
  247. U8X8_A(0x50),
  248. U8X8_A(0xaa),
  249. U8X8_A(0x55),
  250. U8X8_A(0xaa),
  251. U8X8_A(0x11),
  252. U8X8_A(0x11),
  253. U8X8_A(0x00),
  254. U8X8_A(0x00),
  255. U8X8_A(0x00),
  256. U8X8_A(0x00),
  257. U8X8_A(0x00),
  258. U8X8_A(0x00),
  259. U8X8_A(0x00),
  260. U8X8_A(0x00),
  261. U8X8_A(0x00),
  262. U8X8_A(0x00),
  263. U8X8_A(0x00),
  264. U8X8_A(0x00),
  265. U8X8_A(0x00),
  266. U8X8_A(0x00),
  267. /* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
  268. U8X8_A(0xff),
  269. U8X8_A(0xff),
  270. U8X8_A(0x3f),
  271. U8X8_A(0x00),
  272. U8X8_A(0x00),
  273. U8X8_A(0x00),
  274. U8X8_A(0x00),
  275. U8X8_A(0x00),
  276. U8X8_A(0x00),
  277. U8X8_A(0x00),
  278. U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display, assumes clk and charge pump are enabled */
  279. U8X8_C(0x20), /* execute sequence */
  280. U8X8_DLY(250), /* delay for 1620ms. The current sequence takes 1582ms */
  281. U8X8_DLY(250),
  282. U8X8_DLY(250),
  283. U8X8_DLY(250),
  284. U8X8_DLY(250),
  285. U8X8_DLY(250),
  286. U8X8_DLY(120),
  287. U8X8_END_TRANSFER(), /* disable chip */
  288. U8X8_END() /* end of sequence */
  289. };
  290. uint8_t u8x8_d_il3820_296x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  291. {
  292. switch(msg)
  293. {
  294. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  295. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_il3820_296x128_display_info);
  296. break;
  297. case U8X8_MSG_DISPLAY_INIT:
  298. u8x8_d_helper_display_init(u8x8);
  299. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_init_seq);
  300. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
  301. u8x8_d_il3820_first_init(u8x8);
  302. /* usually the DISPLAY_INIT message leaves the display in power save state */
  303. /* however this is not done for e-paper devices, see: */
  304. /* https://github.com/olikraus/u8g2/wiki/internal#powersave-mode */
  305. break;
  306. case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
  307. if ( arg_int == 0 )
  308. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
  309. else
  310. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave1_seq);
  311. break;
  312. case U8X8_MSG_DISPLAY_DRAW_TILE:
  313. u8x8_d_il3820_draw_tile(u8x8, arg_int, arg_ptr);
  314. break;
  315. case U8X8_MSG_DISPLAY_REFRESH:
  316. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_to_display_seq);
  317. break;
  318. default:
  319. return 0;
  320. }
  321. return 1;
  322. }
  323. /*=================================================*/
  324. /* second version for the IL3820 display */
  325. /* http://www.waveshare.com/wiki/File:2.9inch_e-Paper_Module_code.7z */
  326. static const uint8_t u8x8_d_il3820_v2_296x128_init_seq[] = {
  327. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  328. // U8X8_CA(0x10, 0x00), /* Deep Sleep mode Control: POR: Normal mode */
  329. U8X8_C(0x01),
  330. U8X8_A(295 % 256), U8X8_A(295/256), U8X8_A(0),
  331. /* the driving voltagesmust not be that high, in order to aviod level change after */
  332. /* some seconds (which happens with 0xea */
  333. U8X8_CA(0x03, 0x75), /* Gate Driving voltage: +/-15V =0x00 POR (+22/-20V) = 0x0ea*/
  334. U8X8_CA(0x04, 0x0a), /* Source Driving voltage: (POR=0x0a=15V), max=0x0e*/
  335. U8X8_CA(0x0b, 7), /* Set Delay of gate and source non overlap period, POR = 7 */
  336. U8X8_CA(0x2c, 0xa8), /* write vcom value*/
  337. U8X8_CA(0x3a, 0x16), /* dummy lines POR=22 (0x016) */
  338. U8X8_CA(0x3b, 0x08), /* gate time POR=0x08*/
  339. U8X8_CA(0x3c, 0x33), /* select boarder waveform */
  340. U8X8_CA(0x11, 0x07), /* Define data entry mode, x&y inc, x first*/
  341. U8X8_CAA(0x44, 0, 29), /* RAM x start & end, 32*4=128 */
  342. U8X8_CAAAA(0x45, 0, 0, 295&255, 295>>8), /* RAM y start & end, 0..295 */
  343. U8X8_END_TRANSFER(), /* disable chip */
  344. U8X8_END() /* end of sequence */
  345. };
  346. static const uint8_t u8x8_d_il3820_v2_to_display_seq[] = {
  347. U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
  348. /*
  349. 0xaa, 0x09, 0x09, 0x19, 0x19,
  350. 0x11, 0x11, 0x11, 0x11, 0x00,
  351. 0x00, 0x00, 0x00, 0x00, 0x00,
  352. 0x00, 0x00, 0x00, 0x00, 0x00,
  353. 0x75, 0x77, 0x77, 0x77, 0x07,
  354. 0x00, 0x00, 0x00, 0x00, 0x00
  355. measured 1240 ms
  356. */
  357. U8X8_C(0x32), /* write LUT register*/
  358. /* https://github.com/olikraus/u8g2/issues/347 */
  359. U8X8_A(0xaa),
  360. U8X8_A(0x09),
  361. U8X8_A(0x09),
  362. U8X8_A(0x19),
  363. U8X8_A(0x19),
  364. U8X8_A(0x11),
  365. U8X8_A(0x11),
  366. U8X8_A(0x11),
  367. U8X8_A(0x11),
  368. U8X8_A(0x00),
  369. U8X8_A(0x00),
  370. U8X8_A(0x00),
  371. U8X8_A(0x00),
  372. U8X8_A(0x00),
  373. U8X8_A(0x00),
  374. U8X8_A(0x00),
  375. U8X8_A(0x00),
  376. U8X8_A(0x00),
  377. U8X8_A(0x00),
  378. U8X8_A(0x00),
  379. /* Timing part of the LUT, 20 Phases with 4 bit each: 10 bytes */
  380. U8X8_A(0x75),
  381. U8X8_A(0x77),
  382. U8X8_A(0x77),
  383. U8X8_A(0x77),
  384. U8X8_A(0x07),
  385. U8X8_A(0x00),
  386. U8X8_A(0x00),
  387. U8X8_A(0x00),
  388. U8X8_A(0x00),
  389. U8X8_A(0x00),
  390. U8X8_CA(0x22, 0x04), /* display update seq. option: pattern display */
  391. U8X8_C(0x20), /* execute sequence */
  392. U8X8_DLY(250), /* delay for 1400ms. The current sequence takes 1240ms, it was reported, that longer delays are better */
  393. U8X8_DLY(250),
  394. U8X8_DLY(250),
  395. U8X8_DLY(250),
  396. U8X8_DLY(250),
  397. U8X8_DLY(150), /* extended, #318 */
  398. U8X8_END_TRANSFER(), /* disable chip */
  399. U8X8_END() /* end of sequence */
  400. };
  401. uint8_t u8x8_d_il3820_v2_296x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
  402. {
  403. switch(msg)
  404. {
  405. case U8X8_MSG_DISPLAY_SETUP_MEMORY:
  406. u8x8_d_helper_display_setup_memory(u8x8, &u8x8_il3820_296x128_display_info);
  407. break;
  408. case U8X8_MSG_DISPLAY_INIT:
  409. u8x8_d_helper_display_init(u8x8);
  410. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_v2_296x128_init_seq);
  411. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
  412. u8x8_d_il3820_first_init(u8x8);
  413. /* u8x8_d_il3820_second_init(u8x8); */ /* not required, u8g2.begin() will also clear the display once more */
  414. /* usually the DISPLAY_INIT message leaves the display in power save state */
  415. /* however this is not done for e-paper devices, see: */
  416. /* https://github.com/olikraus/u8g2/wiki/internal#powersave-mode */
  417. break;
  418. case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
  419. if ( arg_int == 0 )
  420. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave0_seq);
  421. else
  422. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_296x128_powersave1_seq);
  423. break;
  424. case U8X8_MSG_DISPLAY_DRAW_TILE:
  425. u8x8_d_il3820_draw_tile(u8x8, arg_int, arg_ptr);
  426. break;
  427. case U8X8_MSG_DISPLAY_REFRESH:
  428. u8x8_cad_SendSequence(u8x8, u8x8_d_il3820_v2_to_display_seq);
  429. break;
  430. default:
  431. return 0;
  432. }
  433. return 1;
  434. }