Python Module for I2C, OLED Library Update
Lazar Demin administrators last edited by Lazar Demin
I2C Python Module
Finally, as promised, the Onion I2C library is available as a Python module.
Check out this wiki post for details on how to install and use the module: https://wiki.onion.io/Tutorials/Libraries/I2C-Library
OLED Expansion Library
The OLED library has been updated with some new functions:
- Setting column addressing for text
- Setting column addressing for the full screen
- Setting the cursor based on the row and pixel (instead of column)
- Writing a single byte (8 vertical pixels) to the screen
The functions are available in the C library as well as the Python Module, and the command line
oled-exptool supports the new functions as well.
All of the info can be found here: https://wiki.onion.io/Tutorials/Libraries/OLED-Expansion-Library
I am go glad you updated the oled python library. HOWEVER:
- there are typos in the wiki: the python method is not oledSetImageColumns() , it is just setImageColumns()
(one can check by doing a dir on the module)
- more importantly, when I call setCursorByPixel(0,0) I get a seg fault.
Please fix these bugs ! I am writing a library to write scalable font to the display and need byte level writes to work.
@PK-Shiu Ah apologies for the typos, the wiki article has been updated.
And I'll take a loot at the segfault tomorrow!
It works fine on my end, I think that the segfault issue is due to the
libonionoledexplibrary not being the latest version.
Can you run
opkg list-installed | grep -i oled?
All of the versions should be
If that's the case, run the following:
opkg upgrade pyOledExp --force-depends
This will update the pyOledExp package and all of it's dependencies to the latest version. Try running your code again and let me know how it goes.
Not only did I have to force my Onion to update the Python OLED library, I also had to force it to update the C library:
opkg upgrade libonionoledexp --force-depends
Thank you, @Lazar-Demin, it appears to be working great!
Here's my test program for those who are interested.
#!/usr/bin/python import OmegaExpansion.oledExp as oled oled.driverInit() oled.setDisplayPower(1) oled.setDisplayMode(0) oled.setImageColumns() oled.clear() oled.setCursorByPixel(0, 0) oled.writeByte(0x3C) oled.writeByte(0x42) oled.writeByte(0x89) oled.writeByte(0xA1) oled.writeByte(0xA1) oled.writeByte(0x89) oled.writeByte(0x42) oled.writeByte(0x3C)
I'm ignoring the status return from writeByte (and probably a few other API's too). The output should be a tiny face on the OLED. I tried to do a smiley, but there wasn't enough space in an 8x8 block
Thanks @Bryan-Hilterbrand and @Lazar-Demin - I have to update both libraries. Now it is working. BTW this is my package list:
libonionoledexp - 0.2-1
oled-exp - 0.1-1
pyOledExp - 0.2-1
oled-exp is still at 0.1.-1.
@PK-Shiu, you're right, oled-exp should be updated as well. oled-exp is the command line tool for accessing the OLED screen, so it doesn't matter when you're using Python.
opkg upgrade oled-exp --force-depends
Nice! Here's your test program on my Omega at the office: