greiman / SSD1306Ascii

Text only Arduino Library for SSD1306 OLED displays
MIT License
490 stars 120 forks source link

When using the ssd1306AvrI2c library, the avr hangs indefinitely #117

Open jonathanmlang opened 6 months ago

jonathanmlang commented 6 months ago

This happens when noise occurs on the i2c lines or the display is disconnected. Only way out is to reset. This problem can be dealt with in the wire library variant using wire.setWireTimeout(). But there doesnt seem to be a version to use with your avri2c library. I prefer using it as well because its so much faster than wire and would like to get it working well. Thanks in advance.

greiman commented 6 months ago

There is a timeout loop in AvrI2c but it takes too long.

The loop count is here.

I tried changing the 0XFFFF to 0XFF and examples using AvrI2c still seems to work.

The AvrI2c128x64 example runs in about 341 ms with the shorter timeout if you remove the display. It runs in 71 ms with the display.

A major problem is lack of status returns from member functions. I just don't have time now to add functionality to my Arduino libraries.

jonathanmlang commented 4 months ago

Ive just tried this, the program no longer hangs but the display continues to remain frozen. Is there a way of triggering a reinitialisation routine for the display when this occurs? like running oled.end() then oled.begin()?

greiman commented 4 months ago

I can't help much since I don't have the hardware here with the problem.

Some I2C displays have a reset pin. I have not been able to find a software reset command, Some posts on the internet claim the command 0XE4 does a reset for their display.

There are lots of posts on the internet looking for a solution to reset for I2C displays.

If the I2C controller is hung, it might be possible to reset it with an call to the end() function here.

I don't have an end() function in SSD1306Ascii since I don't know what it should do since there is no reset command.

what happens if you call oled.begin() when it hangs.

jonathanmlang commented 4 months ago

Well my display has no reset pin however resetting the arduino board does bring the display back to life. All im doing here to recreate the issue is with an ssd1306 and me pulling one of the i2c wires off and back on.