introduction of improved ssd13xx i2c cad procedure (fast_i2c) #735

This commit is contained in:
kraus 2018-12-20 20:14:45 +01:00
parent 9f0ecf24e9
commit 4efa313040
4 changed files with 101 additions and 8 deletions

View File

@ -631,6 +631,7 @@ uint8_t u8x8_cad_011(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_100(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_st7920_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_ssd13xx_fast_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_st75256_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_st75256_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_ld7032_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_ld7032_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_uc16xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);

View File

@ -407,6 +407,7 @@ static void u8x8_i2c_data_transfer(u8x8_t *u8x8, uint8_t arg_int, void *arg_ptr)
u8x8_byte_EndTransfer(u8x8); u8x8_byte_EndTransfer(u8x8);
} }
/* classic version: will put a start/stop condition around each command and arg */
uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{ {
uint8_t *p; uint8_t *p;
@ -456,6 +457,83 @@ uint8_t u8x8_cad_ssd13xx_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
return 1; return 1;
} }
/* fast version with reduced data start/stops, issue 735 */
uint8_t u8x8_cad_ssd13xx_fast_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
static uint8_t in_transfer = 0;
uint8_t *p;
switch(msg)
{
case U8X8_MSG_CAD_SEND_CMD:
/* improved version, takeover from ld7032 */
/* assumes, that the args of a command is not longer than 31 bytes */
/* speed improvement is about 4% compared to the classic version */
if ( in_transfer != 0 )
u8x8_byte_EndTransfer(u8x8);
u8x8_byte_StartTransfer(u8x8);
u8x8_byte_SendByte(u8x8, 0x000); /* cmd byte for ssd13xx controller */
u8x8_byte_SendByte(u8x8, arg_int);
in_transfer = 1;
/* lightning version: can replace the improved version from above */
/* the drawback of the lightning version is this: The complete init sequence */
/* must fit into the 32 byte Arduino Wire buffer, wbich might not always be the case */
/* speed improvement is about 6% compared to the classic version */
// if ( in_transfer == 0 )
// {
// u8x8_byte_StartTransfer(u8x8);
// u8x8_byte_SendByte(u8x8, 0x000); /* cmd byte for ssd13xx controller */
// in_transfer = 1;
// }
//u8x8_byte_SendByte(u8x8, arg_int);
break;
case U8X8_MSG_CAD_SEND_ARG:
u8x8_byte_SendByte(u8x8, arg_int);
break;
case U8X8_MSG_CAD_SEND_DATA:
if ( in_transfer != 0 )
u8x8_byte_EndTransfer(u8x8);
/* the FeatherWing OLED with the 32u4 transfer of long byte */
/* streams was not possible. This is broken down to */
/* smaller streams, 32 seems to be the limit... */
/* I guess this is related to the size of the Wire buffers in Arduino */
/* Unfortunately, this can not be handled in the byte level drivers, */
/* so this is done here. Even further, only 24 bytes will be sent, */
/* because there will be another byte (DC) required during the transfer */
p = arg_ptr;
while( arg_int > 24 )
{
u8x8_i2c_data_transfer(u8x8, 24, p);
arg_int-=24;
p+=24;
}
u8x8_i2c_data_transfer(u8x8, arg_int, p);
in_transfer = 0;
break;
case U8X8_MSG_CAD_INIT:
/* apply default i2c adr if required so that the start transfer msg can use this */
if ( u8x8->i2c_address == 255 )
u8x8->i2c_address = 0x078;
return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
case U8X8_MSG_CAD_START_TRANSFER:
in_transfer = 0;
break;
case U8X8_MSG_CAD_END_TRANSFER:
if ( in_transfer != 0 )
u8x8_byte_EndTransfer(u8x8);
in_transfer = 0;
break;
default:
return 0;
}
return 1;
}
/* the st75256 i2c driver is a copy of the ssd13xx driver, but with arg=1 */ /* the st75256 i2c driver is a copy of the ssd13xx driver, but with arg=1 */
/* modified from cad001 (ssd13xx) to cad011 */ /* modified from cad001 (ssd13xx) to cad011 */
uint8_t u8x8_cad_st75256_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) uint8_t u8x8_cad_st75256_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)

View File

