Skip to content

Commit

Permalink
issue #884
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed May 3, 2019
1 parent 0aac090 commit 67a6b5c
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions csrc/u8x8.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ uint8_t u8x8_d_uc1610_ea_dogxl160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, vo
uint8_t u8x8_d_uc1611_ea_dogm240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1611_ea_dogxl240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1611_ew50850(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* 240x160 */
uint8_t u8x8_d_uc1611_cg160160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /* 160x160 */
uint8_t u8x8_d_uc1617_jlx128128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_uc1638_160x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_d_ks0108_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
Expand Down
102 changes: 102 additions & 0 deletions csrc/u8x8_d_uc1611.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,105 @@ uint8_t u8x8_d_uc1611_ew50850(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
}
return 1;
}


/*================================================*/
/* CG160160D, http://www.cloverdisplay.com/pdf/CG160160D.pdf */

/*
UC1611 has two chip select inputs (CS0 and CS1).
CS0 is low active, CS1 is high active. It will depend on the display
module whether the display has a is low or high active chip select.
Connect CS1 to 3.3V and CS0 to GPIO
*/

static const u8x8_display_info_t u8x8_uc1611_cg160160_display_info =
{
/* chip_enable_level = */ 0, /* use CS0 of the UC1611 */
/* chip_disable_level = */ 1,

/* post_chip_enable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
/* pre_chip_disable_wait_ns = */ 10, /* uc1611 datasheet, page 60, actually 0 */
/* reset_pulse_width_ms = */ 1,
/* post_reset_wait_ms = */ 10, /* uc1611 datasheet, page 67 */
/* sda_setup_time_ns = */ 10, /* uc1611 datasheet, page 64, actually 0 */
/* sck_pulse_width_ns = */ 60, /* half of cycle time */
/* sck_clock_hz = */ 8000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
/* spi_mode = */ 0, /* active high, rising edge */
/* i2c_bus_clock_100kHz = */ 4,
/* data_setup_time_ns = */ 30, /* uc1611 datasheet, page 60 */
/* write_pulse_width_ns = */ 80, /* uc1611 datasheet, page 60 */
/* tile_width = */ 20, /* width of 20*8=160 pixel */
/* tile_hight = */ 20,
/* default_x_offset = */ 0,
/* flipmode_x_offset = */ 0,
/* pixel_width = */ 160,
/* pixel_height = */ 160
};

static const uint8_t u8x8_d_uc1611_cg160160_init_seq[] = {

U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x02f), /* internal pump control */
U8X8_CA(0x0f1, 63), /* set COM end */
U8X8_CA(0x0f2, 0x000), /* display line start */
U8X8_CA(0x0f3, 63), /* display line end */
U8X8_C(0x0a3), /* line rate */
U8X8_CA(0x081, 0x0a4), /* set contrast, EA default: 0x0b7 */

//U8X8_C(0x0a9), /* display enable */

U8X8_C(0x0d1), /* display pattern */
U8X8_C(0x089), /* auto increment */
U8X8_CA(0x0c0, 0x004), /* LCD Mapping */
U8X8_C(0x000), /* column low nibble */
U8X8_C(0x010), /* column high nibble */
U8X8_C(0x060), /* page adr low */
U8X8_C(0x070), /* page adr high */


U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};

/* cg160160 display */
uint8_t u8x8_d_uc1611_cg160160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
/* call common procedure first and handle messages there */
if ( u8x8_d_uc1611_common(u8x8, msg, arg_int, arg_ptr) == 0 )
{
/* msg not handled, then try here */
switch(msg)
{
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1611_cg160160_display_info);
break;
case U8X8_MSG_DISPLAY_INIT:
u8x8_d_helper_display_init(u8x8);
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611_cg160160_init_seq);
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
if ( arg_int == 0 )
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave0_seq);
else
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_powersave1_seq);
break;
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
if ( arg_int == 0 )
{
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip0_seq);
u8x8->x_offset = u8x8->display_info->default_x_offset;
}
else
{
u8x8_cad_SendSequence(u8x8, u8x8_d_uc1611s_flip1_seq);
u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
}
break;
default:
return 0; /* msg unknown */
}
}
return 1;
}

0 comments on commit 67a6b5c

Please sign in to comment.