| 1 | /* |
| 2 | |
| 3 | u8x8_d_st7565.c |
| 4 | also includes support for nt7534 |
| 5 | |
| 6 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) |
| 7 | |
| 8 | Copyright (c) 2016, olikraus@gmail.com |
| 9 | All rights reserved. |
| 10 | |
| 11 | Redistribution and use in source and binary forms, with or without modification, |
| 12 | are permitted provided that the following conditions are met: |
| 13 | |
| 14 | * Redistributions of source code must retain the above copyright notice, this list |
| 15 | of conditions and the following disclaimer. |
| 16 | |
| 17 | * Redistributions in binary form must reproduce the above copyright notice, this |
| 18 | list of conditions and the following disclaimer in the documentation and/or other |
| 19 | materials provided with the distribution. |
| 20 | |
| 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
| 22 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| 23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 24 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 28 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 32 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | |
| 35 | |
| 36 | */ |
| 37 | #include "u8x8.h" |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | static const uint8_t u8x8_d_st7565_powersave0_seq[] = { |
| 44 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 45 | U8X8_C(0x0a4), /* all pixel off, issue 142 */ |
| 46 | U8X8_C(0x0af), /* display on */ |
| 47 | U8X8_END_TRANSFER(), /* disable chip */ |
| 48 | U8X8_END() /* end of sequence */ |
| 49 | }; |
| 50 | |
| 51 | static const uint8_t u8x8_d_st7565_powersave1_seq[] = { |
| 52 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 53 | U8X8_C(0x0ae), /* display off */ |
| 54 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 55 | U8X8_END_TRANSFER(), /* disable chip */ |
| 56 | U8X8_END() /* end of sequence */ |
| 57 | }; |
| 58 | |
| 59 | static const uint8_t u8x8_d_st7565_flip0_seq[] = { |
| 60 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 61 | U8X8_C(0x0a1), /* segment remap a0/a1*/ |
| 62 | U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ |
| 63 | U8X8_END_TRANSFER(), /* disable chip */ |
| 64 | U8X8_END() /* end of sequence */ |
| 65 | }; |
| 66 | |
| 67 | static const uint8_t u8x8_d_st7565_flip1_seq[] = { |
| 68 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 69 | U8X8_C(0x0a0), /* segment remap a0/a1*/ |
| 70 | U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ |
| 71 | U8X8_END_TRANSFER(), /* disable chip */ |
| 72 | U8X8_END() /* end of sequence */ |
| 73 | }; |
| 74 | |
| 75 | static const uint8_t u8x8_d_st7565_zflip0_seq[] = { |
| 76 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 77 | U8X8_C(0x0a1), /* segment remap a0/a1*/ |
| 78 | U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */ |
| 79 | U8X8_END_TRANSFER(), /* disable chip */ |
| 80 | U8X8_END() /* end of sequence */ |
| 81 | }; |
| 82 | |
| 83 | static const uint8_t u8x8_d_st7565_zflip1_seq[] = { |
| 84 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 85 | U8X8_C(0x0a0), /* segment remap a0/a1*/ |
| 86 | U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */ |
| 87 | U8X8_END_TRANSFER(), /* disable chip */ |
| 88 | U8X8_END() /* end of sequence */ |
| 89 | }; |
| 90 | |
| 91 | static const u8x8_display_info_t u8x8_st7565_128x64_display_info = |
| 92 | { |
| 93 | /* chip_enable_level = */ 0, |
| 94 | /* chip_disable_level = */ 1, |
| 95 | |
| 96 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 97 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 98 | /* reset_pulse_width_ms = */ 1, |
| 99 | /* post_reset_wait_ms = */ 1, |
| 100 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 101 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 102 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 103 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 104 | /* i2c_bus_clock_100kHz = */ 4, |
| 105 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 106 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 107 | /* tile_width = */ 16, /* width of 16*8=128 pixel */ |
| 108 | /* tile_height = */ 8, |
| 109 | /* default_x_offset = */ 0, |
| 110 | /* flipmode_x_offset = */ 4, |
| 111 | /* pixel_width = */ 128, |
| 112 | /* pixel_height = */ 64 |
| 113 | }; |
| 114 | |
| 115 | uint8_t u8x8_d_st7565_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 116 | { |
| 117 | uint8_t x, c; |
| 118 | uint8_t *ptr; |
| 119 | switch(msg) |
| 120 | { |
| 121 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 122 | u8x8_cad_StartTransfer(u8x8); |
| 123 | |
| 124 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 125 | x *= 8; |
| 126 | x += u8x8->x_offset; |
| 127 | u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); |
| 128 | u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); |
| 129 | u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 130 | |
| 131 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 132 | c *= 8; |
| 133 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 134 | /* |
| 135 | The following if condition checks the hardware limits of the st7565 |
| 136 | controller: It is not allowed to write beyond the display limits. |
| 137 | This is in fact an issue within flip mode. |
| 138 | */ |
| 139 | if ( c + x > 132u ) |
| 140 | { |
| 141 | c = 132u; |
| 142 | c -= x; |
| 143 | } |
| 144 | do |
| 145 | { |
| 146 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */ |
| 147 | arg_int--; |
| 148 | } while( arg_int > 0 ); |
| 149 | |
| 150 | u8x8_cad_EndTransfer(u8x8); |
| 151 | break; |
| 152 | /* handled in the calling procedure |
| 153 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 154 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_128x64_display_info); |
| 155 | break; |
| 156 | case U8X8_MSG_DISPLAY_INIT: |
| 157 | u8x8_d_helper_display_init(u8x8); |
| 158 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq); |
| 159 | break; |
| 160 | */ |
| 161 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 162 | if ( arg_int == 0 ) |
| 163 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_powersave0_seq); |
| 164 | else |
| 165 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_powersave1_seq); |
| 166 | break; |
| 167 | #ifdef U8X8_WITH_SET_CONTRAST |
| 168 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 169 | u8x8_cad_StartTransfer(u8x8); |
| 170 | u8x8_cad_SendCmd(u8x8, 0x081 ); |
| 171 | u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* st7565 has range from 0 to 63 */ |
| 172 | u8x8_cad_EndTransfer(u8x8); |
| 173 | break; |
| 174 | #endif |
| 175 | default: |
| 176 | return 0; |
| 177 | } |
| 178 | return 1; |
| 179 | } |
| 180 | |
| 181 | /*================================================*/ |
| 182 | /* DOGM128 */ |
| 183 | |
| 184 | static const uint8_t u8x8_d_st7565_dogm128_init_seq[] = { |
| 185 | |
| 186 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 187 | |
| 188 | U8X8_C(0x0e2), /* soft reset */ |
| 189 | U8X8_C(0x0ae), /* display off */ |
| 190 | U8X8_C(0x040), /* set display start line to 0 */ |
| 191 | |
| 192 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 193 | U8X8_C(0x0c0), /* common output mode */ |
| 194 | // Flipmode |
| 195 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 196 | // U8X8_C(0x0c8), /* common output mode */ |
| 197 | |
| 198 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 199 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 200 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 201 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */ |
| 202 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 203 | U8X8_CA(0x081, 0x018), /* set contrast, contrast value, EA default: 0x016 */ |
| 204 | |
| 205 | U8X8_C(0x0ae), /* display off */ |
| 206 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 207 | |
| 208 | U8X8_END_TRANSFER(), /* disable chip */ |
| 209 | U8X8_END() /* end of sequence */ |
| 210 | }; |
| 211 | |
| 212 | uint8_t u8x8_d_st7565_ea_dogm128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 213 | { |
| 214 | /* call common procedure first and handle messages there */ |
| 215 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 216 | { |
| 217 | /* msg not handled, then try here */ |
| 218 | switch(msg) |
| 219 | { |
| 220 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 221 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_128x64_display_info); |
| 222 | break; |
| 223 | case U8X8_MSG_DISPLAY_INIT: |
| 224 | u8x8_d_helper_display_init(u8x8); |
| 225 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_dogm128_init_seq); |
| 226 | break; |
| 227 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 228 | if ( arg_int == 0 ) |
| 229 | { |
| 230 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 231 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 232 | } |
| 233 | else |
| 234 | { |
| 235 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 236 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 237 | } |
| 238 | break; |
| 239 | default: |
| 240 | return 0; /* msg unknown */ |
| 241 | } |
| 242 | } |
| 243 | return 1; |
| 244 | } |
| 245 | |
| 246 | |
| 247 | |
| 248 | /*================================================*/ |
| 249 | /* LM6063 https://github.com/olikraus/u8g2/issues/893 */ |
| 250 | |
| 251 | static const uint8_t u8x8_d_st7565_lm6063_init_seq[] = { |
| 252 | |
| 253 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 254 | |
| 255 | U8X8_C(0x0e2), /* soft reset */ |
| 256 | U8X8_C(0x0ae), /* display off */ |
| 257 | U8X8_C(0x040), /* set display start line to 0 */ |
| 258 | |
| 259 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 260 | U8X8_C(0x0c0), /* common output mode */ |
| 261 | // Flipmode |
| 262 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 263 | // U8X8_C(0x0c8), /* common output mode */ |
| 264 | |
| 265 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 266 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 267 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 268 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */ |
| 269 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 270 | U8X8_CA(0x081, 50/4), /* set contrast, contrast value, 40..60 seems to be good */ |
| 271 | |
| 272 | U8X8_C(0x0ae), /* display off */ |
| 273 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 274 | |
| 275 | U8X8_END_TRANSFER(), /* disable chip */ |
| 276 | U8X8_END() /* end of sequence */ |
| 277 | }; |
| 278 | |
| 279 | uint8_t u8x8_d_st7565_lm6063(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 280 | { |
| 281 | /* call common procedure first and handle messages there */ |
| 282 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 283 | { |
| 284 | /* msg not handled, then try here */ |
| 285 | switch(msg) |
| 286 | { |
| 287 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 288 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_128x64_display_info); |
| 289 | break; |
| 290 | case U8X8_MSG_DISPLAY_INIT: |
| 291 | u8x8_d_helper_display_init(u8x8); |
| 292 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_lm6063_init_seq); |
| 293 | break; |
| 294 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 295 | if ( arg_int == 0 ) |
| 296 | { |
| 297 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 298 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 303 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 304 | } |
| 305 | break; |
| 306 | default: |
| 307 | return 0; /* msg unknown */ |
| 308 | } |
| 309 | } |
| 310 | return 1; |
| 311 | } |
| 312 | |
| 313 | |
| 314 | /*================================================*/ |
| 315 | /* Displaytech 64128n */ |
| 316 | |
| 317 | static const uint8_t u8x8_d_st7565_64128n_init_seq[] = { |
| 318 | |
| 319 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 320 | |
| 321 | #ifdef NOT_WORKING |
| 322 | |
| 323 | U8X8_C(0x0e2), /* soft reset */ |
| 324 | U8X8_C(0x0ae), /* display off */ |
| 325 | U8X8_C(0x040), /* set display start line to 0 */ |
| 326 | |
| 327 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 328 | U8X8_C(0x0c0), /* common output mode */ |
| 329 | // Flipmode |
| 330 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 331 | // U8X8_C(0x0c8), /* common output mode */ |
| 332 | |
| 333 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 334 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 335 | U8X8_C(0x02f), /* all power control circuits on */ |
| 336 | //U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */ |
| 337 | //U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 338 | |
| 339 | U8X8_C(0x010), /* Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N */ |
| 340 | |
| 341 | |
| 342 | U8X8_CA(0x081, 0x01e), /* set contrast, contrast value */ |
| 343 | |
| 344 | U8X8_C(0x0ae), /* display off */ |
| 345 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 346 | #else |
| 347 | |
| 348 | |
| 349 | U8X8_C(0x0e2), /* soft reset */ |
| 350 | U8X8_C(0x0A2), /* 0x0a2: LCD bias 1/9 (according to Displaytech 64128N datasheet) */ |
| 351 | |
| 352 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 353 | U8X8_C(0x0c0), /* common output mode */ |
| 354 | //U8X8_C(0x0A0), /* Normal ADC Select (according to Displaytech 64128N datasheet) */ |
| 355 | //U8X8_C(0x0c8), /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */ |
| 356 | |
| 357 | U8X8_C(0x040), /* Display start line for Displaytech 64128N */ |
| 358 | U8X8_C(0x028 | 0x04), /* power control: turn on voltage converter */ |
| 359 | U8X8_C(0x028 | 0x06), /* power control: turn on voltage regulator */ |
| 360 | U8X8_C(0x028 | 0x07), /* power control: turn on voltage follower */ |
| 361 | U8X8_C(0x010), /* Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N */ |
| 362 | /* 19 Jul 17: Not sure if this is true, cmd 0x1? is used to set the column */ |
| 363 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 364 | U8X8_C(0x081), /* set contrast */ |
| 365 | U8X8_C(0x01e), /* Contrast value. Setting for controlling brightness of Displaytech 64128N */ |
| 366 | //U8X8_C(0x0af), /* display on */ |
| 367 | //U8X8_C(0x0a5), /* display all points, ST7565 */ |
| 368 | //U8X8_C(0x0a4), /* normal display */ |
| 369 | |
| 370 | U8X8_C(0x0ae), /* display off */ |
| 371 | |
| 372 | |
| 373 | #endif |
| 374 | |
| 375 | U8X8_END_TRANSFER(), /* disable chip */ |
| 376 | U8X8_END() /* end of sequence */ |
| 377 | }; |
| 378 | |
| 379 | static const u8x8_display_info_t u8x8_st7565_64128n_display_info = |
| 380 | { |
| 381 | /* chip_enable_level = */ 0, |
| 382 | /* chip_disable_level = */ 1, |
| 383 | |
| 384 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 385 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 386 | /* reset_pulse_width_ms = */ 1, |
| 387 | /* post_reset_wait_ms = */ 1, |
| 388 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 389 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 390 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 391 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 392 | /* i2c_bus_clock_100kHz = */ 4, |
| 393 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 394 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 395 | /* tile_width = */ 16, /* width of 16*8=128 pixel */ |
| 396 | /* tile_height = */ 8, |
| 397 | /* default_x_offset = */ 4, |
| 398 | /* flipmode_x_offset = */ 0, |
| 399 | /* pixel_width = */ 128, |
| 400 | /* pixel_height = */ 64 |
| 401 | }; |
| 402 | |
| 403 | uint8_t u8x8_d_st7565_64128n(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 404 | { |
| 405 | /* call common procedure first and handle messages there */ |
| 406 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 407 | { |
| 408 | /* msg not handled, then try here */ |
| 409 | switch(msg) |
| 410 | { |
| 411 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 412 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_64128n_display_info); |
| 413 | break; |
| 414 | case U8X8_MSG_DISPLAY_INIT: |
| 415 | u8x8_d_helper_display_init(u8x8); |
| 416 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_64128n_init_seq); |
| 417 | break; |
| 418 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 419 | if ( arg_int == 0 ) |
| 420 | { |
| 421 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 422 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 423 | } |
| 424 | else |
| 425 | { |
| 426 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 427 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 428 | } |
| 429 | break; |
| 430 | default: |
| 431 | return 0; /* msg unknown */ |
| 432 | } |
| 433 | } |
| 434 | return 1; |
| 435 | } |
| 436 | |
| 437 | /*================================================*/ |
| 438 | /* ZOLEN 128x64 */ |
| 439 | |
| 440 | static const uint8_t u8x8_d_st7565_zolen_128x64_init_seq[] = { |
| 441 | |
| 442 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 443 | |
| 444 | U8X8_C(0x0e2), /* soft reset */ |
| 445 | U8X8_C(0x0ae), /* display off */ |
| 446 | U8X8_C(0x040), /* set display start line to 0 */ |
| 447 | |
| 448 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 449 | U8X8_C(0x0c8), /* common output mode */ |
| 450 | // Flipmode |
| 451 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 452 | // U8X8_C(0x0c0), /* common output mode */ |
| 453 | |
| 454 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 455 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 456 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 457 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */ |
| 458 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 459 | U8X8_CA(0x081, 0x007), /* set contrast, contrast value, EA default: 0x016 */ |
| 460 | |
| 461 | U8X8_C(0x0ae), /* display off */ |
| 462 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 463 | |
| 464 | U8X8_END_TRANSFER(), /* disable chip */ |
| 465 | U8X8_END() /* end of sequence */ |
| 466 | }; |
| 467 | |
| 468 | uint8_t u8x8_d_st7565_zolen_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 469 | { |
| 470 | /* call common procedure first and handle messages there */ |
| 471 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 472 | { |
| 473 | /* msg not handled, then try here */ |
| 474 | switch(msg) |
| 475 | { |
| 476 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 477 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_128x64_display_info); |
| 478 | break; |
| 479 | case U8X8_MSG_DISPLAY_INIT: |
| 480 | u8x8_d_helper_display_init(u8x8); |
| 481 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_zolen_128x64_init_seq); |
| 482 | break; |
| 483 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 484 | if ( arg_int == 0 ) |
| 485 | { |
| 486 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_zflip0_seq); |
| 487 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_zflip1_seq); |
| 492 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 493 | } |
| 494 | break; |
| 495 | default: |
| 496 | return 0; /* msg unknown */ |
| 497 | } |
| 498 | } |
| 499 | return 1; |
| 500 | } |
| 501 | |
| 502 | |
| 503 | |
| 504 | /*================================================*/ |
| 505 | /* NHD-C12832 */ |
| 506 | |
| 507 | static const u8x8_display_info_t u8x8_st7565_128x32_display_info = |
| 508 | { |
| 509 | /* chip_enable_level = */ 0, |
| 510 | /* chip_disable_level = */ 1, |
| 511 | |
| 512 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 513 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 514 | /* reset_pulse_width_ms = */ 1, |
| 515 | /* post_reset_wait_ms = */ 1, |
| 516 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 517 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 518 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 519 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 520 | /* i2c_bus_clock_100kHz = */ 4, |
| 521 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 522 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 523 | /* tile_width = */ 16, /* width of 16*8=128 pixel */ |
| 524 | /* tile_height = */ 4, |
| 525 | /* default_x_offset = */ 4, |
| 526 | /* flipmode_x_offset = */ 0, |
| 527 | /* pixel_width = */ 128, |
| 528 | /* pixel_height = */ 32 |
| 529 | }; |
| 530 | |
| 531 | |
| 532 | static const uint8_t u8x8_d_st7565_nhd_c12832_init_seq[] = { |
| 533 | |
| 534 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 535 | |
| 536 | U8X8_C(0x0e2), /* soft reset */ |
| 537 | U8X8_C(0x0ae), /* display off */ |
| 538 | U8X8_C(0x040), /* set display start line to 0 */ |
| 539 | |
| 540 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 541 | U8X8_C(0x0c0), /* common output mode */ |
| 542 | // Flipmode |
| 543 | //U8X8_C(0x0a0), /* ADC set to reverse */ |
| 544 | //U8X8_C(0x0c8), /* common output mode */ |
| 545 | |
| 546 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 547 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 548 | U8X8_C(0x02f), /* all power control circuits on */ |
| 549 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */ |
| 550 | U8X8_C(0x023), /* set V0 voltage resistor ratio to large*/ |
| 551 | U8X8_CA(0x081, 0x00a), /* set contrast, contrast value NHD C12832 */ |
| 552 | |
| 553 | U8X8_C(0x0ae), /* display off */ |
| 554 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 555 | |
| 556 | U8X8_END_TRANSFER(), /* disable chip */ |
| 557 | U8X8_END() /* end of sequence */ |
| 558 | }; |
| 559 | |
| 560 | uint8_t u8x8_d_st7565_nhd_c12832(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 561 | { |
| 562 | /* call common procedure first and handle messages there */ |
| 563 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 564 | { |
| 565 | /* msg not handled, then try here */ |
| 566 | switch(msg) |
| 567 | { |
| 568 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 569 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_128x32_display_info); |
| 570 | break; |
| 571 | case U8X8_MSG_DISPLAY_INIT: |
| 572 | u8x8_d_helper_display_init(u8x8); |
| 573 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_nhd_c12832_init_seq); |
| 574 | break; |
| 575 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 576 | if ( arg_int == 0 ) |
| 577 | { |
| 578 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 579 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 580 | } |
| 581 | else |
| 582 | { |
| 583 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 584 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 585 | } |
| 586 | break; |
| 587 | default: |
| 588 | return 0; /* msg unknown */ |
| 589 | } |
| 590 | } |
| 591 | return 1; |
| 592 | } |
| 593 | |
| 594 | /*================================================*/ |
| 595 | /* NHD-C12864 */ |
| 596 | |
| 597 | static const u8x8_display_info_t u8x8_st7565_nhd_c12864_display_info = |
| 598 | { |
| 599 | /* chip_enable_level = */ 0, |
| 600 | /* chip_disable_level = */ 1, |
| 601 | |
| 602 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 603 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 604 | /* reset_pulse_width_ms = */ 1, |
| 605 | /* post_reset_wait_ms = */ 1, |
| 606 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 607 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 608 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 609 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 610 | /* i2c_bus_clock_100kHz = */ 4, |
| 611 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 612 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 613 | /* tile_width = */ 16, /* width of 16*8=128 pixel */ |
| 614 | /* tile_height = */ 8, |
| 615 | /* default_x_offset = */ 4, |
| 616 | /* flipmode_x_offset = */ 0, |
| 617 | /* pixel_width = */ 128, |
| 618 | /* pixel_height = */ 64 |
| 619 | }; |
| 620 | |
| 621 | |
| 622 | static const uint8_t u8x8_d_st7565_nhd_c12864_init_seq[] = { |
| 623 | |
| 624 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 625 | |
| 626 | U8X8_C(0x0e2), /* soft reset */ |
| 627 | U8X8_C(0x0ae), /* display off */ |
| 628 | U8X8_C(0x040), /* set display start line to 0 */ |
| 629 | |
| 630 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 631 | U8X8_C(0x0c0), /* common output mode */ |
| 632 | // Flipmode |
| 633 | //U8X8_C(0x0a0), /* ADC set to reverse */ |
| 634 | //U8X8_C(0x0c8), /* common output mode */ |
| 635 | |
| 636 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 637 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 638 | U8X8_C(0x02f), /* all power control circuits on */ |
| 639 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */ |
| 640 | U8X8_C(0x025), /* set V0 voltage resistor ratio to large, issue 1678: changed from 0x23 to 0x25 */ |
| 641 | U8X8_CA(0x081, 170), /* set contrast, contrast value NHD C12864, see issue 186, increased contrast to 180 (issue 219), reduced to 170 (issue 1678) */ |
| 642 | |
| 643 | U8X8_C(0x0ae), /* display off */ |
| 644 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 645 | |
| 646 | U8X8_END_TRANSFER(), /* disable chip */ |
| 647 | U8X8_END() /* end of sequence */ |
| 648 | }; |
| 649 | |
| 650 | uint8_t u8x8_d_st7565_nhd_c12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 651 | { |
| 652 | /* call common procedure first and handle messages there */ |
| 653 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 654 | { |
| 655 | /* msg not handled, then try here */ |
| 656 | switch(msg) |
| 657 | { |
| 658 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 659 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_nhd_c12864_display_info); |
| 660 | break; |
| 661 | case U8X8_MSG_DISPLAY_INIT: |
| 662 | u8x8_d_helper_display_init(u8x8); |
| 663 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_nhd_c12864_init_seq); |
| 664 | break; |
| 665 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 666 | if ( arg_int == 0 ) |
| 667 | { |
| 668 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 669 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 670 | } |
| 671 | else |
| 672 | { |
| 673 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 674 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 675 | } |
| 676 | break; |
| 677 | default: |
| 678 | return 0; /* msg unknown */ |
| 679 | } |
| 680 | } |
| 681 | return 1; |
| 682 | } |
| 683 | /*================================================*/ |
| 684 | /* JLX12864 */ |
| 685 | |
| 686 | uint8_t u8x8_d_st7565_jlx12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 687 | { |
| 688 | return u8x8_d_st7565_nhd_c12864(u8x8, msg, arg_int, arg_ptr); |
| 689 | } |
| 690 | |
| 691 | |
| 692 | /*================================================*/ |
| 693 | /* LM6059 (Adafruit)... probably this is a ST7567 display */ |
| 694 | |
| 695 | static const uint8_t u8x8_d_st7565_lm6059_init_seq[] = { |
| 696 | |
| 697 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 698 | |
| 699 | U8X8_C(0x0e2), /* soft reset */ |
| 700 | U8X8_C(0x0ae), /* display off */ |
| 701 | U8X8_C(0x060), /* set display start line to ... */ |
| 702 | |
| 703 | U8X8_C(0x0a0), /* ADC set to reverse */ |
| 704 | U8X8_C(0x0c8), /* common output mode */ |
| 705 | //U8X8_C(0x0a1), /* ADC set to reverse */ |
| 706 | //U8X8_C(0x0c0), /* common output mode */ |
| 707 | // Flipmode |
| 708 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 709 | // U8X8_C(0x0c8), /* common output mode */ |
| 710 | |
| 711 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 712 | U8X8_C(0x0a3), /* LCD bias 1/9 */ |
| 713 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 714 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x (ST7567 feature) */ |
| 715 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 716 | U8X8_CA(0x081, 0x018), /* set contrast, contrast value, EA default: 0x016 */ |
| 717 | |
| 718 | U8X8_C(0x0ae), /* display off */ |
| 719 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 720 | |
| 721 | U8X8_END_TRANSFER(), /* disable chip */ |
| 722 | U8X8_END() /* end of sequence */ |
| 723 | }; |
| 724 | |
| 725 | static const u8x8_display_info_t u8x8_st7565_lm6059_display_info = |
| 726 | { |
| 727 | /* chip_enable_level = */ 0, |
| 728 | /* chip_disable_level = */ 1, |
| 729 | |
| 730 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 731 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 732 | /* reset_pulse_width_ms = */ 1, |
| 733 | /* post_reset_wait_ms = */ 1, |
| 734 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 735 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 736 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 737 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 738 | /* i2c_bus_clock_100kHz = */ 4, |
| 739 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 740 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 741 | /* tile_width = */ 16, /* width of 16*8=128 pixel */ |
| 742 | /* tile_height = */ 8, |
| 743 | /* default_x_offset = */ 1, /* not sure... */ |
| 744 | /* flipmode_x_offset = */ 3, |
| 745 | /* pixel_width = */ 128, |
| 746 | /* pixel_height = */ 64 |
| 747 | }; |
| 748 | |
| 749 | uint8_t u8x8_d_st7565_lm6059(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 750 | { |
| 751 | /* call common procedure first and handle messages there */ |
| 752 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 753 | { |
| 754 | /* msg not handled, then try here */ |
| 755 | switch(msg) |
| 756 | { |
| 757 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 758 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_lm6059_display_info); |
| 759 | break; |
| 760 | case U8X8_MSG_DISPLAY_INIT: |
| 761 | u8x8_d_helper_display_init(u8x8); |
| 762 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_lm6059_init_seq); |
| 763 | break; |
| 764 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 765 | if ( arg_int == 0 ) |
| 766 | { |
| 767 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 768 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 769 | } |
| 770 | else |
| 771 | { |
| 772 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 773 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 774 | } |
| 775 | break; |
| 776 | default: |
| 777 | return 0; /* msg unknown */ |
| 778 | } |
| 779 | } |
| 780 | return 1; |
| 781 | } |
| 782 | |
| 783 | /*================================================*/ |
| 784 | /* https://github.com/olikraus/u8g2/issues/1314 */ |
| 785 | /* KS0713 controller, takeover from LM6059 */ |
| 786 | |
| 787 | static const uint8_t u8x8_d_st7565_ks0713_init_seq[] = { |
| 788 | |
| 789 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 790 | U8X8_C(0x0ae), /* display off */ |
| 791 | U8X8_C(0x0e2), /* soft reset */ |
| 792 | U8X8_C(0x0a3), /* LCD bias 1/9 */ |
| 793 | U8X8_C(0x0a0), /* ADC set to reverse */ |
| 794 | U8X8_C(0x0c0), /* common output mode */ |
| 795 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 796 | U8X8_C(0x026), /* set V0 voltage resistor ratio to max */ |
| 797 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 798 | U8X8_CA(0x081, 0x010), /* set contrast, contrast value, EA default: 0x016 */ |
| 799 | U8X8_C(0x0af), /* display on */ |
| 800 | U8X8_END_TRANSFER(), /* disable chip */ |
| 801 | U8X8_END() /* end of sequence */ |
| 802 | }; |
| 803 | |
| 804 | uint8_t u8x8_d_st7565_ks0713(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 805 | { |
| 806 | /* call common procedure first and handle messages there */ |
| 807 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 808 | { |
| 809 | /* msg not handled, then try here */ |
| 810 | switch(msg) |
| 811 | { |
| 812 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 813 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_lm6059_display_info); |
| 814 | break; |
| 815 | case U8X8_MSG_DISPLAY_INIT: |
| 816 | u8x8_d_helper_display_init(u8x8); |
| 817 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_ks0713_init_seq); |
| 818 | break; |
| 819 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 820 | if ( arg_int == 0 ) |
| 821 | { |
| 822 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_zflip1_seq); |
| 823 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 824 | } |
| 825 | else |
| 826 | { |
| 827 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_zflip0_seq); |
| 828 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 829 | } |
| 830 | break; |
| 831 | default: |
| 832 | return 0; /* msg unknown */ |
| 833 | } |
| 834 | } |
| 835 | return 1; |
| 836 | } |
| 837 | |
| 838 | |
| 839 | /*================================================*/ |
| 840 | /* LX12864 issue 576 */ |
| 841 | |
| 842 | static const uint8_t u8x8_d_st7565_lx12864_init_seq[] = { |
| 843 | |
| 844 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 845 | |
| 846 | U8X8_C(0x0e2), /* soft reset */ |
| 847 | U8X8_C(0x0ae), /* display off */ |
| 848 | U8X8_C(0x060), /* set display start line to ... */ |
| 849 | |
| 850 | U8X8_C(0x0a0), /* ADC set to reverse */ |
| 851 | U8X8_C(0x0c8), /* common output mode */ |
| 852 | //U8X8_C(0x0a1), /* ADC set to reverse */ |
| 853 | //U8X8_C(0x0c0), /* common output mode */ |
| 854 | // Flipmode |
| 855 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 856 | // U8X8_C(0x0c8), /* common output mode */ |
| 857 | |
| 858 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 859 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 860 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 861 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x (ST7567 feature) */ |
| 862 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 863 | U8X8_CA(0x081, 0x008), /* set contrast, contrast value */ |
| 864 | |
| 865 | U8X8_C(0x0ae), /* display off */ |
| 866 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 867 | |
| 868 | U8X8_END_TRANSFER(), /* disable chip */ |
| 869 | U8X8_END() /* end of sequence */ |
| 870 | }; |
| 871 | |
| 872 | static const u8x8_display_info_t u8x8_st7565_lx12864_display_info = |
| 873 | { |
| 874 | /* chip_enable_level = */ 0, |
| 875 | /* chip_disable_level = */ 1, |
| 876 | |
| 877 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 878 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 879 | /* reset_pulse_width_ms = */ 1, |
| 880 | /* post_reset_wait_ms = */ 1, |
| 881 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 882 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 883 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 884 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 885 | /* i2c_bus_clock_100kHz = */ 4, |
| 886 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 887 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 888 | /* tile_width = */ 16, /* width of 16*8=128 pixel */ |
| 889 | /* tile_height = */ 8, |
| 890 | /* default_x_offset = */ 1, /* not sure... */ |
| 891 | /* flipmode_x_offset = */ 3, |
| 892 | /* pixel_width = */ 128, |
| 893 | /* pixel_height = */ 64 |
| 894 | }; |
| 895 | |
| 896 | uint8_t u8x8_d_st7565_lx12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 897 | { |
| 898 | /* call common procedure first and handle messages there */ |
| 899 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 900 | { |
| 901 | /* msg not handled, then try here */ |
| 902 | switch(msg) |
| 903 | { |
| 904 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 905 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_lx12864_display_info); |
| 906 | break; |
| 907 | case U8X8_MSG_DISPLAY_INIT: |
| 908 | u8x8_d_helper_display_init(u8x8); |
| 909 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_lx12864_init_seq); |
| 910 | break; |
| 911 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 912 | if ( arg_int == 0 ) |
| 913 | { |
| 914 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 915 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 916 | } |
| 917 | else |
| 918 | { |
| 919 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 920 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 921 | } |
| 922 | break; |
| 923 | default: |
| 924 | return 0; /* msg unknown */ |
| 925 | } |
| 926 | } |
| 927 | return 1; |
| 928 | } |
| 929 | |
| 930 | |
| 931 | /*================================================*/ |
| 932 | /* ERC12864-1 (buydisplay.com) */ |
| 933 | |
| 934 | static const uint8_t u8x8_d_st7565_erc12864_init_seq[] = { |
| 935 | |
| 936 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 937 | |
| 938 | U8X8_C(0x0e2), /* soft reset */ |
| 939 | U8X8_C(0x0ae), /* display off */ |
| 940 | U8X8_C(0x040), /* set display start line to ... */ |
| 941 | |
| 942 | U8X8_C(0x0a0), /* ADC set to reverse */ |
| 943 | U8X8_C(0x0c8), /* common output mode */ |
| 944 | //U8X8_C(0x0a1), /* ADC set to reverse */ |
| 945 | //U8X8_C(0x0c0), /* common output mode */ |
| 946 | // Flipmode |
| 947 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 948 | // U8X8_C(0x0c8), /* common output mode */ |
| 949 | |
| 950 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 951 | U8X8_C(0x0a3), /* LCD bias 1/9 */ |
| 952 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 953 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x (ST7567 feature)*/ |
| 954 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 955 | U8X8_CA(0x081, 0x018), /* set contrast, contrast value, EA default: 0x016 */ |
| 956 | |
| 957 | U8X8_C(0x0ae), /* display off */ |
| 958 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 959 | |
| 960 | U8X8_END_TRANSFER(), /* disable chip */ |
| 961 | U8X8_END() /* end of sequence */ |
| 962 | }; |
| 963 | |
| 964 | static const u8x8_display_info_t u8x8_st7565_erc12864_display_info = |
| 965 | { |
| 966 | /* chip_enable_level = */ 0, |
| 967 | /* chip_disable_level = */ 1, |
| 968 | |
| 969 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 970 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 971 | /* reset_pulse_width_ms = */ 1, |
| 972 | /* post_reset_wait_ms = */ 1, |
| 973 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 974 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 975 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 976 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 977 | /* i2c_bus_clock_100kHz = */ 4, |
| 978 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 979 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 980 | /* tile_width = */ 16, /* width of 16*8=128 pixel */ |
| 981 | /* tile_height = */ 8, |
| 982 | /* default_x_offset = */ 0, |
| 983 | /* flipmode_x_offset = */ 4, |
| 984 | /* pixel_width = */ 128, |
| 985 | /* pixel_height = */ 64 |
| 986 | }; |
| 987 | |
| 988 | uint8_t u8x8_d_st7565_erc12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 989 | { |
| 990 | /* call common procedure first and handle messages there */ |
| 991 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 992 | { |
| 993 | /* msg not handled, then try here */ |
| 994 | switch(msg) |
| 995 | { |
| 996 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 997 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_erc12864_display_info); |
| 998 | break; |
| 999 | case U8X8_MSG_DISPLAY_INIT: |
| 1000 | u8x8_d_helper_display_init(u8x8); |
| 1001 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_erc12864_init_seq); |
| 1002 | break; |
| 1003 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1004 | if ( arg_int == 0 ) |
| 1005 | { |
| 1006 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 1007 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1008 | } |
| 1009 | else |
| 1010 | { |
| 1011 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 1012 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1013 | } |
| 1014 | break; |
| 1015 | default: |
| 1016 | return 0; /* msg unknown */ |
| 1017 | } |
| 1018 | } |
| 1019 | return 1; |
| 1020 | } |
| 1021 | |
| 1022 | |
| 1023 | |
| 1024 | |
| 1025 | /*================================================*/ |
| 1026 | /* ERC12864-1 alternative version, suggested in issue 790 */ |
| 1027 | |
| 1028 | static const uint8_t u8x8_d_st7565_erc12864_alt_init_seq[] = { |
| 1029 | |
| 1030 | |
| 1031 | // original sequence |
| 1032 | |
| 1033 | // U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1034 | |
| 1035 | // U8X8_C(0x0e2), /* soft reset */ |
| 1036 | // U8X8_C(0x0ae), /* display off */ |
| 1037 | // U8X8_C(0x040), /* set display start line to ... */ |
| 1038 | |
| 1039 | // U8X8_C(0x0a0), /* ADC set to reverse */ |
| 1040 | // U8X8_C(0x0c8), /* common output mode */ |
| 1041 | |
| 1042 | // U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 1043 | // U8X8_C(0x0a3), /* LCD bias 1/9 */ |
| 1044 | // U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 1045 | // U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x (ST7567 feature)*/ |
| 1046 | // U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 1047 | // U8X8_CA(0x081, 0x018), /* set contrast, contrast value, EA default: 0x016 */ |
| 1048 | |
| 1049 | // U8X8_C(0x0ae), /* display off */ |
| 1050 | // U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 1051 | |
| 1052 | // U8X8_END_TRANSFER(), /* disable chip */ |
| 1053 | // U8X8_END() /* end of sequence */ |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | // suggested in https://github.com/olikraus/u8g2/issues/790 |
| 1058 | |
| 1059 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1060 | |
| 1061 | U8X8_C(0x0e2), /* soft reset */ |
| 1062 | U8X8_C(0x0ae), /* display off */ |
| 1063 | U8X8_C(0x040), /* set display start line to ... */ |
| 1064 | |
| 1065 | U8X8_C(0x0a0), /* ADC set to reverse */ |
| 1066 | U8X8_C(0x0c8), /* common output mode */ |
| 1067 | |
| 1068 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 1069 | U8X8_C(0x0a2), /* LCD bias 1/9 - *** Changed by Ismail - was 0xa3 - 1/7 bias we were getting dark pixel off */ |
| 1070 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 1071 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x (ST7567 feature)*/ |
| 1072 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 1073 | U8X8_CA(0x081, 0x05), /* set contrast, contrast value, EA default: 0x016 - *** Changed by Ismail to 0x05 */ |
| 1074 | |
| 1075 | U8X8_C(0x0ae), /* display off */ |
| 1076 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 1077 | |
| 1078 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1079 | U8X8_END() /* end of sequence */ |
| 1080 | |
| 1081 | }; |
| 1082 | |
| 1083 | |
| 1084 | uint8_t u8x8_d_st7565_erc12864_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1085 | { |
| 1086 | /* call common procedure first and handle messages there */ |
| 1087 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 1088 | { |
| 1089 | /* msg not handled, then try here */ |
| 1090 | switch(msg) |
| 1091 | { |
| 1092 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1093 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_erc12864_display_info); |
| 1094 | break; |
| 1095 | case U8X8_MSG_DISPLAY_INIT: |
| 1096 | u8x8_d_helper_display_init(u8x8); |
| 1097 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_erc12864_alt_init_seq); |
| 1098 | break; |
| 1099 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1100 | if ( arg_int == 0 ) |
| 1101 | { |
| 1102 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 1103 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1104 | } |
| 1105 | else |
| 1106 | { |
| 1107 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 1108 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1109 | } |
| 1110 | break; |
| 1111 | default: |
| 1112 | return 0; /* msg unknown */ |
| 1113 | } |
| 1114 | } |
| 1115 | return 1; |
| 1116 | } |
| 1117 | |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | /*================================================*/ |
| 1122 | /* NT7534, TG12864R */ |
| 1123 | /* The NT7534 has an extended command set for the ST7565, however this is not used. */ |
| 1124 | /* The TG12864R display is also shifted in lines, like the LM6059/Adafruit display */ |
| 1125 | /* However contrast seems to be different */ |
| 1126 | |
| 1127 | static const uint8_t u8x8_d_nt7534_tg12864r_init_seq[] = { |
| 1128 | |
| 1129 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1130 | |
| 1131 | U8X8_C(0x0e2), /* soft reset */ |
| 1132 | U8X8_C(0x0ae), /* display off */ |
| 1133 | U8X8_C(0x060), /* set display start line to ... */ |
| 1134 | |
| 1135 | U8X8_C(0x0a0), /* ADC set to reverse */ |
| 1136 | U8X8_C(0x0c8), /* common output mode */ |
| 1137 | // Flipmode |
| 1138 | //U8X8_C(0x0a1), /* ADC set to reverse */ |
| 1139 | //U8X8_C(0x0c0), /* common output mode */ |
| 1140 | |
| 1141 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 1142 | U8X8_C(0x0a3), /* LCD bias 1/9 */ |
| 1143 | U8X8_C(0x02f), /* all power control circuits on (regulator, booster and follower) */ |
| 1144 | //U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x (ST7567 feature)*/ |
| 1145 | U8X8_C(0x027), /* set V0 voltage resistor ratio to max */ |
| 1146 | U8X8_CA(0x081, 0x009), /* set contrast, contrast value, EA default: 0x016 */ |
| 1147 | |
| 1148 | U8X8_C(0x0ae), /* display off */ |
| 1149 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 1150 | |
| 1151 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1152 | U8X8_END() /* end of sequence */ |
| 1153 | }; |
| 1154 | |
| 1155 | uint8_t u8x8_d_nt7534_tg12864r(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1156 | { |
| 1157 | /* call common procedure first and handle messages there */ |
| 1158 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 1159 | { |
| 1160 | /* msg not handled, then try here */ |
| 1161 | switch(msg) |
| 1162 | { |
| 1163 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1164 | /* reuse the LM6059 data structure... this display seems to have similar shifts and offsets */ |
| 1165 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_lm6059_display_info); |
| 1166 | break; |
| 1167 | case U8X8_MSG_DISPLAY_INIT: |
| 1168 | u8x8_d_helper_display_init(u8x8); |
| 1169 | |
| 1170 | //u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_lm6059_init_seq); |
| 1171 | u8x8_cad_SendSequence(u8x8, u8x8_d_nt7534_tg12864r_init_seq); |
| 1172 | break; |
| 1173 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1174 | if ( arg_int == 0 ) |
| 1175 | { |
| 1176 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 1177 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1178 | } |
| 1179 | else |
| 1180 | { |
| 1181 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 1182 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1183 | } |
| 1184 | break; |
| 1185 | default: |
| 1186 | return 0; /* msg unknown */ |
| 1187 | } |
| 1188 | } |
| 1189 | return 1; |
| 1190 | } |
| 1191 | |
| 1192 | |
| 1193 | /*================================================*/ |
| 1194 | /* EA DOGM132 */ |
| 1195 | |
| 1196 | static const u8x8_display_info_t u8x8_st7565_dogm132_display_info = |
| 1197 | { |
| 1198 | /* chip_enable_level = */ 0, |
| 1199 | /* chip_disable_level = */ 1, |
| 1200 | |
| 1201 | /* post_chip_enable_wait_ns = */ 150, /* st7565 datasheet, table 26, tcsh */ |
| 1202 | /* pre_chip_disable_wait_ns = */ 50, /* st7565 datasheet, table 26, tcss */ |
| 1203 | /* reset_pulse_width_ms = */ 1, |
| 1204 | /* post_reset_wait_ms = */ 1, |
| 1205 | /* sda_setup_time_ns = */ 50, /* st7565 datasheet, table 26, tsds */ |
| 1206 | /* sck_pulse_width_ns = */ 120, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */ |
| 1207 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 1208 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 1209 | /* i2c_bus_clock_100kHz = */ 4, |
| 1210 | /* data_setup_time_ns = */ 40, /* st7565 datasheet, table 24, tds8 */ |
| 1211 | /* write_pulse_width_ns = */ 80, /* st7565 datasheet, table 24, tcclw */ |
| 1212 | /* tile_width = */ 17, /* width of 16*8=136 pixel */ |
| 1213 | /* tile_height = */ 4, |
| 1214 | /* default_x_offset = */ 0, |
| 1215 | /* flipmode_x_offset = */ 0, |
| 1216 | /* pixel_width = */ 132, |
| 1217 | /* pixel_height = */ 32 |
| 1218 | }; |
| 1219 | |
| 1220 | |
| 1221 | static const uint8_t u8x8_d_st7565_dogm132_init_seq[] = { |
| 1222 | |
| 1223 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1224 | |
| 1225 | U8X8_C(0x0e2), /* soft reset */ |
| 1226 | U8X8_C(0x0ae), /* display off */ |
| 1227 | U8X8_C(0x040), /* set display start line to 0 */ |
| 1228 | |
| 1229 | U8X8_C(0x0a1), /* ADC set to reverse */ |
| 1230 | U8X8_C(0x0c0), /* common output mode */ |
| 1231 | // Flipmode |
| 1232 | //U8X8_C(0x0a0), /* ADC set to reverse */ |
| 1233 | //U8X8_C(0x0c8), /* common output mode */ |
| 1234 | |
| 1235 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */ |
| 1236 | U8X8_C(0x0a2), /* LCD bias 1/9 */ |
| 1237 | U8X8_C(0x02f), /* all power control circuits on */ |
| 1238 | U8X8_CA(0x0f8, 0x000), /* set booster ratio to 4x */ |
| 1239 | U8X8_C(0x023), /* set V0 voltage resistor ratio to large*/ |
| 1240 | U8X8_CA(0x081, 0x01f), /* set contrast, contrast value EA DOGM132 */ |
| 1241 | |
| 1242 | U8X8_C(0x0ae), /* display off */ |
| 1243 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */ |
| 1244 | |
| 1245 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1246 | U8X8_END() /* end of sequence */ |
| 1247 | }; |
| 1248 | |
| 1249 | uint8_t u8x8_d_st7565_ea_dogm132(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1250 | { |
| 1251 | /* call common procedure first and handle messages there */ |
| 1252 | if ( u8x8_d_st7565_common(u8x8, msg, arg_int, arg_ptr) == 0 ) |
| 1253 | { |
| 1254 | /* msg not handled, then try here */ |
| 1255 | switch(msg) |
| 1256 | { |
| 1257 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1258 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st7565_dogm132_display_info); |
| 1259 | break; |
| 1260 | case U8X8_MSG_DISPLAY_INIT: |
| 1261 | u8x8_d_helper_display_init(u8x8); |
| 1262 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_dogm132_init_seq); |
| 1263 | break; |
| 1264 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1265 | if ( arg_int == 0 ) |
| 1266 | { |
| 1267 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip0_seq); |
| 1268 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1269 | } |
| 1270 | else |
| 1271 | { |
| 1272 | u8x8_cad_SendSequence(u8x8, u8x8_d_st7565_flip1_seq); |
| 1273 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1274 | } |
| 1275 | break; |
| 1276 | default: |
| 1277 | return 0; /* msg unknown */ |
| 1278 | } |
| 1279 | } |
| 1280 | return 1; |
| 1281 | } |