Display refresh Latency

Status
Not open for further replies.

Svenson

Member
Hi,
i'm working with Teensy 4.0 connected via USB to my PC. I'm newbie in firmware develop, sorry if it's a stupid question.

PC and Teensy are communicating correctly and the speed of communication is good.
I decide to connect a little display (128x64) via i2c using <Adafruit_GFX.h> <Adafruit_SSD1306.h> driver.

After this I noticed a big slowdown in the communication. So I would to understand if there is a best practice to manage a display refresh in order to mantein a good serial communication speed.


This is the easy code that I'm testing

//Setup
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}



//LOOP
display.clearDisplay(); //Pulisce il buffer da inviare al display
display.setCursor(0,0); //Imposta la posizione del cursore (Larghezza,Altezza)
display.println("BERNIE"); //Stringa da visualizzare
int gain = gain_rotary.getValue();
display.print("GAIN: ");
display.println(gain);
display.display();



Is there a best practice to manage a display refresh? dedicated thread? Or other solution? Asynch method!?

I just think to move on a SPI Display to increase the communication speed.


Andre
 
Using 1MHz I2C speed, a 50% ping-pong buffer and DMA (with a self-tuned version of the i2c_t3 library and hand written rendering code instead of using a gfx lib with overhead), I could get a refresh rate of a little more than 60fps on a 128x64 OLED with a Teensy LC. Thus, it should also be possible with a Teensy 4. But since your eyes are not infinitively speedy and will not be able to read so many updates of the gain value, I think that you should rather use a 100-200ms interval timer to update the display at 5-10fps (which is sufficient) outside the loop(), so that the latter may turn more often for other tasks.
 
Using 1MHz I2C speed, a 50% ping-pong buffer and DMA (with a self-tuned version of the i2c_t3 library and hand written rendering code instead of using a gfx lib with overhead), I could get a refresh rate of a little more than 60fps on a 128x64 OLED with a Teensy LC. Thus, it should also be possible with a Teensy 4. But since your eyes are not infinitively speedy and will not be able to read so many updates of the gain value, I think that you should rather use a 100-200ms interval timer to update the display at 5-10fps (which is sufficient) outside the loop(), so that the latter may turn more often for other tasks.

Sadly i2c_t3 not updated yet to work on T_4.x's :(

The adaF SSD1306 does have a param for i2c speed to be used though - that makes a difference. Not sure if Wire max was pushed past 2 MHz? But it goes higher than the default speed ... but is still blocking until done.

@mjs513 had new clock values in beta that pushed the high end on Wire and worked at 3-4 Mhz - but it pushed up the min speed available and that never got resolved/pulled in IIRC.
 
I've also encountered this. Not in terms of 'my eyes seeing it', but some other things not running as fast as they should. I'm using it together with audio output and that is more prone to latency that is noticeable. What I concluded was that you should try to avoid the 'clear display' function (takes over 20ms) and just print stuff to the screen when needed (i.e. when something needs to change on the display).
 
Status
Not open for further replies.
Back
Top