static void u8x8_d_ssd1606_draw_tile(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr) { uint8_t x, c, page; uint8_t *ptr; u8x8_cad_StartTransfer(u8x8); page = u8x8->display_info->tile_height; page --; page -= (((u8x8_tile_t *)arg_ptr)->y_pos); page *= 2; x = ((u8x8_tile_t *)arg_ptr)->x_pos; x *= 8; x += u8x8->x_offset; u8x8_cad_SendCmd(u8x8, 0x00f ); /* scan start */ u8x8_cad_SendArg(u8x8, 0); u8x8_cad_SendCmd(u8x8, 0x011 ); /* cursor increment mode */ u8x8_cad_SendArg(u8x8, 3); u8x8_cad_SendCmd(u8x8, 0x045 ); /* window start column */ u8x8_cad_SendArg(u8x8, 0); u8x8_cad_SendArg(u8x8, 179); /* end of display */ u8x8_cad_SendCmd(u8x8, 0x044 ); /* window end page */ u8x8_cad_SendArg(u8x8, page); u8x8_cad_SendArg(u8x8, page+1); u8x8_cad_SendCmd(u8x8, 0x04f ); /* window column */ u8x8_cad_SendArg(u8x8, x); u8x8_cad_SendCmd(u8x8, 0x04e ); /* window row */ u8x8_cad_SendArg(u8x8, page); u8x8_cad_SendCmd(u8x8, 0x024 ); do { c = ((u8x8_tile_t *)arg_ptr)->cnt; ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; do { u8x8_cad_SendData(u8x8, 16, u8x8_convert_tile_for_ssd1606(ptr)); ptr += 8; x += 8; c--; } while( c > 0 ); arg_int--; } while( arg_int > 0 ); u8x8_cad_EndTransfer(u8x8); }
static uint8_t u8x8_d_ssd1309_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { uint8_t x, c; uint8_t *ptr; switch(msg) { case U8X8_MSG_DISPLAY_DRAW_TILE: u8x8_cad_StartTransfer(u8x8); x = ((u8x8_tile_t *)arg_ptr)->x_pos; x *= 8; x += u8x8->x_offset; u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos) ); do { c = ((u8x8_tile_t *)arg_ptr)->cnt; ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */ /* do { u8x8_cad_SendData(u8x8, 8, ptr); ptr += 8; c--; } while( c > 0 ); */ arg_int--; } while( arg_int > 0 ); u8x8_cad_EndTransfer(u8x8); break; case U8X8_MSG_DISPLAY_SET_POWER_SAVE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_powersave0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1309_powersave1_seq); break; #ifdef U8X8_WITH_SET_CONTRAST case U8X8_MSG_DISPLAY_SET_CONTRAST: u8x8_cad_StartTransfer(u8x8); u8x8_cad_SendCmd(u8x8, 0x081 ); u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1309 has range from 0 to 255 */ u8x8_cad_EndTransfer(u8x8); break; #endif default: return 0; } return 1; }
uint8_t u8x8_d_uc1604_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { uint8_t x, y, c; uint8_t *ptr; switch(msg) { case U8X8_MSG_DISPLAY_DRAW_TILE: u8x8_cad_StartTransfer(u8x8); x = ((u8x8_tile_t *)arg_ptr)->x_pos; x *= 8; u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); y = ((u8x8_tile_t *)arg_ptr)->y_pos; y += u8x8->x_offset; u8x8_cad_SendCmd(u8x8, 0x0b0 | (y&15)); c = ((u8x8_tile_t *)arg_ptr)->cnt; c *= 8; ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; do { u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */ arg_int--; } while( arg_int > 0 ); u8x8_cad_EndTransfer(u8x8); break; /* handled in the calling procedure case U8X8_MSG_DISPLAY_SETUP_MEMORY: u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1604_128x64_display_info); break; case U8X8_MSG_DISPLAY_INIT: u8x8_d_helper_display_init(u8x8); u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq); break; */ case U8X8_MSG_DISPLAY_SET_POWER_SAVE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_powersave0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_powersave1_seq); break; case U8X8_MSG_DISPLAY_SET_FLIP_MODE: if ( arg_int == 0 ) { u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_flip0_seq); u8x8->x_offset = u8x8->display_info->default_x_offset; } else { u8x8_cad_SendSequence(u8x8, u8x8_d_uc1604_flip1_seq); u8x8->x_offset = u8x8->display_info->flipmode_x_offset; } break; #ifdef U8X8_WITH_SET_CONTRAST case U8X8_MSG_DISPLAY_SET_CONTRAST: u8x8_cad_StartTransfer(u8x8); u8x8_cad_SendCmd(u8x8, 0x081 ); u8x8_cad_SendArg(u8x8, arg_int ); /* uc1604 has range from 0 to 255 */ u8x8_cad_EndTransfer(u8x8); break; #endif default: return 0; } return 1; }
static uint8_t u8x8_d_sh1107_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { uint8_t x, c; uint8_t *ptr; switch(msg) { /* handled by the calling function case U8X8_MSG_DISPLAY_SETUP_MEMORY: u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sh1107_64x128_noname_display_info); break; */ /* handled by the calling function case U8X8_MSG_DISPLAY_INIT: u8x8_d_helper_display_init(u8x8); u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_init_seq); break; */ case U8X8_MSG_DISPLAY_SET_POWER_SAVE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_powersave1_seq); break; case U8X8_MSG_DISPLAY_SET_FLIP_MODE: if ( arg_int == 0 ) { u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip0_seq); u8x8->x_offset = u8x8->display_info->default_x_offset; } else { u8x8_cad_SendSequence(u8x8, u8x8_d_sh1107_64x128_noname_flip1_seq); u8x8->x_offset = u8x8->display_info->flipmode_x_offset; } break; #ifdef U8X8_WITH_SET_CONTRAST case U8X8_MSG_DISPLAY_SET_CONTRAST: u8x8_cad_StartTransfer(u8x8); u8x8_cad_SendCmd(u8x8, 0x081 ); u8x8_cad_SendArg(u8x8, arg_int ); /* sh1107 has range from 0 to 255 */ u8x8_cad_EndTransfer(u8x8); break; #endif case U8X8_MSG_DISPLAY_DRAW_TILE: u8x8_cad_StartTransfer(u8x8); x = ((u8x8_tile_t *)arg_ptr)->x_pos; x *= 8; x += u8x8->x_offset; //u8x8_cad_SendCmd(u8x8, 0x040 ); /* set line offset to 0 */ // set column address u8x8_cad_SendCmd(u8x8, 0x010 | (x >> 4)); u8x8_cad_SendCmd(u8x8, 0x000 | ((x & 15))); /* probably wrong, should be SendCmd */ // set page address u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); /* probably wrong, should be SendCmd */ do { c = ((u8x8_tile_t *)arg_ptr)->cnt; ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */ /* do { u8x8_cad_SendData(u8x8, 8, ptr); ptr += 8; c--; } while( c > 0 ); */ arg_int--; } while( arg_int > 0 ); u8x8_cad_EndTransfer(u8x8); break; default: return 0; } return 1; }
static uint8_t u8x8_d_ssd1326_256x32_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { uint8_t x, y, c; uint8_t *ptr; switch(msg) { /* handled by the calling function case U8X8_MSG_DISPLAY_SETUP_MEMORY: u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ssd1326_256x32_nhd_display_info); break; */ case U8X8_MSG_DISPLAY_INIT: u8x8_d_helper_display_init(u8x8); u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_er_256x32_init_seq); break; case U8X8_MSG_DISPLAY_SET_POWER_SAVE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_powersave0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_powersave1_seq); break; case U8X8_MSG_DISPLAY_SET_FLIP_MODE: if ( arg_int == 0 ) { u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_flip0_seq); u8x8->x_offset = u8x8->display_info->default_x_offset; } else { u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1326_256x32_nhd_flip1_seq); u8x8->x_offset = u8x8->display_info->flipmode_x_offset; } break; #ifdef U8X8_WITH_SET_CONTRAST case U8X8_MSG_DISPLAY_SET_CONTRAST: u8x8_cad_StartTransfer(u8x8); u8x8_cad_SendCmd(u8x8, 0x081 ); u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1326 has range from 0 to 255 */ u8x8_cad_EndTransfer(u8x8); break; #endif case U8X8_MSG_DISPLAY_DRAW_TILE: u8x8_cad_StartTransfer(u8x8); x = ((u8x8_tile_t *)arg_ptr)->x_pos; x *= 4; y = (((u8x8_tile_t *)arg_ptr)->y_pos); y *= 8; y += u8x8->x_offset; /* x_offset is used as y offset for the ssd1326 */ do { c = ((u8x8_tile_t *)arg_ptr)->cnt; ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; do { /* tile is empty, use the graphics acceleration command */ /* are this really available on the ssd1326??? */ u8x8_cad_SendCmd(u8x8, 0x024 ); // draw rectangle u8x8_cad_SendArg(u8x8, x ); u8x8_cad_SendArg(u8x8, y ); u8x8_cad_SendArg(u8x8, x+3 ); u8x8_cad_SendArg(u8x8, y+7 ); u8x8_cad_SendArg(u8x8, 0 ); // clear ptr += 8; x += 4; c--; } while( c > 0 ); //x += 4; arg_int--; } while( arg_int > 0 ); u8x8_cad_EndTransfer(u8x8); break; default: return 0; } return 1; }
uint8_t u8x8_d_t6963_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { uint8_t c, i; uint16_t y; uint8_t *ptr; switch(msg) { /* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */ /* case U8X8_MSG_DISPLAY_SETUP_MEMORY: break; case U8X8_MSG_DISPLAY_INIT: break; */ case U8X8_MSG_DISPLAY_SET_POWER_SAVE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_powersave0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_t6963_powersave1_seq); break; case U8X8_MSG_DISPLAY_DRAW_TILE: y = (((u8x8_tile_t *)arg_ptr)->y_pos); y*=8; y*= u8x8->display_info->tile_width; /* x = ((u8x8_tile_t *)arg_ptr)->x_pos; x is ignored... no u8x8 support */ //u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */ u8x8_cad_StartTransfer(u8x8); //u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */ /* Tile structure is reused here for the t6963, however u8x8 is not supported tile_ptr points to data which has cnt*8 bytes (same as SSD1306 tiles) Buffer is expected to have 8 lines of code fitting to the t6963 internal memory "cnt" includes the number of horizontal bytes. width is equal to cnt*8 TODO: Consider arg_int, however arg_int is not used by u8g2 */ c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */ ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */ for( i = 0; i < 8; i++ ) { u8x8_cad_SendArg(u8x8, y&255); u8x8_cad_SendArg(u8x8, y>>8); u8x8_cad_SendCmd(u8x8, 0x024 ); /* set adr */ u8x8_cad_SendCmd(u8x8, 0x0b0 ); /* auto write start */ //c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */ u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes, send one line of data */ u8x8_cad_SendCmd(u8x8, 0x0b2 ); /* auto write reset */ ptr += u8x8->display_info->tile_width; y += u8x8->display_info->tile_width; } u8x8_cad_EndTransfer(u8x8); //u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_NANO, 200, NULL); /* extra dely required */ break; default: return 0; } return 1; }
uint8_t u8x8_d_ssd1306_128x64_noname(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) { uint8_t x, c; uint8_t *ptr; switch(msg) { case U8X8_MSG_DISPLAY_INIT: u8x8_d_helper_display_init(u8x8, &u8x8_ssd1306_128x64_noname_display_info); u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_init_seq); break; case U8X8_MSG_DISPLAY_SET_POWER_SAVE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_powersave1_seq); break; #ifdef U8X8_WITH_SET_FLIP_MODE case U8X8_MSG_DISPLAY_SET_FLIP_MODE: if ( arg_int == 0 ) u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip0_seq); else u8x8_cad_SendSequence(u8x8, u8x8_d_ssd1306_128x64_noname_flip1_seq); break; #endif #ifdef U8X8_WITH_SET_CONTRAST case U8X8_MSG_DISPLAY_SET_CONTRAST: u8x8_cad_StartTransfer(u8x8); u8x8_cad_SendCmd(u8x8, 0x081 ); u8x8_cad_SendArg(u8x8, arg_int ); /* ssd1306 has range from 0 to 255 */ u8x8_cad_EndTransfer(u8x8); break; #endif case U8X8_MSG_DISPLAY_DRAW_TILE: u8x8_cad_StartTransfer(u8x8); x = ((u8x8_tile_t *)arg_ptr)->x_pos; x *= 8; x += u8x8->x_offset; u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) ); u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15))); u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos)); do { c = ((u8x8_tile_t *)arg_ptr)->cnt; ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; do { u8x8_cad_SendData(u8x8, 8, ptr); ptr += 8; c--; } while( c > 0 ); arg_int--; } while( arg_int > 0 ); u8x8_cad_EndTransfer(u8x8); break; default: return 0; } return 1; }