Closed Idechix closed 7 years ago
Hmmm... we have an I2cSensor
class, but that's primarily for LEGO sensors which use the I2C protocol but have a proper ev3dev driver to operate them. That class doesn't actually provide any generic read/write capabilities.
My inclination is to say that the way you do it now is the best, barring writing your own kernel driver for this multiplexer. You could wrap it in your own class to make the interface nicer, but there aren't any pre-built classes for that to my knowledge.
Ok, thank you :) I think I will use that code, but I am curious and I would like to go a bit further.
In my research I found that: http://docs.ev3dev.org/projects/lego-linux-drivers/en/ev3dev-jessie/sensor_data.html#pcf8574
I don't really know if that means a driver for that chip really exists (and how to use it?).
It means there is not an ev3dev driver for that chip. There is a regular Linux kernel driver that exposes the device using the Linux gpio device class. To use it, would have to add something to /etc/modules-load.d/
and /etc/modprobe.d/
to get the driver to automatically load correctly. Then you would have to write a udev rule so that non-root users could use those gpios. Then you would have to figure out how to use the gpios from python. Using smbus is probably easier than all of this. 😄
Yes, smbus will be just fine ;) Thank you guys!
Hi everyone! I made that sensor: http://www.mindstormsrobots.com/lego-mindstorms/mindstorms-8-input-rcx-touch-sensor-multiplexer/
I can read its values using smbus, but I wonder if there is a way to only use ev3dev python classes to get the same result.
Here is what I do for now:
I really appreciate any help you can provide :)