| 1 | /* |
| 2 | |
| 3 | u8x8_d_sed1330.c |
| 4 | |
| 5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) |
| 6 | |
| 7 | Copyright (c) 2016, 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 | |
| 35 | The device might also work with the RA8835, SED1335 and SED1336 controller. |
| 36 | The following devices might be compatible: |
| 37 | RA8835 |
| 38 | SED1330 |
| 39 | SED1335 |
| 40 | S1D13700 |
| 41 | |
| 42 | |
| 43 | */ |
| 44 | #include "u8x8.h" |
| 45 | |
| 46 | |
| 47 | |
| 48 | static const uint8_t u8x8_d_sed1330_powersave0_seq[] = { |
| 49 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 50 | U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */ |
| 51 | U8X8_CA(0x059, 0x004), /* send display on command (hex 0x059, see p37 ) */ |
| 52 | /* display cmd has one arg: 01010100 should enable all three blocks, but disable the cursor*/ |
| 53 | |
| 54 | U8X8_END_TRANSFER(), /* disable chip */ |
| 55 | U8X8_END() /* end of sequence */ |
| 56 | }; |
| 57 | |
| 58 | static const uint8_t u8x8_d_sed1330_powersave1_seq[] = { |
| 59 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 60 | U8X8_CA(0x058, 0x000), /* send display off command (hex 0x059, see p37) and turn of all banks */ |
| 61 | /* maybe send a sleep in cmd */ |
| 62 | //U8X8_C(0x053) /* sleep in: 0x053 */ |
| 63 | U8X8_END_TRANSFER(), /* disable chip */ |
| 64 | U8X8_END() /* end of sequence */ |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | uint8_t u8x8_d_sed1330_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 69 | { |
| 70 | uint8_t c, i; |
| 71 | uint16_t y; |
| 72 | uint8_t *ptr; |
| 73 | switch(msg) |
| 74 | { |
| 75 | /* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */ |
| 76 | /* |
| 77 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 78 | break; |
| 79 | case U8X8_MSG_DISPLAY_INIT: |
| 80 | break; |
| 81 | */ |
| 82 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE: |
| 83 | if ( arg_int == 0 ) |
| 84 | u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_powersave0_seq); |
| 85 | else |
| 86 | u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_powersave1_seq); |
| 87 | break; |
| 88 | case U8X8_MSG_DISPLAY_DRAW_TILE: |
| 89 | y = (((u8x8_tile_t *)arg_ptr)->y_pos); |
| 90 | y*=8; |
| 91 | y*= u8x8->display_info->tile_width; |
| 92 | |
| 93 | u8x8_cad_StartTransfer(u8x8); |
| 94 | |
| 95 | c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */ |
| 96 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */ |
| 97 | for( i = 0; i < 8; i++ ) |
| 98 | { |
| 99 | u8x8_cad_SendCmd(u8x8, 0x046 ); /* CSRW command*/ |
| 100 | u8x8_cad_SendArg(u8x8, y&255); /* CSRW low adr byte */ |
| 101 | u8x8_cad_SendArg(u8x8, y>>8); /* CSRW high adr byte */ |
| 102 | u8x8_cad_SendCmd(u8x8, 0x042 ); /* MWRITE */ |
| 103 | |
| 104 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */ |
| 105 | |
| 106 | ptr += u8x8->display_info->tile_width; |
| 107 | y += u8x8->display_info->tile_width; |
| 108 | } |
| 109 | |
| 110 | /* sometimes the display switches off... so just sent a display on command */ |
| 111 | u8x8_cad_SendCmd(u8x8, 0x059 ); /* display on */ |
| 112 | u8x8_cad_SendArg(u8x8, 0x004); /* arg for display on */ |
| 113 | |
| 114 | u8x8_cad_EndTransfer(u8x8); |
| 115 | //u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */ |
| 116 | |
| 117 | break; |
| 118 | default: |
| 119 | return 0; |
| 120 | } |
| 121 | return 1; |
| 122 | } |
| 123 | |
| 124 | /*=============================================*/ |
| 125 | |
| 126 | |
| 127 | static const u8x8_display_info_t u8x8_sed1330_240x128_display_info = |
| 128 | { |
| 129 | /* chip_enable_level = */ 0, |
| 130 | /* chip_disable_level = */ 1, |
| 131 | |
| 132 | /* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */ |
| 133 | /* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */ |
| 134 | /* reset_pulse_width_ms = */ 1, |
| 135 | /* post_reset_wait_ms = */ 6, |
| 136 | /* sda_setup_time_ns = */ 20, |
| 137 | /* sck_pulse_width_ns = */ 140, |
| 138 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 139 | /* spi_mode = */ 0, |
| 140 | /* i2c_bus_clock_100kHz = */ 4, |
| 141 | /* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */ |
| 142 | /* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */ |
| 143 | /* tile_width = */ 0x01e, |
| 144 | /* tile_height = */ 16, |
| 145 | /* default_x_offset = */ 0, |
| 146 | /* flipmode_x_offset = */ 0, |
| 147 | /* pixel_width = */ 240, |
| 148 | /* pixel_height = */ 128 |
| 149 | }; |
| 150 | |
| 151 | /* 240x128 Seiko G242C */ |
| 152 | static const uint8_t u8x8_d_sed1330_240x128_init_seq[] = { |
| 153 | U8X8_DLY(100), |
| 154 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 155 | U8X8_DLY(100), |
| 156 | |
| 157 | /* system init command, see also u8x8_d_sed1330_powersave0_seq */ |
| 158 | U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */ |
| 159 | /* system init has total 8 parameters, so 7 more are here */ |
| 160 | U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */ |
| 161 | U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */ |
| 162 | U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */ |
| 163 | U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/ |
| 164 | U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/ |
| 165 | U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */ |
| 166 | U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */ |
| 167 | |
| 168 | U8X8_C(0x044), /* SCROLL */ |
| 169 | U8X8_A(0x000), |
| 170 | U8X8_A(0x000), |
| 171 | U8X8_A(0x080), |
| 172 | U8X8_A(0x000), |
| 173 | U8X8_A(0x040), |
| 174 | U8X8_A(0x080), |
| 175 | U8X8_A(0x000), |
| 176 | U8X8_A(0x000), |
| 177 | U8X8_A(0x000), |
| 178 | U8X8_A(0x000), |
| 179 | |
| 180 | U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */ |
| 181 | |
| 182 | U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */ |
| 183 | |
| 184 | |
| 185 | U8X8_DLY(100), |
| 186 | U8X8_END_TRANSFER(), /* disable chip */ |
| 187 | U8X8_DLY(100), |
| 188 | }; |
| 189 | |
| 190 | /* RA8835 NHD-240128BZ */ |
| 191 | static const uint8_t u8x8_d_rh8835_nhd_240128_init_seq[] = { |
| 192 | U8X8_DLY(100), |
| 193 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 194 | U8X8_DLY(100), |
| 195 | |
| 196 | /* system init command, see also u8x8_d_sed1330_powersave0_seq */ |
| 197 | U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */ |
| 198 | /* system init has total 8 parameters, so 7 more are here */ |
| 199 | U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */ |
| 200 | U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */ |
| 201 | U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */ |
| 202 | U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/ |
| 203 | U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/ |
| 204 | U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */ |
| 205 | U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */ |
| 206 | |
| 207 | U8X8_C(0x044), /* SCROLL */ |
| 208 | U8X8_A(0x000), |
| 209 | U8X8_A(0x000), |
| 210 | U8X8_A(0x080), |
| 211 | U8X8_A(0x000), |
| 212 | U8X8_A(0x040), |
| 213 | U8X8_A(0x080), |
| 214 | U8X8_A(0x000), |
| 215 | U8X8_A(0x000), |
| 216 | U8X8_A(0x000), |
| 217 | U8X8_A(0x000), |
| 218 | |
| 219 | //U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */ |
| 220 | |
| 221 | U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */ |
| 222 | |
| 223 | //U8X8_CA(0x059, 0x04), /* send display on command (hex 0x059, see p37 ) */ |
| 224 | |
| 225 | U8X8_DLY(100), |
| 226 | U8X8_END_TRANSFER(), /* disable chip */ |
| 227 | U8X8_DLY(100), |
| 228 | |
| 229 | }; |
| 230 | |
| 231 | |
| 232 | uint8_t u8x8_d_sed1330_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 233 | { |
| 234 | switch(msg) |
| 235 | { |
| 236 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 237 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x128_display_info); |
| 238 | break; |
| 239 | case U8X8_MSG_DISPLAY_INIT: |
| 240 | u8x8_d_helper_display_init(u8x8); |
| 241 | u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_240x128_init_seq); |
| 242 | break; |
| 243 | default: |
| 244 | return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr); |
| 245 | } |
| 246 | return 1; |
| 247 | } |
| 248 | |
| 249 | |
| 250 | uint8_t u8x8_d_ra8835_nhd_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 251 | { |
| 252 | switch(msg) |
| 253 | { |
| 254 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 255 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x128_display_info); |
| 256 | break; |
| 257 | case U8X8_MSG_DISPLAY_INIT: |
| 258 | u8x8_d_helper_display_init(u8x8); |
| 259 | u8x8_cad_SendSequence(u8x8, u8x8_d_rh8835_nhd_240128_init_seq); |
| 260 | break; |
| 261 | default: |
| 262 | return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr); |
| 263 | } |
| 264 | return 1; |
| 265 | } |
| 266 | |
| 267 | /*=============================================*/ |
| 268 | /* issue 2518 https://github.com/olikraus/u8g2/issues/2518 */ |
| 269 | |
| 270 | static const u8x8_display_info_t u8x8_sed1330_240x64_display_info = |
| 271 | { |
| 272 | /* chip_enable_level = */ 0, |
| 273 | /* chip_disable_level = */ 1, |
| 274 | |
| 275 | /* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */ |
| 276 | /* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */ |
| 277 | /* reset_pulse_width_ms = */ 1, |
| 278 | /* post_reset_wait_ms = */ 6, |
| 279 | /* sda_setup_time_ns = */ 20, |
| 280 | /* sck_pulse_width_ns = */ 140, |
| 281 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 282 | /* spi_mode = */ 0, |
| 283 | /* i2c_bus_clock_100kHz = */ 4, |
| 284 | /* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */ |
| 285 | /* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */ |
| 286 | /* tile_width = */ 30, |
| 287 | /* tile_height = */ 8, |
| 288 | /* default_x_offset = */ 0, |
| 289 | /* flipmode_x_offset = */ 0, |
| 290 | /* pixel_width = */ 240, |
| 291 | /* pixel_height = */ 64 |
| 292 | }; |
| 293 | |
| 294 | static const uint8_t u8x8_d_sed1330_240x64_init_seq[] = { |
| 295 | U8X8_DLY(100), |
| 296 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 297 | U8X8_DLY(100), |
| 298 | |
| 299 | /* system init command, see also u8x8_d_sed1330_powersave0_seq */ |
| 300 | U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */ |
| 301 | /* system init has total 8 parameters, so 7 more are here */ |
| 302 | U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */ |
| 303 | U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */ |
| 304 | U8X8_A(0x01d), /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */ |
| 305 | U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/ |
| 306 | U8X8_A(0x03f), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/ |
| 307 | U8X8_A(0x01e), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */ |
| 308 | U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */ |
| 309 | |
| 310 | U8X8_C(0x044), /* SCROLL */ |
| 311 | U8X8_A(0x000), |
| 312 | U8X8_A(0x000), |
| 313 | U8X8_A(0x080), |
| 314 | U8X8_A(0x000), |
| 315 | U8X8_A(0x040), |
| 316 | U8X8_A(0x080), |
| 317 | U8X8_A(0x000), |
| 318 | U8X8_A(0x000), |
| 319 | U8X8_A(0x000), |
| 320 | U8X8_A(0x000), |
| 321 | |
| 322 | U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */ |
| 323 | |
| 324 | U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */ |
| 325 | |
| 326 | |
| 327 | U8X8_DLY(100), |
| 328 | U8X8_END_TRANSFER(), /* disable chip */ |
| 329 | U8X8_DLY(100), |
| 330 | }; |
| 331 | |
| 332 | |
| 333 | uint8_t u8x8_d_sed1330_240x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 334 | { |
| 335 | switch(msg) |
| 336 | { |
| 337 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 338 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_240x64_display_info); |
| 339 | break; |
| 340 | case U8X8_MSG_DISPLAY_INIT: |
| 341 | u8x8_d_helper_display_init(u8x8); |
| 342 | u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_240x64_init_seq); |
| 343 | u8x8_SendF(u8x8, "caaaaaaaa", 0x40, 0x30, 0x87, 0x07, 0x1d, 0x50, 0x3f, 0x1e, 0x00); /* send init again, issue 2518 https://github.com/olikraus/u8g2/issues/2518 */ |
| 344 | break; |
| 345 | default: |
| 346 | return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr); |
| 347 | } |
| 348 | return 1; |
| 349 | } |
| 350 | |
| 351 | |
| 352 | /*=============================================*/ |
| 353 | |
| 354 | |
| 355 | static const u8x8_display_info_t u8x8_sed1330_320x240_display_info = |
| 356 | { |
| 357 | /* chip_enable_level = */ 0, |
| 358 | /* chip_disable_level = */ 1, |
| 359 | |
| 360 | /* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */ |
| 361 | /* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */ |
| 362 | /* reset_pulse_width_ms = */ 1, |
| 363 | /* post_reset_wait_ms = */ 6, |
| 364 | /* sda_setup_time_ns = */ 20, |
| 365 | /* sck_pulse_width_ns = */ 140, |
| 366 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 367 | /* spi_mode = */ 0, |
| 368 | /* i2c_bus_clock_100kHz = */ 4, |
| 369 | /* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */ |
| 370 | /* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */ |
| 371 | /* tile_width = */ 40, |
| 372 | /* tile_height = */ 30, |
| 373 | /* default_x_offset = */ 0, |
| 374 | /* flipmode_x_offset = */ 0, |
| 375 | /* pixel_width = */ 320, |
| 376 | /* pixel_height = */ 240 |
| 377 | }; |
| 378 | |
| 379 | static const uint8_t u8x8_d_sed1330_320x240_init_seq[] = { |
| 380 | U8X8_DLY(100), |
| 381 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 382 | U8X8_DLY(100), |
| 383 | |
| 384 | /* system init command, see also u8x8_d_sed1330_powersave0_seq */ |
| 385 | U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */ |
| 386 | /* system init has total 8 parameters, so 7 more are here */ |
| 387 | U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */ |
| 388 | U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */ |
| 389 | U8X8_A(0x027), /* 40-1 */ /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */ |
| 390 | U8X8_A(0x039), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/ |
| 391 | U8X8_A(0x0ef), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/ |
| 392 | U8X8_A(0x028), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */ |
| 393 | U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */ |
| 394 | |
| 395 | U8X8_C(0x044), /* SCROLL */ |
| 396 | U8X8_A(0x000), |
| 397 | U8X8_A(0x000), |
| 398 | U8X8_A(0x0ef), |
| 399 | U8X8_A(0x0b0), |
| 400 | U8X8_A(0x004), |
| 401 | U8X8_A(0x0ef), |
| 402 | U8X8_A(0x000), |
| 403 | U8X8_A(0x000), |
| 404 | U8X8_A(0x000), |
| 405 | U8X8_A(0x000), |
| 406 | |
| 407 | U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */ |
| 408 | |
| 409 | U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */ |
| 410 | |
| 411 | |
| 412 | U8X8_DLY(100), |
| 413 | U8X8_END_TRANSFER(), /* disable chip */ |
| 414 | U8X8_DLY(100), |
| 415 | }; |
| 416 | |
| 417 | |
| 418 | |
| 419 | uint8_t u8x8_d_ra8835_320x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 420 | { |
| 421 | switch(msg) |
| 422 | { |
| 423 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 424 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_320x240_display_info); |
| 425 | break; |
| 426 | case U8X8_MSG_DISPLAY_INIT: |
| 427 | u8x8_d_helper_display_init(u8x8); |
| 428 | u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_320x240_init_seq); |
| 429 | break; |
| 430 | default: |
| 431 | return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr); |
| 432 | } |
| 433 | return 1; |
| 434 | } |
| 435 | |
| 436 | /*=============================================*/ |
| 437 | /* |
| 438 | https://github.com/olikraus/u8g2/issues/1908 |
| 439 | https://www.allelectronics.com/mas_assets/media/allelectronics2018/spec/LCD-101.pdf |
| 440 | */ |
| 441 | |
| 442 | static const u8x8_display_info_t u8x8_sed1330_256x128_display_info = |
| 443 | { |
| 444 | /* chip_enable_level = */ 0, |
| 445 | /* chip_disable_level = */ 1, |
| 446 | |
| 447 | /* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */ |
| 448 | /* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */ |
| 449 | /* reset_pulse_width_ms = */ 1, |
| 450 | /* post_reset_wait_ms = */ 6, |
| 451 | /* sda_setup_time_ns = */ 20, |
| 452 | /* sck_pulse_width_ns = */ 140, |
| 453 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 454 | /* spi_mode = */ 0, |
| 455 | /* i2c_bus_clock_100kHz = */ 4, |
| 456 | /* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */ |
| 457 | /* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */ |
| 458 | /* tile_width = */ 32, |
| 459 | /* tile_height = */ 16, |
| 460 | /* default_x_offset = */ 0, |
| 461 | /* flipmode_x_offset = */ 0, |
| 462 | /* pixel_width = */ 256, |
| 463 | /* pixel_height = */ 128 |
| 464 | }; |
| 465 | |
| 466 | |
| 467 | /* 256x128 Hyundai HG25604 (HG25504???) */ |
| 468 | static const uint8_t u8x8_d_sed1330_256x128_init_seq[] = { |
| 469 | U8X8_DLY(100), |
| 470 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 471 | U8X8_DLY(100), |
| 472 | |
| 473 | /* system init command, see also u8x8_d_sed1330_powersave0_seq */ |
| 474 | U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */ |
| 475 | /* system init has total 8 parameters, so 7 more are here */ |
| 476 | U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */ |
| 477 | U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */ |
| 478 | U8X8_A(0x01f), /* 32-1*/ /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */ |
| 479 | U8X8_A(0x050), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/ |
| 480 | U8X8_A(0x080), /* L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/ |
| 481 | U8X8_A(0x020), /* 32 */ /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */ |
| 482 | U8X8_A(0), /* High byte of the virtual screen size, see also section 9.1.2 */ |
| 483 | |
| 484 | U8X8_C(0x044), /* SCROLL, 11 Bytes in total */ |
| 485 | U8X8_A(0x000), |
| 486 | U8X8_A(0x000), |
| 487 | U8X8_A(0x080), |
| 488 | U8X8_A(0x000), |
| 489 | U8X8_A(0x040), |
| 490 | U8X8_A(0x080), |
| 491 | U8X8_A(0x000), |
| 492 | U8X8_A(0x000), |
| 493 | U8X8_A(0x000), |
| 494 | U8X8_A(0x000), |
| 495 | |
| 496 | U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */ |
| 497 | |
| 498 | U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */ |
| 499 | |
| 500 | |
| 501 | U8X8_DLY(100), |
| 502 | U8X8_END_TRANSFER(), /* disable chip */ |
| 503 | U8X8_DLY(100), |
| 504 | }; |
| 505 | |
| 506 | uint8_t u8x8_d_sed1330_256x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 507 | { |
| 508 | switch(msg) |
| 509 | { |
| 510 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 511 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_256x128_display_info); |
| 512 | break; |
| 513 | case U8X8_MSG_DISPLAY_INIT: |
| 514 | u8x8_d_helper_display_init(u8x8); |
| 515 | u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_256x128_init_seq); |
| 516 | break; |
| 517 | default: |
| 518 | return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr); |
| 519 | } |
| 520 | return 1; |
| 521 | } |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | /*=============================================*/ |
| 530 | |
| 531 | /* |
| 532 | https://github.com/olikraus/u8g2/issues/1086 |
| 533 | */ |
| 534 | |
| 535 | static const u8x8_display_info_t u8x8_sed1330_320x200_display_info = |
| 536 | { |
| 537 | /* chip_enable_level = */ 0, |
| 538 | /* chip_disable_level = */ 1, |
| 539 | |
| 540 | /* post_chip_enable_wait_ns = */ 30, /* G242CX Datasheet p5 */ |
| 541 | /* pre_chip_disable_wait_ns = */ 10, /* G242CX Datasheet p5 */ |
| 542 | /* reset_pulse_width_ms = */ 1, |
| 543 | /* post_reset_wait_ms = */ 6, |
| 544 | /* sda_setup_time_ns = */ 20, |
| 545 | /* sck_pulse_width_ns = */ 140, |
| 546 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */ |
| 547 | /* spi_mode = */ 0, |
| 548 | /* i2c_bus_clock_100kHz = */ 4, |
| 549 | /* data_setup_time_ns = */ 120, /* G242CX Datasheet p5 */ |
| 550 | /* write_pulse_width_ns = */ 220, /* G242CX Datasheet p5 */ |
| 551 | /* tile_width = */ 40, |
| 552 | /* tile_height = */ 25, |
| 553 | /* default_x_offset = */ 0, |
| 554 | /* flipmode_x_offset = */ 0, |
| 555 | /* pixel_width = */ 320, |
| 556 | /* pixel_height = */ 200 |
| 557 | }; |
| 558 | |
| 559 | static const uint8_t u8x8_d_sed1330_320x200_init_seq[] = { |
| 560 | U8X8_DLY(100), |
| 561 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ |
| 562 | U8X8_DLY(100), |
| 563 | |
| 564 | /* system init command, see also u8x8_d_sed1330_powersave0_seq */ |
| 565 | U8X8_CA(0x040, 0x030), /* sys init (0x040) with one arg, where 0x030 is a wild guess */ |
| 566 | /* system init has total 8 parameters, so 7 more are here */ |
| 567 | |
| 568 | U8X8_A(0x087), /* no idea here... WF (topmost bit) is set to one because it is suggested in the datasheet, lowest 3 bits refer to text mode only */ |
| 569 | U8X8_A(0x007), /* FY: height of a char+1, does not matter here (hopefully), because we use graphics mode only */ |
| 570 | U8X8_A(0x027), /* 40-1 */ /* C/R: this could be the number of horizontal bytes - 1 (Value confirmed with app notes p41) */ |
| 571 | U8X8_A(0x02F), /* TC/R: According to app notes fOSC=6Mhz fFF=70Hz --> TC/R = 74d*/ |
| 572 | U8X8_A(0x0c7), /* 0xc7=199, L/F: Lines per frame - 1, probably this is the height of the display - 1 (value confirmed with app notes p41)*/ |
| 573 | U8X8_A(0x028), /* Low byte of the virtual screen size. (Value confirmed with app notes p41) */ |
| 574 | U8X8_A(0x000), /* High byte of the virtual screen size, see also section 9.1.2 */ |
| 575 | |
| 576 | U8X8_C(0x044), /* SCROLL, 11 Bytes in total */ |
| 577 | U8X8_A(0x000), /* Screen 1 Start Address (Low) = 00H */ |
| 578 | U8X8_A(0x000), /* Screen 1 Start Address (High) = 00H */ |
| 579 | U8X8_A(0x0c7), /* Screen Layer 1 Number of lines = 200d */ |
| 580 | U8X8_A(0x0b0), /* Screen 2 Start Address (Low) = 00H */ |
| 581 | U8X8_A(0x005), /* Screen 2 Start Address (High) = 00H */ |
| 582 | U8X8_A(0x0c7), /* Screen Layer 2 Number of lines = 200d */ |
| 583 | U8X8_C(0x04C), /* Cursor Direction 0,0 Shift Direction = Right */ |
| 584 | U8X8_A(0x000), |
| 585 | U8X8_A(0x000), |
| 586 | U8X8_A(0x000), |
| 587 | |
| 588 | U8X8_CA(0x05a, 0), /* HDOT SCR: Horizontal dotwise scroll... set to 0 */ |
| 589 | |
| 590 | U8X8_CA(0x05b, 0x0c), /* OVLAY: 2-layer, all graphics, OR between layer 1 and 2 */ |
| 591 | |
| 592 | |
| 593 | U8X8_DLY(100), |
| 594 | U8X8_END_TRANSFER(), /* disable chip */ |
| 595 | U8X8_DLY(100), |
| 596 | }; |
| 597 | |
| 598 | |
| 599 | |
| 600 | uint8_t u8x8_d_sed1330_320x200(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) |
| 601 | { |
| 602 | switch(msg) |
| 603 | { |
| 604 | case U8X8_MSG_DISPLAY_SETUP_MEMORY: |
| 605 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sed1330_320x200_display_info); |
| 606 | break; |
| 607 | case U8X8_MSG_DISPLAY_INIT: |
| 608 | u8x8_d_helper_display_init(u8x8); |
| 609 | u8x8_cad_SendSequence(u8x8, u8x8_d_sed1330_320x200_init_seq); |
| 610 | break; |
| 611 | default: |
| 612 | return u8x8_d_sed1330_common(u8x8, msg, arg_int, arg_ptr); |
| 613 | } |
| 614 | return 1; |
| 615 | } |
| 616 | |
| 617 | |