Closed PiStuffing closed 6 years ago
Just flipping through the pdf you referred to, I wouldn't expect any of these to work:
I have two comments/questions for you:
bus.read_byte(0x40)
? It's a bit rough, but it has worked for me for one particular i2c device in the past. Depends on how forgiving yours is.bus.i2c_rdwr()
, and I suppose that's what you intended to do. However, you are not doing it right as far as I can see in the code sample.# Read 2 bytes from address 0x40
msg = i2c_msg.read(0x40, 2)
bus.i2c_rdwr(msg)
# Access the data in the msg object
data = list(msg)
print(data)
Good luck
Perfect, thank you. Problem solved.
While two read_bytes returned the same value on both reads, your i2c_msg + i2c_rdwr are producing 2 distinct values tracking the joysticks perfectly.
This is likely to be my problem that I need help with. I'm using this i2c joysticks:
http://www.grayhill.com/assets/1/7/67a_i2c_user_manual_1.2.pdf
It requires reading 2 bytes simultaniously; there is no register used. Python SMBus doesn't support this function, hence I'm trying your SMBus2. Of the four options I've tried, only the first works (a bit but only one byte), the rest either get exceptions or return all zeros. Any suggestions please?
` with SMBusWrapper(1) as bus: