-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Firing off API commands like print()
or setFastBacklight()
can result in an OSError
, number 121 or 5. The raw number of the exceptions is reduced by sleeping "enough" between commands, but not necessarily the frequency of exceptions per API call. Receiving an OSError
number 121 almost always causes "glitching" of the display, where unexpected characters print it in unexpected places. A number 5 usually does not result in glitching, but it can still happen.
This issue appears to have old origins and is not unique to this python API: https://community.sparkfun.com/t/20x4-lcd-screen-troubles-with-speed/15438/3
A newer, more thorough discussion mirroring my experience is here: https://community.sparkfun.com/t/serlcd-i2c-timing-issue/39322
Quoting from TS Chris from 2020:
if you send a command before the LCD has completed the previous instruction, unpredictable things happen on the display.
I don’t think we take into account how long the various commands take to process, (by the LCD controller, not the ATmega on the LCD) but that might be a good addition to future firmware revisions.
It sure seems to be the case that this is not unique to the Python API, and it has been an issue for 5-15 years. I was building an application that would smartly update only changed data, but with all the error handling and sleep()
statements to try to reduce the likelihood of exceptions, it was ironically much faster to just blindly update the entire display as fast as the API allows. I can achieve a 1Hz refresh rate with occasional glitching that lasts a maximum of 1s. When attempting to sleep()
strategically to avoid exceptions, the "smart" refresh of only changed text was actually slower.