I have attached a ssd1306 OLED display to the board, using i2c1 interface, using the luma.oled library as driver.
import sys
from PIL importImagefrom PIL importImageDrawfrom PIL importImageFontimport subprocess
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
from time import sleep
serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=0)
width=device.width
height=device.height
image =Image.new('1',(device.width, device.height))# Get drawing object to draw on image.
draw =ImageDraw.Draw(image)# Draw a black filled box to clear the image.
draw.rectangle((0,0,device.width,device.height), outline=0, fill=0)
padding =2
top = padding
bottom = device.height-padding
# Move left to right keeping track of the current x position for drawing shapes.
x =0whileTrue:# Draw a black filled box to clear the image.
draw.rectangle((0,0,width,height), outline=0, fill=0)# Shell scripts for system monitoring from here : https://unix.stackexchange.com/questions/119126/command-to-displa$ cmd = "hostname -I | cut -d\' \' -f1"
IP = subprocess.check_output(cmd, shell =True)
cmd ="top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'"
CPU = subprocess.check_output(cmd, shell =True)
cmd ="free -m | awk 'NR==2{printf \"Mem: %s/%sMB %.2f%%\", $3,$2,$3*100/$2 }'"MemUsage= subprocess.check_output(cmd, shell =True)
cmd ="df -h | awk '$NF==\"/\"{printf \"Disk: %d/%dGB %s\", $3,$2,$5}'"Disk= subprocess.check_output(cmd, shell =True)# Write two lines of text.
draw.text((x, top),"IP:"+str(IP,encoding ="utf-8"), font=font, fill=255)
draw.text((x, top+8),str(CPU,encoding ="utf-8"), font=font, fill=255)
draw.text((x, top+16),str(MemUsage,encoding ="utf-8"), font=font, fill=255)
draw.text((x, top+25),str(Disk,encoding ="utf-8"), font=font, fill=255)
device.display(image)
sleep(0.5)
At the kernel version 5.3.9, the display worked perfectly, without any problem.
But after updating the kernel version to above 5.4.20, the same code don't work at all.
Traceback (most recent call last):
File "./test_oled.py", line 12, in <module>
device = ssd1306(serial, rotate=0)
File "/usr/local/lib/python3.6/dist-packages/luma/oled/device/__init__.py", line 188, in __init__
self.clear()
File "/usr/local/lib/python3.6/dist-packages/luma/core/mixin.py", line 46, in clear
self.display(Image.new(self.mode, self.size))
File "/usr/local/lib/python3.6/dist-packages/luma/oled/device/__init__.py", line 220, in display
self.data(list(buf))
File "/usr/local/lib/python3.6/dist-packages/luma/core/device.py", line 46, in data
self._serial_interface.data(data)
File "/usr/local/lib/python3.6/dist-packages/luma/core/interface/serial.py", line 119, in data
write(list(data[i:i + block_size]))
File "/usr/local/lib/python3.6/dist-packages/luma/core/interface/serial.py", line 128, in _write_large_block
self._bus.i2c_rdwr(self._i2c_msg_write(self._addr, [self._data_mode] + data))
File "/usr/local/lib/python3.6/dist-packages/smbus2/smbus2.py", line 637, in i2c_rdwr
ioctl(self.fd, I2C_RDWR, ioctl_data)
TimeoutError: [Errno 110] Connection timed out
Because the luma.oled library just uses the linux kernel i2c interface like the /dev/i2c-1, so it is more likely a bug related to kernel.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
hallo1
I am using a orangepi win plus.
I have attached a ssd1306 OLED display to the board, using i2c1 interface, using the luma.oled library as driver.
At the kernel version 5.3.9, the display worked perfectly, without any problem.
But after updating the kernel version to above 5.4.20, the same code don't work at all.
Because the luma.oled library just uses the linux kernel i2c interface like the /dev/i2c-1, so it is more likely a bug related to kernel.
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.