@ -153,7 +153,13 @@
Uno U8G2_ST7920_128X64_F_HW_SPI HW SPI 1.8MHz FPS: Clip=23.0 Box=22.8 @=7.4 Pix=10.4 Uno U8G2_ST7920_128X64_F_HW_SPI HW SPI 1.8MHz FPS: Clip=23.0 Box=22.8 @=7.4 Pix=10.4
Uno U8G2_ST7920_128X64_F_SW_SPI SW SPI FPS: Clip=22.7 Box=21.0 @=7.1 Pix=9.6 Uno U8G2_ST7920_128X64_F_SW_SPI SW SPI FPS: Clip=22.7 Box=21.0 @=7.1 Pix=9.6
Due U8G2_ST7920_128X64_F_SW_SPI SW SPI FPS: Clip=3.3 Box=3.2 @=3.1 Pix=3.1 Due U8G2_ST7920_128X64_F_SW_SPI SW SPI FPS: Clip=3.3 Box=3.2 @=3.1 Pix=3.1
Due U8G2_ST7920_128X64_F_SW_SPI SW SPI FPS: Clip=18.0 Box=17.8 @=13.5 Pix=14.6 /* Due optimized, 1000ns */ Due U8G2_ST7920_128X64_F_SW_SPI SW SPI FPS: Clip=18.0 Box=17.8 @=13.5 Pix=14.6 Due optimized, 1000ns
20 Dec 2018
Uno U8G2_SSD1306_128X64_NONAME_F_SW_I2C SW I2C FPS: Clip=1.8 Box=1.9 @=1.6 Pix=1.7
Uno U8G2_SSD1306_128X64_NONAME_F_HW_I2C HW I2C FPS: Clip=17.3 Box=19.5 @=6.6 Pix=8.8 old SSD13xx cad procedure
Uno U8G2_SSD1306_128X64_NONAME_F_HW_I2C HW I2C FPS: Clip=18.0 Box=20.3 @=6.6 Pix=9.0 new SSD13xx cad procedure
Uno U8G2_SSD1306_128X64_NONAME_F_HW_I2C HW I2C FPS: Clip=18.3 Box=20.8 @=6.7 Pix=9.1 new SSD13xx cad procedure (lightning version)
*/ */
@ -184,7 +190,7 @@
//U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition)
//U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
//U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the "every 2nd line skipped" problem //U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the "every 2nd line skipped" problem
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display

View File

@ -2,6 +2,14 @@
generate and update c/c++ files generate and update c/c++ files
this also replaces the buildcpp tool this also replaces the buildcpp tool
Dec 2018:
There are now two SSD13xx cad procedures:
u8x8_cad_ssd13xx_i2c Put a I2C start/stop around each command and each argument --> many start/stop commands
u8x8_cad_ssd13xx_fast_i2c Put a I2C start/stop around each command+arg sequence --> start/stop is probably halfed --> 4% faster
*/ */
@ -119,7 +127,7 @@ struct controller controller_list[] =
} }
}, },
{ {
"ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, "ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1, "", /* is_generate_u8g2_class= */ 1,
{ {
{ "128x64_noname" }, { "128x64_noname" },
@ -278,7 +286,7 @@ struct controller controller_list[] =
} }
}, },
{ {
"ssd1306", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, "ssd1306", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1, "", /* is_generate_u8g2_class= */ 1,
{ {
{ "128x32_univision" }, { "128x32_univision" },
@ -295,7 +303,7 @@ struct controller controller_list[] =
} }
}, },
{ {
"ssd1306", 8, 6, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, "ssd1306", 8, 6, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1, "", /* is_generate_u8g2_class= */ 1,
{ {
{ "64x48_er" }, { "64x48_er" },
@ -312,7 +320,7 @@ struct controller controller_list[] =
} }
}, },
{ {
"ssd1306", 6, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, "ssd1306", 6, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1, "", /* is_generate_u8g2_class= */ 1,
{ {
{ "48x64_winstar" }, { "48x64_winstar" },
@ -331,7 +339,7 @@ struct controller controller_list[] =
} }
}, },
{ {
"ssd1306", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, "ssd1306", 8, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1, "", /* is_generate_u8g2_class= */ 1,
{ {
{ "64x32_noname" }, { "64x32_noname" },
@ -349,7 +357,7 @@ struct controller controller_list[] =
} }
}, },
{ {
"ssd1306", 12, 2, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, "ssd1306", 12, 2, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_fast_i2c", "i2c", COM_I2C,
"", /* is_generate_u8g2_class= */ 1, "", /* is_generate_u8g2_class= */ 1,
{ {
{ "96x16_er" }, { "96x16_er" },