| 1 | /* |
| 2 | |
| 3 | u8x8_d_st75256.c |
| 4 | |
| 5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) |
| 6 | |
| 7 | Copyright (c) 2017, olikraus@gmail.com |
| 8 | All rights reserved. |
| 9 | |
| 10 | Redistribution and use in source and binary forms, with or without modification, |
| 11 | are permitted provided that the following conditions are met: |
| 12 | |
| 13 | * Redistributions of source code must retain the above copyright notice, this list |
| 14 | of conditions and the following disclaimer. |
| 15 | |
| 16 | * Redistributions in binary form must reproduce the above copyright notice, this |
| 17 | list of conditions and the following disclaimer in the documentation and/or other |
| 18 | materials provided with the distribution. |
| 19 | |
| 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
| 21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| 22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | |
| 34 | 0x030 ext 00 |
| 35 | 0x031 ext 01 |
| 36 | 0x038 ext 10 |
| 37 | 0x039 ext 11 |
| 38 | |
| 39 | cad 011 |
| 40 | |
| 41 | |
| 42 | code examples: |
| 43 | http://www.it610.com/article/2601023.htm |
| 44 | |
| 45 | normal mode: |
| 46 | 0x00c bit format |
| 47 | U8X8_CA( 0xbc, 0x00 ), data scan dir |
| 48 | U8X8_A( 0xa6 ), |
| 49 | y: 0 offset |
| 50 | |
| 51 | flip mode: |
| 52 | 0x008 bit format |
| 53 | U8X8_CA( 0xbc, 0x03 ), data scan dir |
| 54 | U8X8_A( 0xa6 ), |
| 55 | y: 5 offset |
| 56 | |
| 57 | |
| 58 | */ |
| 59 | |
| 60 | |
| 61 | #include "u8x8.h" |
| 62 | |
| 63 | |
| 64 | /* not a real power down for the st75256... just a display off */ |
| 65 | static const uint8_t u8x8_d_st75256_256x128_powersave0_seq[] = { |
| 66 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 67 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 68 | U8X8_C( 0x94 ), /* sleep out */ |
| 69 | U8X8_DLY(10), |
| 70 | U8X8_C( 0xaf ), /* display on */ |
| 71 | U8X8_END_TRANSFER(), /* disable chip */ |
| 72 | U8X8_END() /* end of sequence */ |
| 73 | }; |
| 74 | |
| 75 | static const uint8_t u8x8_d_st75256_256x128_powersave1_seq[] = { |
| 76 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 77 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 78 | U8X8_C( 0xae ), /* display off */ |
| 79 | U8X8_C( 0x95 ), /* sleep in */ |
| 80 | U8X8_END_TRANSFER(), /* disable chip */ |
| 81 | U8X8_END() /* end of sequence */ |
| 82 | }; |
| 83 | |
| 84 | static const uint8_t u8x8_d_st75256_jlx256128_flip0_seq[] = { |
| 85 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 86 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 87 | U8X8_CA( 0xbc, 0x00 ), /* data scan dir */ |
| 88 | U8X8_A( 0xa6 ), /* ??? */ |
| 89 | |
| 90 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 91 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 92 | U8X8_END_TRANSFER(), /* disable chip */ |
| 93 | U8X8_END() /* end of sequence */ |
| 94 | }; |
| 95 | |
| 96 | static const uint8_t u8x8_d_st75256_jlx256128_flip1_seq[] = { |
| 97 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 98 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 99 | U8X8_CA( 0xbc, 0x03 ), /* data scan dir */ |
| 100 | U8X8_A( 0xa6 ), /* ??? */ |
| 101 | |
| 102 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 103 | U8X8_C( 0x008 ), /* data format MSB top */ |
| 104 | U8X8_END_TRANSFER(), /* disable chip */ |
| 105 | U8X8_END() /* end of sequence */ |
| 106 | }; |
| 107 | |
| 108 | static const uint8_t u8x8_d_st75256_jlx172104_flip0_seq[] = { |
| 109 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 110 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 111 | U8X8_CA( 0xbc, 0x02 ), /* data scan dir */ |
| 112 | U8X8_A( 0xa6 ), /* ??? */ |
| 113 | |
| 114 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 115 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 116 | U8X8_END_TRANSFER(), /* disable chip */ |
| 117 | U8X8_END() /* end of sequence */ |
| 118 | }; |
| 119 | |
| 120 | static const uint8_t u8x8_d_st75256_jlx172104_flip1_seq[] = { |
| 121 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 122 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 123 | U8X8_CA( 0xbc, 0x01 ), /* data scan dir */ |
| 124 | U8X8_A( 0xa6 ), /* ??? */ |
| 125 | |
| 126 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 127 | U8X8_C( 0x008 ), /* data format MSB top */ |
| 128 | U8X8_END_TRANSFER(), /* disable chip */ |
| 129 | U8X8_END() /* end of sequence */ |
| 130 | }; |
| 131 | |
| 132 | static const uint8_t u8x8_d_st75256_jlx256160_flip0_seq[] = { |
| 133 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 134 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 135 | U8X8_CA( 0xbc, 0x00 ), /* data scan dir */ |
| 136 | U8X8_A( 0xa6 ), /* ??? */ |
| 137 | |
| 138 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 139 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 140 | U8X8_END_TRANSFER(), /* disable chip */ |
| 141 | U8X8_END() /* end of sequence */ |
| 142 | }; |
| 143 | |
| 144 | static const uint8_t u8x8_d_st75256_jlx256160_flip1_seq[] = { |
| 145 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 146 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 147 | U8X8_CA( 0xbc, 0x03 ), /* data scan dir */ |
| 148 | U8X8_A( 0xa6 ), /* ??? */ |
| 149 | |
| 150 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 151 | U8X8_C( 0x008 ), /* data format MSB top */ |
| 152 | U8X8_END_TRANSFER(), /* disable chip */ |
| 153 | U8X8_END() /* end of sequence */ |
| 154 | }; |
| 155 | |
| 156 | |
| 157 | static uint8_t u8x8_d_st75256_256x128_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 158 | { |
| 159 | uint8_t x, c; |
| 160 | uint8_t *ptr; |
| 161 | switch(msg) |
| 162 | { |
| 163 | /* handled by the calling function |
| 164 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 165 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_256x128_display_info); |
| 166 | break; |
| 167 | */ |
| 168 | /* handled by the calling function |
| 169 | case U8X8_MSG_DISPLAY_INIT: |
| 170 | u8x8_d_helper_display_init(u8x8); |
| 171 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_init_seq); |
| 172 | break; |
| 173 | */ |
| 174 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 175 | if ( arg_int == 0 ) |
| 176 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 177 | else |
| 178 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 179 | |
| 180 | break; |
| 181 | #ifdef U8X8_WITH_SET_CONTRAST |
| 182 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 183 | |
| 184 | u8x8_cad_StartTransfer(u8x8); |
| 185 | |
| 186 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 187 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 188 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 189 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 190 | |
| 191 | u8x8_cad_EndTransfer(u8x8); |
| 192 | break; |
| 193 | #endif |
| 194 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 195 | |
| 196 | u8x8_cad_StartTransfer(u8x8); |
| 197 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 198 | x *= 8; |
| 199 | |
| 200 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 201 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 202 | u8x8_cad_SendArg(u8x8, u8x8->x_offset + (((u8x8_tile_t *)arg_ptr)->y_pos)); /* x offset is used as y offset */ |
| 203 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 204 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 205 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 206 | u8x8_cad_SendArg(u8x8, x); |
| 207 | u8x8_cad_SendArg(u8x8, 255); |
| 208 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 209 | |
| 210 | do |
| 211 | { |
| 212 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 213 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 214 | /* SendData can not handle more than 255 bytes, treat c > 31 correctly */ |
| 215 | if ( c > 31 ) |
| 216 | { |
| 217 | u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */ |
| 218 | ptr+=248; |
| 219 | c -= 31; |
| 220 | } |
| 221 | |
| 222 | u8x8_cad_SendData(u8x8, c*8, ptr); |
| 223 | arg_int--; |
| 224 | } while( arg_int > 0 ); |
| 225 | |
| 226 | u8x8_cad_EndTransfer(u8x8); |
| 227 | break; |
| 228 | default: |
| 229 | return 0; |
| 230 | } |
| 231 | return 1; |
| 232 | } |
| 233 | |
| 234 | /*=============================================*/ |
| 235 | /* JLX256128 */ |
| 236 | |
| 237 | static const u8x8_display_info_t u8x8_st75256_256x128_display_info = |
| 238 | { |
| 239 | /* chip_enable_level = */ 0, |
| 240 | /* chip_disable_level = */ 1, |
| 241 | |
| 242 | /* post_chip_enable_wait_ns = */ 20, |
| 243 | /* pre_chip_disable_wait_ns = */ 20, |
| 244 | /* reset_pulse_width_ms = */ 5, |
| 245 | /* post_reset_wait_ms = */ 5, /**/ |
| 246 | /* sda_setup_time_ns = */ 20, /* */ |
| 247 | /* sck_pulse_width_ns = */ 40, /* */ |
| 248 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 249 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 250 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 251 | /* data_setup_time_ns = */ 15, |
| 252 | /* write_pulse_width_ns = */ 70, |
| 253 | /* tile_width = */ 32, |
| 254 | /* tile_height = */ 16, |
| 255 | /* default_x_offset = */ 0, /* must be 0, because this is checked also for normal mode */ |
| 256 | /* flipmode_x_offset = */ 5, /* used as y offset */ |
| 257 | /* pixel_width = */ 256, |
| 258 | /* pixel_height = */ 128 |
| 259 | }; |
| 260 | |
| 261 | |
| 262 | static const uint8_t u8x8_d_st75256_256x128_init_seq[] = { |
| 263 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 264 | |
| 265 | U8X8_DLY(20), |
| 266 | |
| 267 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 268 | U8X8_C( 0x094 ), /* sleep out */ |
| 269 | |
| 270 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 271 | U8X8_C( 0x0ae ), /* display off */ |
| 272 | |
| 273 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 274 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 275 | |
| 276 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 277 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 278 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 279 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 280 | U8X8_A( 0x000 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 281 | |
| 282 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 283 | U8X8_C( 0x020 ), /* gray levels */ |
| 284 | U8X8_A( 0x01 ), |
| 285 | U8X8_A( 0x03 ), |
| 286 | U8X8_A( 0x05 ), |
| 287 | U8X8_A( 0x07 ), |
| 288 | U8X8_A( 0x09), |
| 289 | U8X8_A( 0x0b ), |
| 290 | U8X8_A( 0x0d ), |
| 291 | U8X8_A( 0x10 ), |
| 292 | U8X8_A( 0x11 ), |
| 293 | U8X8_A( 0x13 ), |
| 294 | U8X8_A( 0x15 ), |
| 295 | U8X8_A( 0x17 ), |
| 296 | U8X8_A( 0x19 ), |
| 297 | U8X8_A( 0x1b ), |
| 298 | U8X8_A( 0x1d ), |
| 299 | U8X8_A( 0x1f ), |
| 300 | |
| 301 | |
| 302 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 303 | U8X8_CAA(0x75, 0, 0x4f), /* row range */ |
| 304 | U8X8_CAA(0x15, 0, 255), /* col range */ |
| 305 | |
| 306 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 307 | U8X8_CA( 0xbc, 0x00 ), /* data scan dir */ |
| 308 | U8X8_A( 0xa6 ), /* ??? */ |
| 309 | |
| 310 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 311 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 312 | |
| 313 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 314 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 315 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 316 | U8X8_A( 0x7f ), /* 1/160 duty value from the DS example code */ |
| 317 | U8X8_A( 0x20 ), /* nline off */ |
| 318 | |
| 319 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 320 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 321 | |
| 322 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 323 | U8X8_CAA( 0x81, 0x36, 0x05 ), /* Volume control */ |
| 324 | |
| 325 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 326 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 327 | U8X8_DLY(100), |
| 328 | |
| 329 | U8X8_END_TRANSFER(), /* disable chip */ |
| 330 | U8X8_END() /* end of sequence */ |
| 331 | }; |
| 332 | |
| 333 | |
| 334 | uint8_t u8x8_d_st75256_jlx256128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 335 | { |
| 336 | if ( u8x8_d_st75256_256x128_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
| 337 | return 1; |
| 338 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY ) |
| 339 | { |
| 340 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 341 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_256x128_display_info); |
| 342 | return 1; |
| 343 | } |
| 344 | else if ( msg == U8X8_MSG_DISPLAY_INIT ) |
| 345 | { |
| 346 | u8x8_d_helper_display_init(u8x8); |
| 347 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_init_seq); |
| 348 | return 1; |
| 349 | } |
| 350 | else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE ) |
| 351 | { |
| 352 | if ( arg_int == 0 ) |
| 353 | { |
| 354 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256128_flip0_seq); |
| 355 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 356 | } |
| 357 | else |
| 358 | { |
| 359 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256128_flip1_seq); |
| 360 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 361 | } |
| 362 | return 1; |
| 363 | } |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | |
| 368 | |
| 369 | /*=============================================*/ |
| 370 | /* WO256X128, https://github.com/olikraus/u8g2/issues/891 */ |
| 371 | |
| 372 | static const u8x8_display_info_t u8x8_st75256_wo256x128_display_info = |
| 373 | { |
| 374 | /* chip_enable_level = */ 0, |
| 375 | /* chip_disable_level = */ 1, |
| 376 | |
| 377 | /* post_chip_enable_wait_ns = */ 20, |
| 378 | /* pre_chip_disable_wait_ns = */ 20, |
| 379 | /* reset_pulse_width_ms = */ 5, |
| 380 | /* post_reset_wait_ms = */ 5, /**/ |
| 381 | /* sda_setup_time_ns = */ 20, /* */ |
| 382 | /* sck_pulse_width_ns = */ 40, /* */ |
| 383 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 384 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 385 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 386 | /* data_setup_time_ns = */ 15, |
| 387 | /* write_pulse_width_ns = */ 70, |
| 388 | /* tile_width = */ 32, |
| 389 | /* tile_height = */ 16, |
| 390 | /* default_x_offset = */ 5, /* must be 0, because this is checked also for normal mode */ |
| 391 | /* flipmode_x_offset = */ 0, /* used as y offset */ |
| 392 | /* pixel_width = */ 256, |
| 393 | /* pixel_height = */ 128 |
| 394 | }; |
| 395 | |
| 396 | |
| 397 | static const uint8_t u8x8_d_st75256_wo256x128_init_seq[] = { |
| 398 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 399 | |
| 400 | U8X8_DLY(20), |
| 401 | |
| 402 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 403 | U8X8_C( 0x094 ), /* sleep out */ |
| 404 | |
| 405 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 406 | U8X8_C( 0x0ae ), /* display off */ |
| 407 | |
| 408 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 409 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 410 | |
| 411 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 412 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 413 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 414 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 415 | U8X8_A( 0x000 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 416 | |
| 417 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 418 | U8X8_C( 0x020 ), /* gray levels */ |
| 419 | U8X8_A( 0x01 ), |
| 420 | U8X8_A( 0x03 ), |
| 421 | U8X8_A( 0x05 ), |
| 422 | U8X8_A( 0x07 ), |
| 423 | U8X8_A( 0x09), |
| 424 | U8X8_A( 0x0b ), |
| 425 | U8X8_A( 0x0d ), |
| 426 | U8X8_A( 0x10 ), |
| 427 | U8X8_A( 0x11 ), |
| 428 | U8X8_A( 0x13 ), |
| 429 | U8X8_A( 0x15 ), |
| 430 | U8X8_A( 0x17 ), |
| 431 | U8X8_A( 0x19 ), |
| 432 | U8X8_A( 0x1b ), |
| 433 | U8X8_A( 0x1d ), |
| 434 | U8X8_A( 0x1f ), |
| 435 | |
| 436 | |
| 437 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 438 | U8X8_CAA(0x75, 0, 0x4f), /* row range */ |
| 439 | U8X8_CAA(0x15, 0, 255), /* col range */ |
| 440 | |
| 441 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 442 | U8X8_CA( 0xbc, 0x01 ), /* data scan dir */ |
| 443 | U8X8_A( 0xa6 ), /* ??? */ |
| 444 | |
| 445 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 446 | U8X8_C( 0x008 ), /* data format LSB top */ |
| 447 | |
| 448 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 449 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 450 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 451 | U8X8_A( 0x7f ), /* 1/160 duty value from the DS example code */ |
| 452 | U8X8_A( 0x20 ), /* nline off */ |
| 453 | |
| 454 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 455 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 456 | |
| 457 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 458 | U8X8_CAA( 0x81, 0x36, 0x05 ), /* Volume control */ |
| 459 | |
| 460 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 461 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 462 | U8X8_DLY(100), |
| 463 | |
| 464 | U8X8_END_TRANSFER(), /* disable chip */ |
| 465 | U8X8_END() /* end of sequence */ |
| 466 | }; |
| 467 | |
| 468 | |
| 469 | uint8_t u8x8_d_st75256_wo256x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 470 | { |
| 471 | if ( u8x8_d_st75256_256x128_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
| 472 | return 1; |
| 473 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY ) |
| 474 | { |
| 475 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 476 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_wo256x128_display_info); |
| 477 | return 1; |
| 478 | } |
| 479 | else if ( msg == U8X8_MSG_DISPLAY_INIT ) |
| 480 | { |
| 481 | u8x8_d_helper_display_init(u8x8); |
| 482 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_wo256x128_init_seq); |
| 483 | return 1; |
| 484 | } |
| 485 | else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE ) |
| 486 | { |
| 487 | if ( arg_int == 0 ) |
| 488 | { |
| 489 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq); // this matches the init sequence |
| 490 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 491 | } |
| 492 | else |
| 493 | { |
| 494 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq); |
| 495 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 496 | } |
| 497 | return 1; |
| 498 | } |
| 499 | return 0; |
| 500 | } |
| 501 | |
| 502 | |
| 503 | /*=============================================*/ |
| 504 | /* JLX25664 */ |
| 505 | |
| 506 | static const u8x8_display_info_t u8x8_st75256_256x64_display_info = |
| 507 | { |
| 508 | /* chip_enable_level = */ 0, |
| 509 | /* chip_disable_level = */ 1, |
| 510 | |
| 511 | /* post_chip_enable_wait_ns = */ 20, |
| 512 | /* pre_chip_disable_wait_ns = */ 20, |
| 513 | /* reset_pulse_width_ms = */ 5, |
| 514 | /* post_reset_wait_ms = */ 5, /**/ |
| 515 | /* sda_setup_time_ns = */ 20, /* */ |
| 516 | /* sck_pulse_width_ns = */ 40, /* */ |
| 517 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 518 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 519 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 520 | /* data_setup_time_ns = */ 15, |
| 521 | /* write_pulse_width_ns = */ 70, |
| 522 | /* tile_width = */ 32, |
| 523 | /* tile_height = */ 8, |
| 524 | /* default_x_offset = */ 0, /* must be 0, because this is checked also for normal mode */ |
| 525 | /* flipmode_x_offset = */ 13, /* used as y offset */ |
| 526 | /* pixel_width = */ 256, |
| 527 | /* pixel_height = */ 64 |
| 528 | }; |
| 529 | |
| 530 | |
| 531 | static const uint8_t u8x8_d_st75256_256x64_init_seq[] = { |
| 532 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 533 | |
| 534 | U8X8_DLY(20), |
| 535 | |
| 536 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 537 | U8X8_C( 0x094 ), /* sleep out */ |
| 538 | |
| 539 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 540 | U8X8_C( 0x0ae ), /* display off */ |
| 541 | |
| 542 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 543 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 544 | |
| 545 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 546 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 547 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 548 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 549 | U8X8_A( 0x005 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 550 | |
| 551 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 552 | U8X8_C( 0x020 ), /* gray levels */ |
| 553 | U8X8_A( 0x01 ), |
| 554 | U8X8_A( 0x03 ), |
| 555 | U8X8_A( 0x05 ), |
| 556 | U8X8_A( 0x07 ), |
| 557 | U8X8_A( 0x09), |
| 558 | U8X8_A( 0x0b ), |
| 559 | U8X8_A( 0x0d ), |
| 560 | U8X8_A( 0x10 ), |
| 561 | U8X8_A( 0x11 ), |
| 562 | U8X8_A( 0x13 ), |
| 563 | U8X8_A( 0x15 ), |
| 564 | U8X8_A( 0x17 ), |
| 565 | U8X8_A( 0x19 ), |
| 566 | U8X8_A( 0x1b ), |
| 567 | U8X8_A( 0x1d ), |
| 568 | U8X8_A( 0x1f ), |
| 569 | |
| 570 | |
| 571 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 572 | U8X8_CAA(0x75, 0, 0x1f), /* row range */ |
| 573 | U8X8_CAA(0x15, 0, 255), /* col range */ |
| 574 | |
| 575 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 576 | U8X8_CA( 0xbc, 0x00 ), /* data scan dir */ |
| 577 | U8X8_A( 0xa6 ), /* ??? */ |
| 578 | |
| 579 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 580 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 581 | |
| 582 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 583 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 584 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 585 | U8X8_A( 0x3f ), /* 64 duty value from the DS example code */ |
| 586 | U8X8_A( 0x20 ), /* nline off */ |
| 587 | |
| 588 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 589 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 590 | |
| 591 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 592 | U8X8_CAA( 0x81, 012, 0x02 ), /* Volume control */ |
| 593 | |
| 594 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 595 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 596 | U8X8_DLY(100), |
| 597 | |
| 598 | U8X8_END_TRANSFER(), /* disable chip */ |
| 599 | U8X8_END() /* end of sequence */ |
| 600 | }; |
| 601 | |
| 602 | |
| 603 | uint8_t u8x8_d_st75256_jlx25664(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 604 | { |
| 605 | if ( u8x8_d_st75256_256x128_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
| 606 | return 1; |
| 607 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY ) |
| 608 | { |
| 609 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 610 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_256x64_display_info); |
| 611 | return 1; |
| 612 | } |
| 613 | else if ( msg == U8X8_MSG_DISPLAY_INIT ) |
| 614 | { |
| 615 | u8x8_d_helper_display_init(u8x8); |
| 616 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x64_init_seq); |
| 617 | return 1; |
| 618 | } |
| 619 | else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE ) |
| 620 | { |
| 621 | if ( arg_int == 0 ) |
| 622 | { |
| 623 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256128_flip0_seq); |
| 624 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 625 | } |
| 626 | else |
| 627 | { |
| 628 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256128_flip1_seq); |
| 629 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 630 | } |
| 631 | return 1; |
| 632 | } |
| 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | |
| 637 | /*=============================================*/ |
| 638 | /* JLX172104 LCD */ |
| 639 | |
| 640 | static const u8x8_display_info_t u8x8_st75256_172x104_display_info = |
| 641 | { |
| 642 | /* chip_enable_level = */ 0, |
| 643 | /* chip_disable_level = */ 1, |
| 644 | |
| 645 | /* post_chip_enable_wait_ns = */ 20, |
| 646 | /* pre_chip_disable_wait_ns = */ 20, |
| 647 | /* reset_pulse_width_ms = */ 5, |
| 648 | /* post_reset_wait_ms = */ 5, /**/ |
| 649 | /* sda_setup_time_ns = */ 20, /* */ |
| 650 | /* sck_pulse_width_ns = */ 40, /* */ |
| 651 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 652 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 653 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 654 | /* data_setup_time_ns = */ 15, |
| 655 | /* write_pulse_width_ns = */ 70, |
| 656 | /* tile_width = */ 22, /* 22=176 */ |
| 657 | /* tile_height = */ 13, |
| 658 | /* default_x_offset = */ 84, /* */ |
| 659 | /* flipmode_x_offset = */ 0, |
| 660 | /* pixel_width = */ 172, |
| 661 | /* pixel_height = */ 104 |
| 662 | }; |
| 663 | |
| 664 | static const uint8_t u8x8_d_st75256_jlx172104_init_seq[] = { |
| 665 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 666 | |
| 667 | U8X8_DLY(20), |
| 668 | |
| 669 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 670 | U8X8_C( 0x094 ), /* sleep out */ |
| 671 | |
| 672 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 673 | U8X8_C( 0x0ae ), /* display off */ |
| 674 | |
| 675 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 676 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 677 | |
| 678 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 679 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 680 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 681 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 682 | U8X8_A( 0x003 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 683 | |
| 684 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 685 | U8X8_C( 0x020 ), /* gray levels */ |
| 686 | U8X8_A( 0x01 ), |
| 687 | U8X8_A( 0x03 ), |
| 688 | U8X8_A( 0x05 ), |
| 689 | U8X8_A( 0x07 ), |
| 690 | U8X8_A( 0x09), |
| 691 | U8X8_A( 0x0b ), |
| 692 | U8X8_A( 0x0d ), |
| 693 | U8X8_A( 0x10 ), |
| 694 | U8X8_A( 0x11 ), |
| 695 | U8X8_A( 0x13 ), |
| 696 | U8X8_A( 0x15 ), |
| 697 | U8X8_A( 0x17 ), |
| 698 | U8X8_A( 0x19 ), |
| 699 | U8X8_A( 0x1b ), |
| 700 | U8X8_A( 0x1d ), |
| 701 | U8X8_A( 0x1f ), |
| 702 | |
| 703 | |
| 704 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 705 | U8X8_CAA(0x75, 0, 0x4f), /* row range */ |
| 706 | U8X8_CAA(0x15, 0, 255), /* col range */ |
| 707 | |
| 708 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 709 | U8X8_CA( 0xbc, 0x02 ), /* data scan dir */ |
| 710 | U8X8_A( 0xa6 ), /* ??? */ |
| 711 | |
| 712 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 713 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 714 | |
| 715 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 716 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 717 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 718 | U8X8_A( 0x9f ), /* 1/160 duty value from the DS example code */ |
| 719 | U8X8_A( 0x20 ), /* nline off */ |
| 720 | |
| 721 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 722 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 723 | |
| 724 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 725 | U8X8_CAA( 0x81, 0x08, 0x04 ), /* Volume control */ |
| 726 | |
| 727 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 728 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 729 | U8X8_DLY(100), |
| 730 | |
| 731 | U8X8_END_TRANSFER(), /* disable chip */ |
| 732 | U8X8_END() /* end of sequence */ |
| 733 | }; |
| 734 | |
| 735 | |
| 736 | uint8_t u8x8_d_st75256_jlx172104(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 737 | { |
| 738 | uint8_t x, c; |
| 739 | uint8_t *ptr; |
| 740 | |
| 741 | switch(msg) |
| 742 | { |
| 743 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 744 | |
| 745 | u8x8_cad_StartTransfer(u8x8); |
| 746 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 747 | x *= 8; |
| 748 | |
| 749 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 750 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 751 | if ( u8x8->x_offset == 0 ) /* 0 means flip mode 1, then adjust y value */ |
| 752 | u8x8_cad_SendArg(u8x8, 8+(((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 753 | else |
| 754 | u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 755 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 756 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 757 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 758 | u8x8_cad_SendArg(u8x8, x+u8x8->x_offset); |
| 759 | u8x8_cad_SendArg(u8x8, 255); |
| 760 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 761 | |
| 762 | |
| 763 | /* this procedure assumes, that the overall width is 172 */ |
| 764 | do |
| 765 | { |
| 766 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 767 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 768 | c *= 8; |
| 769 | |
| 770 | if ( c + x > 172u ) |
| 771 | { |
| 772 | c = 172u; |
| 773 | c -= x; |
| 774 | } |
| 775 | |
| 776 | u8x8_cad_SendData(u8x8, c, ptr); |
| 777 | x += c; |
| 778 | arg_int--; |
| 779 | } while( arg_int > 0 ); |
| 780 | |
| 781 | u8x8_cad_EndTransfer(u8x8); |
| 782 | return 1; |
| 783 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 784 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 785 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_172x104_display_info); |
| 786 | return 1; |
| 787 | case U8X8_MSG_DISPLAY_INIT: |
| 788 | u8x8_d_helper_display_init(u8x8); |
| 789 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_init_seq); |
| 790 | return 1; |
| 791 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 792 | if ( arg_int == 0 ) |
| 793 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 794 | else |
| 795 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 796 | |
| 797 | return 1; |
| 798 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 799 | if ( arg_int == 0 ) |
| 800 | { |
| 801 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq); |
| 802 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 803 | } |
| 804 | else |
| 805 | { |
| 806 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq); |
| 807 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 808 | } |
| 809 | return 1; |
| 810 | |
| 811 | #ifdef U8X8_WITH_SET_CONTRAST |
| 812 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 813 | |
| 814 | u8x8_cad_StartTransfer(u8x8); |
| 815 | |
| 816 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 817 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 818 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 819 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 820 | |
| 821 | u8x8_cad_EndTransfer(u8x8); |
| 822 | return 1; |
| 823 | #endif |
| 824 | } |
| 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | /*=============================================*/ |
| 829 | /* JLX240160 */ |
| 830 | |
| 831 | static const u8x8_display_info_t u8x8_st75256_240x160_display_info = |
| 832 | { |
| 833 | /* chip_enable_level = */ 0, |
| 834 | /* chip_disable_level = */ 1, |
| 835 | |
| 836 | /* post_chip_enable_wait_ns = */ 20, |
| 837 | /* pre_chip_disable_wait_ns = */ 20, |
| 838 | /* reset_pulse_width_ms = */ 5, |
| 839 | /* post_reset_wait_ms = */ 5, /**/ |
| 840 | /* sda_setup_time_ns = */ 20, /* */ |
| 841 | /* sck_pulse_width_ns = */ 40, /* */ |
| 842 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 843 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 844 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 845 | /* data_setup_time_ns = */ 15, |
| 846 | /* write_pulse_width_ns = */ 70, |
| 847 | /* tile_width = */ 30, |
| 848 | /* tile_height = */ 20, |
| 849 | /* default_x_offset = */ 16, /* x offset in flipmode 0 */ |
| 850 | /* flipmode_x_offset = */ 0, /* */ |
| 851 | /* pixel_width = */ 240, |
| 852 | /* pixel_height = */ 160 |
| 853 | }; |
| 854 | |
| 855 | |
| 856 | static const uint8_t u8x8_d_st75256_240x160_init_seq[] = { |
| 857 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 858 | |
| 859 | U8X8_DLY(20), |
| 860 | |
| 861 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 862 | U8X8_C( 0x094 ), /* sleep out */ |
| 863 | |
| 864 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 865 | U8X8_C( 0x0ae ), /* display off */ |
| 866 | |
| 867 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 868 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 869 | |
| 870 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 871 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 872 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 873 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 874 | U8X8_A( 0x000 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 875 | |
| 876 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 877 | U8X8_C( 0x020 ), /* gray levels */ |
| 878 | U8X8_A( 0x01 ), |
| 879 | U8X8_A( 0x03 ), |
| 880 | U8X8_A( 0x05 ), |
| 881 | U8X8_A( 0x07 ), |
| 882 | U8X8_A( 0x09), |
| 883 | U8X8_A( 0x0b ), |
| 884 | U8X8_A( 0x0d ), |
| 885 | U8X8_A( 0x10 ), |
| 886 | U8X8_A( 0x11 ), |
| 887 | U8X8_A( 0x13 ), |
| 888 | U8X8_A( 0x15 ), |
| 889 | U8X8_A( 0x17 ), |
| 890 | U8X8_A( 0x19 ), |
| 891 | U8X8_A( 0x1b ), |
| 892 | U8X8_A( 0x1d ), |
| 893 | U8X8_A( 0x1f ), |
| 894 | |
| 895 | |
| 896 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 897 | U8X8_CAA(0x75, 0, 0x4f), /* row range */ |
| 898 | U8X8_CAA(0x15, 0, 239), /* col range */ |
| 899 | |
| 900 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 901 | U8X8_CA( 0xbc, 0x02 ), /* data scan dir */ |
| 902 | U8X8_A( 0xa6 ), /* ??? */ |
| 903 | |
| 904 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 905 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 906 | |
| 907 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 908 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 909 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 910 | U8X8_A( 159 ), /* 1/160 duty value from the DS example code */ |
| 911 | U8X8_A( 0x20 ), /* nline off */ |
| 912 | |
| 913 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 914 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 915 | |
| 916 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 917 | U8X8_CAA( 0x81, 0x18, 0x04 ), /* Volume control */ |
| 918 | |
| 919 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 920 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 921 | U8X8_DLY(100), |
| 922 | |
| 923 | U8X8_END_TRANSFER(), /* disable chip */ |
| 924 | U8X8_END() /* end of sequence */ |
| 925 | }; |
| 926 | |
| 927 | |
| 928 | uint8_t u8x8_d_st75256_jlx240160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 929 | { |
| 930 | uint8_t x, c; |
| 931 | uint8_t *ptr; |
| 932 | |
| 933 | switch(msg) |
| 934 | { |
| 935 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 936 | |
| 937 | u8x8_cad_StartTransfer(u8x8); |
| 938 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 939 | x *= 8; |
| 940 | |
| 941 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 942 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 943 | if ( u8x8->x_offset == 0 ) /* 0 means flip mode 1 */ |
| 944 | u8x8_cad_SendArg(u8x8, 1+(((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 945 | else |
| 946 | u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 947 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 948 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 949 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 950 | u8x8_cad_SendArg(u8x8, x+u8x8->x_offset); |
| 951 | u8x8_cad_SendArg(u8x8, 255); |
| 952 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 953 | |
| 954 | |
| 955 | do |
| 956 | { |
| 957 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 958 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 959 | c *= 8; |
| 960 | |
| 961 | if ( c + x > 240u ) |
| 962 | { |
| 963 | c = 240u; |
| 964 | c -= x; |
| 965 | } |
| 966 | |
| 967 | u8x8_cad_SendData(u8x8, c, ptr); |
| 968 | x += c; |
| 969 | arg_int--; |
| 970 | } while( arg_int > 0 ); |
| 971 | |
| 972 | u8x8_cad_EndTransfer(u8x8); |
| 973 | return 1; |
| 974 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 975 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 976 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_240x160_display_info); |
| 977 | return 1; |
| 978 | case U8X8_MSG_DISPLAY_INIT: |
| 979 | u8x8_d_helper_display_init(u8x8); |
| 980 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_240x160_init_seq); |
| 981 | return 1; |
| 982 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 983 | if ( arg_int == 0 ) |
| 984 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 985 | else |
| 986 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 987 | |
| 988 | return 1; |
| 989 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 990 | if ( arg_int == 0 ) |
| 991 | { |
| 992 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq); |
| 993 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 994 | } |
| 995 | else |
| 996 | { |
| 997 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq); |
| 998 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 999 | } |
| 1000 | return 1; |
| 1001 | |
| 1002 | #ifdef U8X8_WITH_SET_CONTRAST |
| 1003 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 1004 | |
| 1005 | u8x8_cad_StartTransfer(u8x8); |
| 1006 | |
| 1007 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 1008 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 1009 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 1010 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 1011 | |
| 1012 | u8x8_cad_EndTransfer(u8x8); |
| 1013 | return 1; |
| 1014 | #endif |
| 1015 | } |
| 1016 | return 0; |
| 1017 | |
| 1018 | |
| 1019 | |
| 1020 | } |
| 1021 | |
| 1022 | |
| 1023 | /*=============================================*/ |
| 1024 | /* JLX256160 */ |
| 1025 | |
| 1026 | static const u8x8_display_info_t u8x8_st75256_256x160_display_info = |
| 1027 | { |
| 1028 | /* chip_enable_level = */ 0, |
| 1029 | /* chip_disable_level = */ 1, |
| 1030 | |
| 1031 | /* post_chip_enable_wait_ns = */ 20, |
| 1032 | /* pre_chip_disable_wait_ns = */ 20, |
| 1033 | /* reset_pulse_width_ms = */ 5, |
| 1034 | /* post_reset_wait_ms = */ 5, /**/ |
| 1035 | /* sda_setup_time_ns = */ 20, /* */ |
| 1036 | /* sck_pulse_width_ns = */ 40, /* */ |
| 1037 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 1038 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 1039 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 1040 | /* data_setup_time_ns = */ 15, |
| 1041 | /* write_pulse_width_ns = */ 70, |
| 1042 | /* tile_width = */ 32, |
| 1043 | /* tile_height = */ 20, |
| 1044 | /* default_x_offset = */ 0, |
| 1045 | /* flipmode_x_offset = */ 1, /* x offset is used as y offset in flipmode */ |
| 1046 | /* pixel_width = */ 256, |
| 1047 | /* pixel_height = */ 160 |
| 1048 | }; |
| 1049 | |
| 1050 | |
| 1051 | static const uint8_t u8x8_d_st75256_256x160_init_seq[] = { |
| 1052 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1053 | |
| 1054 | U8X8_DLY(20), |
| 1055 | |
| 1056 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1057 | U8X8_C( 0x094 ), /* sleep out */ |
| 1058 | |
| 1059 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1060 | U8X8_C( 0x0ae ), /* display off */ |
| 1061 | |
| 1062 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 1063 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 1064 | |
| 1065 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1066 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 1067 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 1068 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 1069 | U8X8_A( 0x000 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 1070 | |
| 1071 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1072 | U8X8_C( 0x020 ), /* gray levels */ |
| 1073 | U8X8_A( 0x01 ), |
| 1074 | U8X8_A( 0x03 ), |
| 1075 | U8X8_A( 0x05 ), |
| 1076 | U8X8_A( 0x07 ), |
| 1077 | U8X8_A( 0x09), |
| 1078 | U8X8_A( 0x0b ), |
| 1079 | U8X8_A( 0x0d ), |
| 1080 | U8X8_A( 0x10 ), |
| 1081 | U8X8_A( 0x11 ), |
| 1082 | U8X8_A( 0x13 ), |
| 1083 | U8X8_A( 0x15 ), |
| 1084 | U8X8_A( 0x17 ), |
| 1085 | U8X8_A( 0x19 ), |
| 1086 | U8X8_A( 0x1b ), |
| 1087 | U8X8_A( 0x1d ), |
| 1088 | U8X8_A( 0x1f ), |
| 1089 | |
| 1090 | |
| 1091 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1092 | U8X8_CAA(0x75, 0, 0x28), /* row range */ |
| 1093 | U8X8_CAA(0x15, 0, 0xFF), /* col range */ |
| 1094 | |
| 1095 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1096 | U8X8_CA( 0xbc, 0x00 ), /* data scan dir */ |
| 1097 | U8X8_A( 0xa6 ), /* ??? */ |
| 1098 | |
| 1099 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1100 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 1101 | |
| 1102 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1103 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 1104 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 1105 | U8X8_A( 159 ), /* 1/160 duty value from the DS example code */ |
| 1106 | U8X8_A( 0x20 ), /* nline off */ |
| 1107 | |
| 1108 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1109 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 1110 | |
| 1111 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1112 | U8X8_CAA( 0x81, 0x18, 0x05 ), /* Volume control */ |
| 1113 | |
| 1114 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1115 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 1116 | U8X8_DLY(100), |
| 1117 | |
| 1118 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1119 | U8X8_END() /* end of sequence */ |
| 1120 | }; |
| 1121 | |
| 1122 | |
| 1123 | uint8_t u8x8_d_st75256_jlx256160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1124 | { |
| 1125 | uint8_t x, c; |
| 1126 | uint8_t *ptr; |
| 1127 | |
| 1128 | switch(msg) |
| 1129 | { |
| 1130 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 1131 | |
| 1132 | u8x8_cad_StartTransfer(u8x8); |
| 1133 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 1134 | x *= 8; |
| 1135 | |
| 1136 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 1137 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 1138 | if ( u8x8->x_offset == 1 ) /* 1 means flip mode 1 */ |
| 1139 | u8x8_cad_SendArg(u8x8, 1+(((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1140 | else |
| 1141 | u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1142 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 1143 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1144 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 1145 | u8x8_cad_SendArg(u8x8, x+u8x8->display_info->default_x_offset); |
| 1146 | u8x8_cad_SendArg(u8x8, 255); |
| 1147 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 1148 | |
| 1149 | |
| 1150 | do |
| 1151 | { |
| 1152 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 1153 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 1154 | /* SendData can not handle more than 255 bytes, treat c > 31 correctly */ |
| 1155 | if ( c > 31 ) |
| 1156 | { |
| 1157 | u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */ |
| 1158 | ptr+=248; |
| 1159 | c -= 31; |
| 1160 | } |
| 1161 | |
| 1162 | u8x8_cad_SendData(u8x8, c*8, ptr); |
| 1163 | arg_int--; |
| 1164 | } while( arg_int > 0 ); |
| 1165 | |
| 1166 | u8x8_cad_EndTransfer(u8x8); |
| 1167 | return 1; |
| 1168 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1169 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 1170 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_256x160_display_info); |
| 1171 | return 1; |
| 1172 | case U8X8_MSG_DISPLAY_INIT: |
| 1173 | u8x8_d_helper_display_init(u8x8); |
| 1174 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x160_init_seq); |
| 1175 | return 1; |
| 1176 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 1177 | if ( arg_int == 0 ) |
| 1178 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 1179 | else |
| 1180 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 1181 | |
| 1182 | return 1; |
| 1183 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1184 | if ( arg_int == 0 ) |
| 1185 | { |
| 1186 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256160_flip0_seq); |
| 1187 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1188 | } |
| 1189 | else |
| 1190 | { |
| 1191 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256160_flip1_seq); |
| 1192 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1193 | } |
| 1194 | return 1; |
| 1195 | |
| 1196 | #ifdef U8X8_WITH_SET_CONTRAST |
| 1197 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 1198 | |
| 1199 | u8x8_cad_StartTransfer(u8x8); |
| 1200 | |
| 1201 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 1202 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 1203 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 1204 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 1205 | |
| 1206 | u8x8_cad_EndTransfer(u8x8); |
| 1207 | return 1; |
| 1208 | #endif |
| 1209 | } |
| 1210 | return 0; |
| 1211 | } |
| 1212 | |
| 1213 | |
| 1214 | /*=============================================*/ |
| 1215 | /* JLX256160 mirror version #930 */ |
| 1216 | |
| 1217 | |
| 1218 | static const uint8_t u8x8_d_st75256_256x160m_init_seq[] = { |
| 1219 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1220 | |
| 1221 | U8X8_DLY(20), |
| 1222 | |
| 1223 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1224 | U8X8_C( 0x094 ), /* sleep out */ |
| 1225 | |
| 1226 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1227 | U8X8_C( 0x0ae ), /* display off */ |
| 1228 | |
| 1229 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 1230 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 1231 | |
| 1232 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1233 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 1234 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 1235 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 1236 | U8X8_A( 0x000 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 1237 | |
| 1238 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1239 | U8X8_C( 0x020 ), /* gray levels */ |
| 1240 | U8X8_A( 0x01 ), |
| 1241 | U8X8_A( 0x03 ), |
| 1242 | U8X8_A( 0x05 ), |
| 1243 | U8X8_A( 0x07 ), |
| 1244 | U8X8_A( 0x09), |
| 1245 | U8X8_A( 0x0b ), |
| 1246 | U8X8_A( 0x0d ), |
| 1247 | U8X8_A( 0x10 ), |
| 1248 | U8X8_A( 0x11 ), |
| 1249 | U8X8_A( 0x13 ), |
| 1250 | U8X8_A( 0x15 ), |
| 1251 | U8X8_A( 0x17 ), |
| 1252 | U8X8_A( 0x19 ), |
| 1253 | U8X8_A( 0x1b ), |
| 1254 | U8X8_A( 0x1d ), |
| 1255 | U8X8_A( 0x1f ), |
| 1256 | |
| 1257 | |
| 1258 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1259 | U8X8_CAA(0x75, 0, 0x28), /* row range */ |
| 1260 | U8X8_CAA(0x15, 0, 0xFF), /* col range */ |
| 1261 | |
| 1262 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1263 | U8X8_CA( 0xbc, 0x02 ), /* data scan dir ( CHANGED FOR MIRROR VERSION ) */ |
| 1264 | U8X8_A( 0xa6 ), /* ??? */ |
| 1265 | |
| 1266 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1267 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 1268 | |
| 1269 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1270 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 1271 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 1272 | U8X8_A( 159 ), /* 1/160 duty value from the DS example code */ |
| 1273 | U8X8_A( 0x20 ), /* nline off */ |
| 1274 | |
| 1275 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1276 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 1277 | |
| 1278 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1279 | U8X8_CAA( 0x81, 0x18, 0x05 ), /* Volume control */ |
| 1280 | |
| 1281 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1282 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 1283 | U8X8_DLY(100), |
| 1284 | |
| 1285 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1286 | U8X8_END() /* end of sequence */ |
| 1287 | }; |
| 1288 | |
| 1289 | uint8_t u8x8_d_st75256_jlx256160m(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1290 | { |
| 1291 | uint8_t x, c; |
| 1292 | uint8_t *ptr; |
| 1293 | |
| 1294 | switch(msg) |
| 1295 | { |
| 1296 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 1297 | |
| 1298 | u8x8_cad_StartTransfer(u8x8); |
| 1299 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 1300 | x *= 8; |
| 1301 | |
| 1302 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 1303 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 1304 | if ( u8x8->x_offset == 1 ) /* 1 means flip mode 1 */ |
| 1305 | u8x8_cad_SendArg(u8x8, 1+(((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1306 | else |
| 1307 | u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1308 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 1309 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1310 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 1311 | u8x8_cad_SendArg(u8x8, x+u8x8->display_info->default_x_offset); |
| 1312 | u8x8_cad_SendArg(u8x8, 255); |
| 1313 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 1314 | |
| 1315 | |
| 1316 | do |
| 1317 | { |
| 1318 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 1319 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 1320 | /* SendData can not handle more than 255 bytes, treat c > 31 correctly */ |
| 1321 | if ( c > 31 ) |
| 1322 | { |
| 1323 | u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */ |
| 1324 | ptr+=248; |
| 1325 | c -= 31; |
| 1326 | } |
| 1327 | |
| 1328 | u8x8_cad_SendData(u8x8, c*8, ptr); |
| 1329 | arg_int--; |
| 1330 | } while( arg_int > 0 ); |
| 1331 | |
| 1332 | u8x8_cad_EndTransfer(u8x8); |
| 1333 | return 1; |
| 1334 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1335 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 1336 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_256x160_display_info); |
| 1337 | return 1; |
| 1338 | case U8X8_MSG_DISPLAY_INIT: |
| 1339 | u8x8_d_helper_display_init(u8x8); |
| 1340 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x160m_init_seq); |
| 1341 | return 1; |
| 1342 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 1343 | if ( arg_int == 0 ) |
| 1344 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 1345 | else |
| 1346 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 1347 | |
| 1348 | return 1; |
| 1349 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1350 | if ( arg_int == 0 ) |
| 1351 | { |
| 1352 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq); |
| 1353 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1354 | } |
| 1355 | else |
| 1356 | { |
| 1357 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq); |
| 1358 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1359 | } |
| 1360 | return 1; |
| 1361 | |
| 1362 | #ifdef U8X8_WITH_SET_CONTRAST |
| 1363 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 1364 | |
| 1365 | u8x8_cad_StartTransfer(u8x8); |
| 1366 | |
| 1367 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 1368 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 1369 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 1370 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 1371 | |
| 1372 | u8x8_cad_EndTransfer(u8x8); |
| 1373 | return 1; |
| 1374 | #endif |
| 1375 | } |
| 1376 | return 0; |
| 1377 | } |
| 1378 | |
| 1379 | |
| 1380 | |
| 1381 | |
| 1382 | /*=============================================*/ |
| 1383 | /* JLX256160 alternative version from issue #561 */ |
| 1384 | |
| 1385 | static const u8x8_display_info_t u8x8_st75256_256x160_alt_display_info = |
| 1386 | { |
| 1387 | /* chip_enable_level = */ 0, |
| 1388 | /* chip_disable_level = */ 1, |
| 1389 | |
| 1390 | /* post_chip_enable_wait_ns = */ 20, |
| 1391 | /* pre_chip_disable_wait_ns = */ 20, |
| 1392 | /* reset_pulse_width_ms = */ 5, |
| 1393 | /* post_reset_wait_ms = */ 5, /**/ |
| 1394 | /* sda_setup_time_ns = */ 20, /* */ |
| 1395 | /* sck_pulse_width_ns = */ 40, /* */ |
| 1396 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 1397 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 1398 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 1399 | /* data_setup_time_ns = */ 15, |
| 1400 | /* write_pulse_width_ns = */ 70, |
| 1401 | /* tile_width = */ 32, |
| 1402 | /* tile_height = */ 20, |
| 1403 | /* default_x_offset = */ 0, /* x offset in flipmode 0 */ |
| 1404 | /* flipmode_x_offset = */ 0, /* */ |
| 1405 | /* pixel_width = */ 256, |
| 1406 | /* pixel_height = */ 160 |
| 1407 | }; |
| 1408 | |
| 1409 | |
| 1410 | static const uint8_t u8x8_d_st75256_256x160_alt_init_seq[] = { |
| 1411 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1412 | |
| 1413 | U8X8_DLY(20), |
| 1414 | |
| 1415 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1416 | U8X8_C( 0x094 ), /* sleep out */ |
| 1417 | |
| 1418 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1419 | U8X8_C( 0x0ae ), /* display off */ |
| 1420 | |
| 1421 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 1422 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 1423 | |
| 1424 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1425 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 1426 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 1427 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 1428 | U8X8_A( 0x000 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 1429 | |
| 1430 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1431 | U8X8_C( 0x020 ), /* gray levels */ |
| 1432 | U8X8_A( 0x01 ), |
| 1433 | U8X8_A( 0x03 ), |
| 1434 | U8X8_A( 0x05 ), |
| 1435 | U8X8_A( 0x07 ), |
| 1436 | U8X8_A( 0x09), |
| 1437 | U8X8_A( 0x0b ), |
| 1438 | U8X8_A( 0x0d ), |
| 1439 | U8X8_A( 0x10 ), |
| 1440 | U8X8_A( 0x11 ), |
| 1441 | U8X8_A( 0x13 ), |
| 1442 | U8X8_A( 0x15 ), |
| 1443 | U8X8_A( 0x17 ), |
| 1444 | U8X8_A( 0x19 ), |
| 1445 | U8X8_A( 0x1b ), |
| 1446 | U8X8_A( 0x1d ), |
| 1447 | U8X8_A( 0x1f ), |
| 1448 | |
| 1449 | |
| 1450 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1451 | U8X8_CAA(0x75, 0, 0x4f), /* row range */ |
| 1452 | U8X8_CAA(0x15, 0, 255), /* col range */ |
| 1453 | |
| 1454 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1455 | U8X8_CA( 0xbc, 0x02 ), /* data scan dir */ |
| 1456 | U8X8_A( 0xa6 ), /* ??? */ |
| 1457 | |
| 1458 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1459 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 1460 | |
| 1461 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1462 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 1463 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 1464 | U8X8_A( 159 ), /* 1/160 duty value from the DS example code */ |
| 1465 | U8X8_A( 0x20 ), /* nline off */ |
| 1466 | |
| 1467 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1468 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 1469 | |
| 1470 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1471 | U8X8_CAA( 0x81, 0x18, 0x05 ), /* Volume control */ |
| 1472 | |
| 1473 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1474 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 1475 | U8X8_DLY(100), |
| 1476 | |
| 1477 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1478 | U8X8_END() /* end of sequence */ |
| 1479 | }; |
| 1480 | |
| 1481 | |
| 1482 | uint8_t u8x8_d_st75256_jlx256160_alt(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1483 | { |
| 1484 | uint8_t x, c; |
| 1485 | uint8_t *ptr; |
| 1486 | |
| 1487 | switch(msg) |
| 1488 | { |
| 1489 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 1490 | |
| 1491 | u8x8_cad_StartTransfer(u8x8); |
| 1492 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 1493 | x *= 8; |
| 1494 | |
| 1495 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 1496 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 1497 | if ( u8x8->x_offset == 0 ) /* 0 means flip mode 1 */ |
| 1498 | u8x8_cad_SendArg(u8x8, 1+(((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1499 | else |
| 1500 | u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1501 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 1502 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1503 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 1504 | u8x8_cad_SendArg(u8x8, x+u8x8->x_offset); |
| 1505 | u8x8_cad_SendArg(u8x8, 255); |
| 1506 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 1507 | |
| 1508 | |
| 1509 | do |
| 1510 | { |
| 1511 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 1512 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 1513 | /* SendData can not handle more than 255 bytes, treat c > 31 correctly */ |
| 1514 | if ( c > 31 ) |
| 1515 | { |
| 1516 | u8x8_cad_SendData(u8x8, 248, ptr); /* 31*8=248 */ |
| 1517 | ptr+=248; |
| 1518 | c -= 31; |
| 1519 | } |
| 1520 | |
| 1521 | u8x8_cad_SendData(u8x8, c*8, ptr); |
| 1522 | arg_int--; |
| 1523 | } while( arg_int > 0 ); |
| 1524 | |
| 1525 | u8x8_cad_EndTransfer(u8x8); |
| 1526 | return 1; |
| 1527 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1528 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 1529 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_256x160_alt_display_info); |
| 1530 | return 1; |
| 1531 | case U8X8_MSG_DISPLAY_INIT: |
| 1532 | u8x8_d_helper_display_init(u8x8); |
| 1533 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x160_alt_init_seq); |
| 1534 | return 1; |
| 1535 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 1536 | if ( arg_int == 0 ) |
| 1537 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 1538 | else |
| 1539 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 1540 | |
| 1541 | return 1; |
| 1542 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1543 | if ( arg_int == 0 ) |
| 1544 | { |
| 1545 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq); |
| 1546 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1547 | } |
| 1548 | else |
| 1549 | { |
| 1550 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq); |
| 1551 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1552 | } |
| 1553 | return 1; |
| 1554 | |
| 1555 | #ifdef U8X8_WITH_SET_CONTRAST |
| 1556 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 1557 | |
| 1558 | u8x8_cad_StartTransfer(u8x8); |
| 1559 | |
| 1560 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 1561 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 1562 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 1563 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 1564 | |
| 1565 | u8x8_cad_EndTransfer(u8x8); |
| 1566 | return 1; |
| 1567 | #endif |
| 1568 | } |
| 1569 | return 0; |
| 1570 | |
| 1571 | } |
| 1572 | |
| 1573 | |
| 1574 | /*=============================================*/ |
| 1575 | /* JLX19296 LCD */ |
| 1576 | |
| 1577 | static const u8x8_display_info_t u8x8_st75256_192x96_display_info = |
| 1578 | { |
| 1579 | /* chip_enable_level = */ 0, |
| 1580 | /* chip_disable_level = */ 1, |
| 1581 | |
| 1582 | /* post_chip_enable_wait_ns = */ 20, |
| 1583 | /* pre_chip_disable_wait_ns = */ 20, |
| 1584 | /* reset_pulse_width_ms = */ 5, |
| 1585 | /* post_reset_wait_ms = */ 5, /**/ |
| 1586 | /* sda_setup_time_ns = */ 20, /* */ |
| 1587 | /* sck_pulse_width_ns = */ 40, /* */ |
| 1588 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 1589 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 1590 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 1591 | /* data_setup_time_ns = */ 15, |
| 1592 | /* write_pulse_width_ns = */ 70, |
| 1593 | /* tile_width = */ 24, |
| 1594 | /* tile_height = */ 12, |
| 1595 | /* default_x_offset = */ 0, /* */ |
| 1596 | /* flipmode_x_offset = */ 64, |
| 1597 | /* pixel_width = */ 192, |
| 1598 | /* pixel_height = */ 96 |
| 1599 | }; |
| 1600 | |
| 1601 | static const uint8_t u8x8_d_st75256_jlx19296_init_seq[] = { |
| 1602 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1603 | |
| 1604 | U8X8_DLY(20), |
| 1605 | |
| 1606 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1607 | U8X8_C( 0x094 ), /* sleep out */ |
| 1608 | |
| 1609 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1610 | U8X8_C( 0x0ae ), /* display off */ |
| 1611 | |
| 1612 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 1613 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 1614 | |
| 1615 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1616 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 1617 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 1618 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 1619 | U8X8_A( 0x003 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 1620 | |
| 1621 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1622 | U8X8_C( 0x020 ), /* gray levels */ |
| 1623 | U8X8_A( 0x01 ), |
| 1624 | U8X8_A( 0x03 ), |
| 1625 | U8X8_A( 0x05 ), |
| 1626 | U8X8_A( 0x07 ), |
| 1627 | U8X8_A( 0x09), |
| 1628 | U8X8_A( 0x0b ), |
| 1629 | U8X8_A( 0x0d ), |
| 1630 | U8X8_A( 0x10 ), |
| 1631 | U8X8_A( 0x11 ), |
| 1632 | U8X8_A( 0x13 ), |
| 1633 | U8X8_A( 0x15 ), |
| 1634 | U8X8_A( 0x17 ), |
| 1635 | U8X8_A( 0x19 ), |
| 1636 | U8X8_A( 0x1b ), |
| 1637 | U8X8_A( 0x1d ), |
| 1638 | U8X8_A( 0x1f ), |
| 1639 | |
| 1640 | |
| 1641 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1642 | U8X8_CAA(0x75, 0, 0x4f), /* row range */ |
| 1643 | U8X8_CAA(0x15, 0, 255), /* col range */ |
| 1644 | |
| 1645 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1646 | U8X8_CA( 0xbc, 0x00 ), /* data scan dir */ |
| 1647 | U8X8_A( 0xa6 ), /* ??? */ |
| 1648 | |
| 1649 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1650 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 1651 | |
| 1652 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1653 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 1654 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 1655 | U8X8_A( 0x9f ), /* 1/160 duty value from the DS example code */ |
| 1656 | U8X8_A( 0x20 ), /* nline off */ |
| 1657 | |
| 1658 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1659 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 1660 | |
| 1661 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1662 | U8X8_CAA( 0x81, 0x2e, 0x03 ), /* Volume control */ |
| 1663 | |
| 1664 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1665 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 1666 | U8X8_DLY(100), |
| 1667 | |
| 1668 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1669 | U8X8_END() /* end of sequence */ |
| 1670 | }; |
| 1671 | |
| 1672 | |
| 1673 | uint8_t u8x8_d_st75256_jlx19296(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1674 | { |
| 1675 | uint8_t x, c; |
| 1676 | uint8_t *ptr; |
| 1677 | |
| 1678 | switch(msg) |
| 1679 | { |
| 1680 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 1681 | |
| 1682 | u8x8_cad_StartTransfer(u8x8); |
| 1683 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 1684 | x *= 8; |
| 1685 | |
| 1686 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 1687 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 1688 | if ( u8x8->x_offset == 0 ) /* 0 means flip mode 1, then adjust y value */ |
| 1689 | u8x8_cad_SendArg(u8x8, 8+(((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1690 | else |
| 1691 | u8x8_cad_SendArg(u8x8, 1+(((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1692 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 1693 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1694 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 1695 | u8x8_cad_SendArg(u8x8, x+u8x8->x_offset); |
| 1696 | u8x8_cad_SendArg(u8x8, 255); |
| 1697 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 1698 | |
| 1699 | |
| 1700 | do |
| 1701 | { |
| 1702 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 1703 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 1704 | c *= 8; |
| 1705 | |
| 1706 | if ( c + x > 192u ) |
| 1707 | { |
| 1708 | c = 192u; |
| 1709 | c -= x; |
| 1710 | } |
| 1711 | |
| 1712 | u8x8_cad_SendData(u8x8, c, ptr); |
| 1713 | x += c; |
| 1714 | arg_int--; |
| 1715 | } while( arg_int > 0 ); |
| 1716 | |
| 1717 | u8x8_cad_EndTransfer(u8x8); |
| 1718 | return 1; |
| 1719 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1720 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 1721 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_192x96_display_info); |
| 1722 | return 1; |
| 1723 | case U8X8_MSG_DISPLAY_INIT: |
| 1724 | u8x8_d_helper_display_init(u8x8); |
| 1725 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx19296_init_seq); |
| 1726 | return 1; |
| 1727 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 1728 | if ( arg_int == 0 ) |
| 1729 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 1730 | else |
| 1731 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 1732 | return 1; |
| 1733 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1734 | if ( arg_int == 0 ) |
| 1735 | { |
| 1736 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256160_flip0_seq); |
| 1737 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1738 | } |
| 1739 | else |
| 1740 | { |
| 1741 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256160_flip1_seq); |
| 1742 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1743 | } |
| 1744 | return 1; |
| 1745 | /* |
| 1746 | if ( arg_int == 0 ) |
| 1747 | { |
| 1748 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq); |
| 1749 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1750 | } |
| 1751 | else |
| 1752 | { |
| 1753 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq); |
| 1754 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1755 | } |
| 1756 | return 1; |
| 1757 | */ |
| 1758 | |
| 1759 | #ifdef U8X8_WITH_SET_CONTRAST |
| 1760 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 1761 | |
| 1762 | u8x8_cad_StartTransfer(u8x8); |
| 1763 | |
| 1764 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 1765 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 1766 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 1767 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 1768 | |
| 1769 | u8x8_cad_EndTransfer(u8x8); |
| 1770 | return 1; |
| 1771 | #endif |
| 1772 | } |
| 1773 | return 0; |
| 1774 | } |
| 1775 | |
| 1776 | |
| 1777 | |
| 1778 | /*=============================================*/ |
| 1779 | /* |
| 1780 | JLX16080 LCD |
| 1781 | |
| 1782 | https://github.com/olikraus/u8g2/issues/2058 |
| 1783 | |
| 1784 | WARNING: NOT FULLY TESTED in issue 2058! |
| 1785 | */ |
| 1786 | |
| 1787 | static const u8x8_display_info_t u8x8_st75256_jlx16080_display_info = |
| 1788 | { |
| 1789 | /* chip_enable_level = */ 0, |
| 1790 | /* chip_disable_level = */ 1, |
| 1791 | |
| 1792 | /* post_chip_enable_wait_ns = */ 20, |
| 1793 | /* pre_chip_disable_wait_ns = */ 20, |
| 1794 | /* reset_pulse_width_ms = */ 5, |
| 1795 | /* post_reset_wait_ms = */ 5, /**/ |
| 1796 | /* sda_setup_time_ns = */ 20, /* */ |
| 1797 | /* sck_pulse_width_ns = */ 40, /* */ |
| 1798 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 1799 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 1800 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 1801 | /* data_setup_time_ns = */ 15, |
| 1802 | /* write_pulse_width_ns = */ 70, |
| 1803 | /* tile_width = */ 20, |
| 1804 | /* tile_height = */ 10, |
| 1805 | /* default_x_offset = */ 0, /* */ |
| 1806 | /* flipmode_x_offset = */ 0, |
| 1807 | /* pixel_width = */ 160, |
| 1808 | /* pixel_height = */ 80 |
| 1809 | }; |
| 1810 | |
| 1811 | static const uint8_t u8x8_d_st75256_jlx16080_init_seq[] = { |
| 1812 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 1813 | |
| 1814 | U8X8_DLY(20), |
| 1815 | |
| 1816 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1817 | U8X8_C( 0x094 ), /* sleep out */ |
| 1818 | |
| 1819 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1820 | U8X8_C( 0x0ae ), /* display off */ |
| 1821 | |
| 1822 | U8X8_C( 0x031 ), /* select 01 commands */ |
| 1823 | U8X8_CA( 0x0d7, 0x09f ), /* disable auto read */ |
| 1824 | |
| 1825 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1826 | U8X8_C( 0x032 ), /* analog circuit set */ |
| 1827 | U8X8_A( 0x000 ), /* code example: OSC Frequency adjustment */ |
| 1828 | U8X8_A( 0x001 ), /* Frequency on booster capacitors 1 = 6KHz? */ |
| 1829 | U8X8_A( 0x003 ), /* Bias: 1: 1/13, 2: 1/12, 3: 1/11, 4:1/10, 5:1/9 */ |
| 1830 | |
| 1831 | //U8X8_C( 0x031 ), /* select 01 commands */ |
| 1832 | U8X8_C( 0x020 ), /* gray levels */ |
| 1833 | U8X8_A( 0x01 ), |
| 1834 | U8X8_A( 0x03 ), |
| 1835 | U8X8_A( 0x05 ), |
| 1836 | U8X8_A( 0x07 ), |
| 1837 | U8X8_A( 0x09), |
| 1838 | U8X8_A( 0x0b ), |
| 1839 | U8X8_A( 0x0d ), |
| 1840 | U8X8_A( 0x10 ), |
| 1841 | U8X8_A( 0x11 ), |
| 1842 | U8X8_A( 0x13 ), |
| 1843 | U8X8_A( 0x15 ), |
| 1844 | U8X8_A( 0x17 ), |
| 1845 | U8X8_A( 0x19 ), |
| 1846 | U8X8_A( 0x1b ), |
| 1847 | U8X8_A( 0x1d ), |
| 1848 | U8X8_A( 0x1f ), |
| 1849 | |
| 1850 | |
| 1851 | U8X8_C( 0x030 ), /* select 00 commands */ |
| 1852 | U8X8_CAA(0x75, 0, 0x4f), /* row range */ |
| 1853 | U8X8_CAA(0x15, 0, 255), /* col range */ |
| 1854 | |
| 1855 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1856 | U8X8_CA( 0xbc, 0x00 ), /* data scan dir */ |
| 1857 | U8X8_A( 0xa6 ), /* ??? */ |
| 1858 | |
| 1859 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1860 | U8X8_C( 0x00c ), /* data format LSB top */ |
| 1861 | |
| 1862 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1863 | U8X8_C( 0xca ), /* display control, 3 args follow */ |
| 1864 | U8X8_A( 0x00 ), /* 0x00: no clock division, 0x04: devide clock */ |
| 1865 | U8X8_A( 0x9f ), /* 1/160 duty value from the DS example code */ |
| 1866 | U8X8_A( 0x20 ), /* nline off */ |
| 1867 | |
| 1868 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1869 | U8X8_CA( 0x0f0, 0x010 ), /* monochrome mode = 0x010*/ |
| 1870 | |
| 1871 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1872 | U8X8_CAA( 0x81, 0x2e, 0x03 ), /* Volume control */ |
| 1873 | |
| 1874 | //U8X8_C( 0x030 ), /* select 00 commands */ |
| 1875 | U8X8_CA( 0x020, 0x00b ), /* Power control: Regulator, follower & booster on */ |
| 1876 | U8X8_DLY(100), |
| 1877 | |
| 1878 | U8X8_END_TRANSFER(), /* disable chip */ |
| 1879 | U8X8_END() /* end of sequence */ |
| 1880 | }; |
| 1881 | |
| 1882 | |
| 1883 | uint8_t u8x8_d_st75256_jlx16080(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 1884 | { |
| 1885 | uint8_t x, c; |
| 1886 | uint8_t *ptr; |
| 1887 | |
| 1888 | switch(msg) |
| 1889 | { |
| 1890 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 1891 | |
| 1892 | u8x8_cad_StartTransfer(u8x8); |
| 1893 | x = ((u8x8_tile_t *)arg_ptr)->x_pos; |
| 1894 | x *= 8; |
| 1895 | |
| 1896 | u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ |
| 1897 | u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ |
| 1898 | |
| 1899 | |
| 1900 | //if ( u8x8->x_offset == 0 ) /* 0 means flip mode 1, then adjust y value */ |
| 1901 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1902 | //else |
| 1903 | u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1904 | |
| 1905 | |
| 1906 | u8x8_cad_SendArg(u8x8, 0x04f); |
| 1907 | //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); |
| 1908 | u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ |
| 1909 | u8x8_cad_SendArg(u8x8, x+u8x8->x_offset); |
| 1910 | u8x8_cad_SendArg(u8x8, 255); |
| 1911 | u8x8_cad_SendCmd(u8x8, 0x05c ); |
| 1912 | |
| 1913 | |
| 1914 | do |
| 1915 | { |
| 1916 | c = ((u8x8_tile_t *)arg_ptr)->cnt; |
| 1917 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; |
| 1918 | c *= 8; |
| 1919 | |
| 1920 | if ( c + x > 192u ) |
| 1921 | { |
| 1922 | c = 192u; |
| 1923 | c -= x; |
| 1924 | } |
| 1925 | |
| 1926 | u8x8_cad_SendData(u8x8, c, ptr); |
| 1927 | x += c; |
| 1928 | arg_int--; |
| 1929 | } while( arg_int > 0 ); |
| 1930 | |
| 1931 | u8x8_cad_EndTransfer(u8x8); |
| 1932 | return 1; |
| 1933 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 1934 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 1935 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_jlx16080_display_info); |
| 1936 | return 1; |
| 1937 | case U8X8_MSG_DISPLAY_INIT: |
| 1938 | u8x8_d_helper_display_init(u8x8); |
| 1939 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx16080_init_seq); |
| 1940 | return 1; |
| 1941 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 1942 | if ( arg_int == 0 ) |
| 1943 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave0_seq); |
| 1944 | else |
| 1945 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_256x128_powersave1_seq); |
| 1946 | return 1; |
| 1947 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE: |
| 1948 | if ( arg_int == 0 ) |
| 1949 | { |
| 1950 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256160_flip0_seq); |
| 1951 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1952 | } |
| 1953 | else |
| 1954 | { |
| 1955 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256160_flip1_seq); |
| 1956 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1957 | } |
| 1958 | return 1; |
| 1959 | /* |
| 1960 | if ( arg_int == 0 ) |
| 1961 | { |
| 1962 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip0_seq); |
| 1963 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 1964 | } |
| 1965 | else |
| 1966 | { |
| 1967 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx172104_flip1_seq); |
| 1968 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 1969 | } |
| 1970 | return 1; |
| 1971 | */ |
| 1972 | |
| 1973 | #ifdef U8X8_WITH_SET_CONTRAST |
| 1974 | case U8X8_MSG_DISPLAY_SET_CONTRAST: |
| 1975 | |
| 1976 | u8x8_cad_StartTransfer(u8x8); |
| 1977 | |
| 1978 | u8x8_cad_SendCmd(u8x8, 0x030 ); |
| 1979 | u8x8_cad_SendCmd(u8x8, 0x081 ); /* there are 9 bit for the volume control */ |
| 1980 | u8x8_cad_SendArg(u8x8, (arg_int & 0x1f)<<1 ); /* lower 6 bit */ |
| 1981 | u8x8_cad_SendArg(u8x8, (arg_int>>5)); /* upper 3 bit */ |
| 1982 | |
| 1983 | u8x8_cad_EndTransfer(u8x8); |
| 1984 | return 1; |
| 1985 | #endif |
| 1986 | } |
| 1987 | return 0; |
| 1988 | } |
| 1989 | |
| 1990 | /*=============================================*/ |
| 1991 | /* 128x128 issue https://github.com/olikraus/u8g2/issues/2702*/ |
| 1992 | |
| 1993 | static const u8x8_display_info_t u8x8_st75256_128x128_display_info = |
| 1994 | { |
| 1995 | /* chip_enable_level = */ 0, |
| 1996 | /* chip_disable_level = */ 1, |
| 1997 | |
| 1998 | /* post_chip_enable_wait_ns = */ 20, |
| 1999 | /* pre_chip_disable_wait_ns = */ 20, |
| 2000 | /* reset_pulse_width_ms = */ 5, |
| 2001 | /* post_reset_wait_ms = */ 5, /**/ |
| 2002 | /* sda_setup_time_ns = */ 20, /* */ |
| 2003 | /* sck_pulse_width_ns = */ 40, /* */ |
| 2004 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 2005 | /* spi_mode = */ 0, /* active high, rising edge */ |
| 2006 | /* i2c_bus_clock_100kHz = */ 4, /* 400KHz */ |
| 2007 | /* data_setup_time_ns = */ 15, |
| 2008 | /* write_pulse_width_ns = */ 70, |
| 2009 | /* tile_width = */ 16, |
| 2010 | /* tile_height = */ 16, |
| 2011 | /* default_x_offset = */ 0, /* must be 0, because this is checked also for normal mode */ |
| 2012 | /* flipmode_x_offset = */ 0, /* used as y offset */ |
| 2013 | /* pixel_width = */ 128, |
| 2014 | /* pixel_height = */ 128 |
| 2015 | }; |
| 2016 | |
| 2017 | |
| 2018 | static const uint8_t u8x8_d_st75256_128x128_init_seq[] = { |
| 2019 | U8X8_START_TRANSFER(), |
| 2020 | U8X8_DLY(10), // 10ms delay |
| 2021 | |
| 2022 | U8X8_C(0x30), // Extension command 1 |
| 2023 | U8X8_C(0x6E), // Enable Master |
| 2024 | |
| 2025 | U8X8_C(0x31), // Extension command 2 |
| 2026 | U8X8_C(0xD7), U8X8_A(0x9F), // Disable Auto Read |
| 2027 | U8X8_C(0xE0), U8X8_A(0x00), // Enable OTP Read |
| 2028 | U8X8_DLY(10), |
| 2029 | U8X8_C(0xE3), // OTP Up-Load |
| 2030 | U8X8_DLY(20), // 20ms delay |
| 2031 | U8X8_C(0xE1), // OTP Control End |
| 2032 | |
| 2033 | U8X8_C(0x30), // Extension command 1 |
| 2034 | U8X8_C(0x94), // Sleep Out |
| 2035 | U8X8_C(0xAE), // Display Off |
| 2036 | U8X8_DLY(50), // 50ms delay |
| 2037 | |
| 2038 | U8X8_C(0x20), // Power Control |
| 2039 | U8X8_A(0x0B), // VB, VR, VF All on |
| 2040 | U8X8_C(0x81), U8X8_A(0x1D), U8X8_A(0x04), // Set Vop (15.0V) |
| 2041 | |
| 2042 | U8X8_C(0x31), // Extension command 2 |
| 2043 | U8X8_C(0x32), U8X8_A(0x00), // Analog Set |
| 2044 | U8X8_A(0x01), // Booster efficiency level 1 |
| 2045 | U8X8_A(0x02), // Bias 1/12 |
| 2046 | U8X8_C(0x51), U8X8_A(0xFA), // Booster Level x 8 |
| 2047 | |
| 2048 | U8X8_C(0x30), // Extension command 1 |
| 2049 | U8X8_C(0xF0), U8X8_A(0x10), // Display Mode = Monochrome |
| 2050 | U8X8_C(0xCA), // Display Control |
| 2051 | U8X8_A(0x00), // CL Dividing Ratio = Not divided |
| 2052 | U8X8_A(0x7F), // Duty Set = 128 |
| 2053 | U8X8_A(0x3F), |
| 2054 | U8X8_C(0xBC), U8X8_A(0x00), // Data Scan Direction |
| 2055 | U8X8_C(0xA6), // Normal Display |
| 2056 | U8X8_C(0x0C), // Data Format = LSB on Top |
| 2057 | U8X8_CAA(0x75, 0x00, 0x7F), // row range for 128 rows |
| 2058 | U8X8_CAA(0x15, 0x00, 0x7F), // col range for 128 cols |
| 2059 | |
| 2060 | U8X8_C(0x31), // Extension command 2 |
| 2061 | U8X8_C(0x40), // Internal Power Supply |
| 2062 | |
| 2063 | U8X8_C(0x30), // Extension command 1 |
| 2064 | U8X8_C(0xaf), // Display On |
| 2065 | U8X8_END_TRANSFER(), |
| 2066 | U8X8_END() |
| 2067 | }; |
| 2068 | |
| 2069 | |
| 2070 | uint8_t u8x8_d_st75256_128x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 2071 | { |
| 2072 | if ( u8x8_d_st75256_256x128_generic(u8x8, msg, arg_int, arg_ptr) != 0 ) |
| 2073 | return 1; |
| 2074 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY ) |
| 2075 | { |
| 2076 | //u8x8_SetI2CAddress(u8x8, 0x078); /* lowest I2C adr of the ST75256 */ |
| 2077 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_st75256_128x128_display_info); |
| 2078 | return 1; |
| 2079 | } |
| 2080 | else if ( msg == U8X8_MSG_DISPLAY_INIT ) |
| 2081 | { |
| 2082 | u8x8_d_helper_display_init(u8x8); |
| 2083 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_128x128_init_seq); |
| 2084 | return 1; |
| 2085 | } |
| 2086 | else if ( msg == U8X8_MSG_DISPLAY_SET_FLIP_MODE ) |
| 2087 | { |
| 2088 | if ( arg_int == 0 ) |
| 2089 | { |
| 2090 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256128_flip0_seq); |
| 2091 | u8x8->x_offset = u8x8->display_info->default_x_offset; |
| 2092 | } |
| 2093 | else |
| 2094 | { |
| 2095 | u8x8_cad_SendSequence(u8x8, u8x8_d_st75256_jlx256128_flip1_seq); |
| 2096 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset; |
| 2097 | } |
| 2098 | return 1; |
| 2099 | } |
| 2100 | return 0; |
| 2101 | } |
| 2102 | |
| 2103 | |