Open ryjelsum opened 6 months ago
let's start with the essential: what smbus version? what python version? luma.core version? etc??
My bad, I shouldn't be filing issues late at night :)
Python 3.10.14, smbus2 version 0.4.3, luma.core version 2.4.2, luma.oled version 3.13.0, on NixOS 23.11, kernel 6.6.30.
(Alternate title; Feature request: 'strict' SMBus i2c mode)
Hi, this is a bit of an odd one, but I'd figure I'd throw it up here if not for somebody to address, then to document the solution a little bit better for anyone else who's run into this issue (or similar) down the line.
I've been playing around with the example programs on my x86 desktop PC, with various i2c USB dongles, as well as hooking LCDs (character and OLED) up to the SMBus on my motherboard, since it has a header for it. luma.lcd has worked fine in my very limited testing, but I ran into some issues with attempting to run luma.oled on an I2C OLED display; the error that is in the title.
Full traceback:
The root of the issue is that apparently, i2c_rdwr is not included / supported by (all) SMBus interfaces, but it is included in the python smbus library nonetheless. I'm putting the issue here since it seems to be an issue with some of the core component.
I have managed to get this "functional", in the sense that is now outputting to the display, by going into the serial.py file, in the 'data' function, and replacing "if self._managed:" with "if False:". (forcing it to always act as 'unmanaged' by the smbus library, as I understand it?) This is a hack, it massively hurts performance, and I'm pretty damn sure it's not the best way to do it, it was just the only way I could understand how. It'd be cool to see if this issue could be addressed in a less amateur way.
Totally understand if this is not something you want to touch, because this is well outside of the intended use case of single-board computers. Just didn't want to feel like all this work went to waste :)