hallo1 Posted May 10, 2020 Posted May 10, 2020 Armbianmonitor: http://ix.io/2lxT 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. import sys from PIL import Image from PIL import ImageDraw from PIL import ImageFont import 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 = 0 while True: # 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. 0 Quote
martinayotte Posted May 10, 2020 Posted May 10, 2020 25 minutes ago, hallo1 said: so it is more likely a bug related to kernel. Did you checked the presence of the device with "i2cdetect" ? Did you checked the permissions of /dev/i2c-1 and running your test script under proper user/group ? 0 Quote
hallo1 Posted May 11, 2020 Author Posted May 11, 2020 17 hours ago, martinayotte said: Did you checked the presence of the device with "i2cdetect" ? Did you checked the permissions of /dev/i2c-1 and running your test script under proper user/group ? I2cdetect works properly, showing a device at address 0x3c I'm using superuser permission to execute the script. If there is a permission issue, it will show a error message "permission denied" Sometimes the display will light up and show proper content, but the script will still run into this error after ~3s. 0 Quote
martinayotte Posted May 11, 2020 Posted May 11, 2020 5 hours ago, hallo1 said: Sometimes the display will light up and show proper content, but the script will still run into this error after ~3s. Then, maybe it is I2C speed issue ... 0 Quote
hallo1 Posted June 14, 2020 Author Posted June 14, 2020 On 5/11/2020 at 10:06 PM, martinayotte said: Then, maybe it is I2C speed issue ... That is not a I2C speed issue. I examined the i2c data of the OLED using a logic analyzer and found the i2c clock is both 100KHz (maybe a little slow but reasonable) 0 Quote
hallo1 Posted June 14, 2020 Author Posted June 14, 2020 34 minutes ago, hallo1 said: That is not a I2C speed issue. I examined the i2c data of the OLED using a logic analyzer and found the i2c clock is both 100KHz (maybe a little slow but reasonable) Here is the output of the logic analyzer (kernel ~5.4). You can open it using the pulseview software. under linux mainline 5.4.sr 0 Quote
Matthai Posted April 30, 2021 Posted April 30, 2021 I have a similar problem. i2c detect detects OLED, I was using Codelectron library, but it seems it stopped working. However, I tried to install Luma library, but I am getting some error: sudo -H pip3 install -e . Obtaining file:///home/matej/luma.examples Collecting argcomplete (from luma.examples==0.0.0) Downloading https://files.pythonhosted.org/packages/b7/9e/9dc74d330c07866d72f62d553fe8bdbe32786ff247a14e68b5659963e6bd/argcomplete-1.12.3-py2.py3-none-any.whl Collecting luma.core>=1.17.1 (from luma.examples==0.0.0) Using cached https://files.pythonhosted.org/packages/e9/c8/878165a9413bcf4745a396809646f16a2eb00eba5589bf5aac1817bf3ce3/luma.core-2.3.1-py2.py3-none-any.whl Collecting luma.emulator>=1.3.0 (from luma.examples==0.0.0) Downloading https://files.pythonhosted.org/packages/53/2c/d00bcb9bb02a7a6b36bc984a577181d2ce08709d630cf80739465ef05f43/luma.emulator-1.4.0-py2.py3-none-any.whl Collecting luma.lcd>=2.5.0 (from luma.examples==0.0.0) Downloading https://files.pythonhosted.org/packages/4f/a9/b84d13a24e2393ffe989d0fb19c4ba3f8e83abf71fbe487528b7105e2ce7/luma.lcd-2.9.0-py2.py3-none-any.whl Collecting luma.led_matrix>=1.5.0 (from luma.examples==0.0.0) Downloading https://files.pythonhosted.org/packages/c9/2d/ffe0f4c610b2740f5ed16dd3d7179cd28d935f1ea851812871ee739da738/luma.led_matrix-1.5.0-py2.py3-none-any.whl Collecting luma.oled>=3.6.0 (from luma.examples==0.0.0) Using cached https://files.pythonhosted.org/packages/d5/3c/2a464be33c7a29633506b75c579cb50356a1e788609db809bf7999c74511/luma.oled-3.8.1-py2.py3-none-any.whl Collecting importlib-metadata<5,>=0.23; python_version == "3.7" (from argcomplete->luma.examples==0.0.0) Downloading https://files.pythonhosted.org/packages/8e/e2/49966924c93909d47612bb47d911448140a2f6c1390aec2f4c1afbe3748f/importlib_metadata-4.0.1-py3-none-any.whl Requirement already satisfied: pillow>=4.0.0 in /usr/lib/python3/dist-packages (from luma.core>=1.17.1->luma.examples==0.0.0) (5.4.1) Requirement already satisfied: pyftdi in /usr/local/lib/python3.7/dist-packages (from luma.core>=1.17.1->luma.examples==0.0.0) (0.52.9) Collecting RPI.GPIO; platform_system == "Linux" (from luma.core>=1.17.1->luma.examples==0.0.0) Using cached https://files.pythonhosted.org/packages/cb/88/d3817eb11fc77a8d9a63abeab8fe303266b1e3b85e2952238f0da43fed4e/RPi.GPIO-0.7.0.tar.gz Requirement already satisfied: deprecated in /usr/local/lib/python3.7/dist-packages (from luma.core>=1.17.1->luma.examples==0.0.0) (1.2.12) Requirement already satisfied: smbus2 in /usr/local/lib/python3.7/dist-packages (from luma.core>=1.17.1->luma.examples==0.0.0) (0.4.1) Requirement already satisfied: cbor2 in /usr/local/lib/python3.7/dist-packages (from luma.core>=1.17.1->luma.examples==0.0.0) (5.2.0) Collecting spidev; platform_system == "Linux" (from luma.core>=1.17.1->luma.examples==0.0.0) Using cached https://files.pythonhosted.org/packages/62/56/de649e7d95f9fcfaf965a6eb937b4a46bc77ef21487c99cde1a7a0546040/spidev-3.5.tar.gz Collecting pygame (from luma.emulator>=1.3.0->luma.examples==0.0.0) Downloading https://files.pythonhosted.org/packages/c7/b8/06e02c7cca7aec915839927a9aa19f749ac17a3d2bb2610b945d2de0aa96/pygame-2.0.1.tar.gz (5.5MB) 100% |████████████████████████████████| 5.5MB 47kB/s Complete output from command python setup.py egg_info: WARNING, No "Setup" File Exists, Running "buildconfig/config.py" Using UNIX configuration... /bin/sh: 1: sdl2-config: not found /bin/sh: 1: sdl2-config: not found /bin/sh: 1: sdl2-config: not found /tmp/pip-install-psoj4g37/pygame/setup.py:44: DeprecationWarning: dist() and linux_distribution() functions are deprecated in Python 3.5 distro = platform.linux_distribution() Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-psoj4g37/pygame/setup.py", line 318, in <module> buildconfig.config.main(AUTO_CONFIG) File "/tmp/pip-install-psoj4g37/pygame/buildconfig/config.py", line 221, in main deps = CFG.main(**kwds) File "/tmp/pip-install-psoj4g37/pygame/buildconfig/config_unix.py", line 194, in main DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl']), File "/tmp/pip-install-psoj4g37/pygame/buildconfig/config_unix.py", line 39, in __init__ self.ver = config[0].strip() IndexError: list index out of range Hunting dependencies... --- For help with compilation see: https://www.pygame.org/wiki/CompileDebian To contribute to pygame development see: https://www.pygame.org/contribute.html --- ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-psoj4g37/pygame/ Any idea how to solve this? 0 Quote
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.