When @wrongbaud gets the discord server and provides the images for the #PiFex, I can provide more detailed documentation. But the key parts are in /boot/firmware/config.txt where you need to add
dtoverlay=i2c-gpio,bus=4,i2c_gpio_sda=22,i2c_gpio_scl=23
I used the https://luma-oled.readthedocs.io/en/latest/ drivers.
----------------------------------
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time-stamp: <2024-06-05 20:52:59 pi>
# Author: grymoire
# Usage: display <arg> .......
# Revisions
# * Added text wrapping
# I'm sure this could be made more efficient/elegant, but it works
"""
Write text to ssd1306 display on PiFex - Grymoire
"""
import time
from luma.core.interface.serial import i2c
from luma.oled.device import ssd1306
from luma.core.render import canvas
from luma.core.virtual import viewport
import sys # for shell arguments
import textwrap # for text wrapping
def do_nothing(obj): # define a custom routine to do nothing on exit instead of clearing the screen (the default)
pass
def main():
virtual = viewport(device, width=device.width, height=device.height)
args=' '.join(sys.argv[1:]) # collect all of the shell arguments
data=textwrap.wrap(args,width=20);
# Hmm. I'm not sure how many lines we now have....
with canvas(virtual) as draw:
if ((len(data) > 0) and len(data[0]) > 0):
draw.text((0, 0), data[0], fill="white")
if (len(data) > 1 and len(data[1]) > 0):
draw.text((0, 12), data[1], fill="white")
if (len(data) > 2 and len(data[2]) > 0):
draw.text((0, 24), data[2], fill="white")
if (len(data) > 3 and len(data[3]) > 0):
draw.text((0, 36), data[3], fill="white")
if __name__ == "__main__":
try:
serial = i2c(port=4, address=0x3c)
device = ssd1306(serial)
device.cleanup = do_nothing # exit without clearing the display
main()
except KeyboardInterrupt:
pass