U8G2 runs very slowly

colinives
Posts: 37
Joined: Tue Mar 03, 2020 2:53 pm

U8G2 runs very slowly

Postby colinives » Tue Mar 09, 2021 5:26 pm

So, the good news what the driver problem has been solved but, as is often the way, things move forward then hold!

I'm running a 128x64 OLED with SPI

For testing, I'm drawing a 10 pixel circle and moving on one pixel every loop - I started with a delay but have now removed it:

The problem I'm having now is that the draw speed is very, very slow - one circle a second running on an ESP32 with Freertos. Its so slow you can see it writing the circle!

Code: Select all

	u8g2_t u8g2; 
		u8g2_Setup_ssd1306_128x64_noname_f(
		&u8g2,
		U8G2_R0,
		u8g2_esp32_spi_byte_cb,
		u8g2_esp32_gpio_and_delay_cb); 


	u8g2_InitDisplay(&u8g2); // send init sequence to the display, display is in sleep mode after this,

	u8g2_SetPowerSave(&u8g2, 0); // wake up display
	int intXPos = 0;
		u8g2_ClearBuffer(&u8g2);
	u8g2_DrawCircle(&u8g2, 32,intXPos, 10,U8G2_DRAW_ALL);
	u8g2_SetFont(&u8g2, u8g2_font_ncenB14_tr);
	u8g2_DrawStr(&u8g2, 0,15,"Hello Colin!");

	while(true){
	u8g2_ClearBuffer(&u8g2);
	u8g2_DrawCircle(&u8g2, intXPos,32, 10,U8G2_DRAW_ALL);
	u8g2_SendBuffer(&u8g2);
	intXPos +=1;
	if (intXPos>100) intXPos = 0;
	//vTaskDelay(10/ portTICK_PERIOD_MS);
}
Your thoughts/ideas on why this is happening would be very welcome. Runs a dream on Arduino (SPI)

colinives
Posts: 37
Joined: Tue Mar 03, 2020 2:53 pm

Re: U8G2 runs very slowly

Postby colinives » Tue Mar 16, 2021 9:08 am

"Doh"

Of course the clock rate was set to only 50khz - no wonder it was running slow. I guess I didn't check there because it didn't occur to me it would bet set at walking pace. Ho Hum

The solution is in the u8g2_es32_hal.c:

Was:
dev_config.clock_speed_hz = 50000;

Changed to:
u8gv_config.clock_speed_hz = 10000000;

Who is online

Users browsing this forum: Google [Bot] and 84 guests