-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
I'd like to use this OLED driver: https://github.com/micropython/micropython/blob/master/drivers/display/ssd1306.py on a pyboard with I2C.
However, this driver expects to be using the soft I2C which provides the "primitive" start/write/stop API (and it does in fact work great on my pyboard). It makes sense that it's using that API - it wants to transmit a single byte followed by a framebuffer. I can't see a way to do this using the writeto() API that doesn't involve a big copy.
I use this for teaching school students so I'm trying to avoid mysterious traps like understanding the difference between machine.I2C('X') vs machine.I2C(scl=...,sda=...).
I have a few suggestions:
-
Add a scatter/gather version of writeto (i.e. the buf argument is allowed to be an iterable of buffers) and update ssd1306.py to use it.
-
Have the stm32 hardware I2C implementation fall back to software I2C for start/stop/readinto/write. (Not sure this is a good idea...).
-
Add these methods to the stm32 hardware implementation. POC for start/stop/write at https://github.com/micropython/micropython/compare/master...jimmo:pyb-i2c-ll?expand=1 (This works for my display). It is a bit complicated because of the address handling though. It would be simpler if
start()took the 7-bit address and then figured out what do based on whetherreadorwritewas called. (What is the policy on making code in micropython/drivers depend on newer firmware versions?).
Thanks!