This commit is contained in:
kraus 2020-04-19 09:08:43 +02:00
parent 371de80a8d
commit 5f3ccbd289
2 changed files with 98 additions and 70 deletions

View File

@ -41,7 +41,8 @@
static const uint8_t u8x8_d_uc1617_powersave0_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
U8X8_C(0x0ad), /* display on */
//U8X8_C(0x0ad), /* display enable BW Mode*/
U8X8_C(0x0af), /* display enable GS Mode*/
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
@ -55,18 +56,61 @@ static const uint8_t u8x8_d_uc1617_powersave1_seq[] = {
static const uint8_t u8x8_d_uc1617_flip0_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
//U8X8_C(0x0c2), /* LCD Mapping */
U8X8_C(0x0c0), /* LCD Mapping */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
static const uint8_t u8x8_d_uc1617_flip1_seq[] = {
U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
//U8X8_C(0x0c4), /* LCD Mapping */
U8X8_C(0x0c6), /* LCD Mapping */
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */
};
//static uint8_t u8x8_upscale_4bit(uint8_t x) U8X8_NOINLINE;
static uint8_t u8x8_upscale_4bit(uint8_t x)
{
uint8_t y = x;
y |= (y << 4); // x = (x | (x << S[2])) & B[2];
y &= 0x0f;
y |= (y << 2); // x = (x | (x << S[1])) & B[1];
y &= 0x33;
y |= (y << 1); // x = (x | (x << S[0])) & B[0];
y &= 0x55;
y |= (y << 1); // z = x | (y << 1);
return y;
}
static uint8_t u8x8_uc1617_tile_half_buffer[8];
static uint8_t *u8x8_convert_tile_for_uc1617_lower4bit(uint8_t *t)
{
uint8_t i;
uint8_t *pbuf = u8x8_uc1617_tile_half_buffer;
for( i = 0; i < 8; i++ )
{
*pbuf++ = u8x8_upscale_4bit(*t++);
}
return u8x8_uc1617_tile_half_buffer;
}
static uint8_t *u8x8_convert_tile_for_uc1617_upper4bit(uint8_t *t)
{
uint8_t i;
uint8_t *pbuf = u8x8_uc1617_tile_half_buffer;
for( i = 0; i < 8; i++ )
{
*pbuf++ = u8x8_upscale_4bit((*t++)>>4);
}
return u8x8_uc1617_tile_half_buffer;
}
#ifdef NOT_USED
static uint8_t *u8x8_convert_tile_for_uc1617(uint8_t *t)
{
uint8_t i;
@ -85,73 +129,79 @@ static uint8_t *u8x8_convert_tile_for_uc1617(uint8_t *t)
}
return buf;
}
#endif
uint8_t u8x8_d_uc1617_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
uint8_t x, y, c;
uint8_t x, y, c, a;
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;
y = ((u8x8_tile_t *)arg_ptr)->y_pos;
y*=2;
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
x *= 8;
x += u8x8->x_offset;
u8x8_cad_SendCmd(u8x8, 0x060 | (x&15));
u8x8_cad_SendCmd(u8x8, 0x070 | (x>>4));
u8x8_cad_SendCmd(u8x8, 0x00 | (y));
#ifdef NOT_REQUIRED
u8x8_cad_SendCmd(u8x8, 0xf8 ); /* disable window */
u8x8_cad_SendCmd(u8x8, 0xf4 ); /* page start */
u8x8_cad_SendCmd(u8x8, y );
u8x8_cad_SendCmd(u8x8, 0xf5 ); /* x start */
u8x8_cad_SendCmd(u8x8, x );
u8x8_cad_SendCmd(u8x8, 0xf6 ); /* page end */
u8x8_cad_SendCmd(u8x8, y );
u8x8_cad_SendCmd(u8x8, 0xf7 ); /* x end */
u8x8_cad_SendCmd(u8x8, 127 );
u8x8_cad_SendCmd(u8x8, 0xf9 ); /* enable window */
#endif
a = arg_int;
do
{
c = ((u8x8_tile_t *)arg_ptr)->cnt;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
do
{
u8x8_cad_SendCmd(u8x8, 0x060 | (x&15));
u8x8_cad_SendCmd(u8x8, 0x070 | (x>>4));
u8x8_cad_SendCmd(u8x8, 0x00 | (y));
u8x8_cad_SendCmd(u8x8, 0xf8 ); /* disable window */
u8x8_cad_SendCmd(u8x8, 0xf4 ); /* page start */
u8x8_cad_SendCmd(u8x8, y );
u8x8_cad_SendCmd(u8x8, 0xf5 ); /* x start */
u8x8_cad_SendCmd(u8x8, x );
u8x8_cad_SendCmd(u8x8, 0xf6 ); /* page end */
u8x8_cad_SendCmd(u8x8, y+1 );
u8x8_cad_SendCmd(u8x8, 0xf7 ); /* x end */
u8x8_cad_SendCmd(u8x8, x+7 );
u8x8_cad_SendCmd(u8x8, 0xf9 ); /* enable window */
u8x8_cad_SendData(u8x8, 16, u8x8_convert_tile_for_uc1617(ptr));
u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_uc1617_lower4bit(ptr));
ptr += 8;
x += 8;
c--;
} while( c > 0 );
arg_int--;
} while( arg_int > 0 );
/*
c = ((u8x8_tile_t *)arg_ptr)->cnt;
c *= 8;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
} while( c > 0 );
a--;
} while( a > 0 );
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
x *= 8;
x += u8x8->x_offset;
u8x8_cad_SendCmd(u8x8, 0x060 | (x&15));
u8x8_cad_SendCmd(u8x8, 0x070 | (x>>4));
u8x8_cad_SendCmd(u8x8, 0x00 | (y+1));
a = arg_int;
do
{
u8x8_cad_SendData(u8x8, c, ptr);
arg_int--;
} while( arg_int > 0 );
*/
c = ((u8x8_tile_t *)arg_ptr)->cnt;
ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
do
{
u8x8_cad_SendData(u8x8, 8, u8x8_convert_tile_for_uc1617_upper4bit(ptr));
ptr += 8;
x += 8;
c--;
} while( c > 0 );
a--;
} while( a > 0 );
u8x8_cad_EndTransfer(u8x8);
break;
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
@ -202,7 +252,7 @@ static const uint8_t u8x8_d_uc1617_jlx128128_init_seq[] = {
U8X8_C(0x02f), /* internal pump control */
U8X8_C(0x0eb), /* bias=1/11 */
U8X8_CA(0x081, 0x036), /* set contrast */
U8X8_CA(0x081, 0x028), /* set contrast */
//U8X8_C(0x0a9), /* used in display datasheet, but cmd not described in controller datasheet */
U8X8_CA(0x0f1, 0x07f), /* set COM end */
@ -213,37 +263,15 @@ static const uint8_t u8x8_d_uc1617_jlx128128_init_seq[] = {
U8X8_C(0x0d3), /* */
U8X8_C(0x0d7), /* */
//U8X8_C(0x0ad), /* display enable BW Mode*/
U8X8_C(0x0af), /* display enable GS Mode*/
//U8X8_C(0x0a5), /* all pixel on */
//U8X8_C(0x0d1), /* display pattern */
U8X8_C(0x08b), /* auto increment */
U8X8_C(0x0c0), /* LCD Mapping */
U8X8_C(0x000), /* column */
U8X8_C(0x060), /* page adr low */
U8X8_C(0x070), /* page adr high */
/*
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
U8X8_D1(0x0ff),
*/
//U8X8_C(0x0ad), /* display enable BW Mode*/
//U8X8_C(0x0af), /* display enable GS Mode*/
U8X8_END_TRANSFER(), /* disable chip */
U8X8_END() /* end of sequence */

View File

@ -211,7 +211,7 @@
//U8X8_UC1611_EW50850_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high
//U8X8_UC1611_CG160160_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc
//U8X8_UC1617_JLX128128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
U8X8_UC1617_JLX128128_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8X8_UC1617_JLX128128_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8X8_UC1638_160X128_4W_HW_SPI u8x8(/* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested
//U8X8_SSD1606_172X72_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display
//U8X8_SSD1607_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists