Well, I've made some headway.
The only way I could find to get Luma onto my Pi entirely successfully was to git clone it. I then discovered that it selects the wrong device type even if I select the correct device type unless I remove every other entry from the device import list rather than just selecting the one I need from the list.
This is the only working code I have so far...
It can't make head nor tail of any of the documentation I've found for Luma and am a total noob when it comes to Python, so I have no idea how to select a different font or set the font size. Neither can I import time (just hours and minutes would be fine) and store it in a variable in a way that displays in this mode.
For the font, I'm getting a screen full of warnings...
...when following the suggestion here...
https://github.com/rm-hull/luma.oled/issues/247
...that's flagged as a closed issue.
Please tell me it's actually all very simple and I'm just being an idiot.
The only way I could find to get Luma onto my Pi entirely successfully was to git clone it. I then discovered that it selects the wrong device type even if I select the correct device type unless I remove every other entry from the device import list rather than just selecting the one I need from the list.
This is the only working code I have so far...
Code:
from luma.core.interface.serial import i2cfrom luma.oled.device import sh1106from luma.core.render import canvasfrom time import sleepfrom time import time# Port type and addressserial = i2c(port=1, address=0x3C)# Device typedevice = sh1106(serial)# Write text to displaywith canvas(device) as draw:draw.text((12, 28), "Display Time Here", fill="white")sleep(10)
It can't make head nor tail of any of the documentation I've found for Luma and am a total noob when it comes to Python, so I have no idea how to select a different font or set the font size. Neither can I import time (just hours and minutes would be fine) and store it in a variable in a way that displays in this mode.
For the font, I'm getting a screen full of warnings...
Code:
Traceback (most recent call last): File "/home/fred/oled-screen/test.py", line 15, in <module> FontTemp = ImageFont.truetype("./TestFont.otf",16) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 1008, in truetype return freetype(font) ^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 1005, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 255, in __init__ self.font = core.getfont( ^^^^^^^^^^^^^OSError: cannot open resource
https://github.com/rm-hull/luma.oled/issues/247
...that's flagged as a closed issue.
Please tell me it's actually all very simple and I'm just being an idiot.
Statistics: Posted by GTR2Fan — Tue Mar 19, 2024 12:27 pm