-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Hi, I am working on a C pi lib for this quad-encoder seesaw thing, and have been trying to reverse-engineer from working python-code, but I noticed an error with setting a rotary-value:
import board
import busio
from adafruit_debug_i2c import DebugI2C
import adafruit_seesaw.seesaw
i2c = DebugI2C(busio.I2C(board.SCL, board.SDA))
seesaw = adafruit_seesaw.seesaw.Seesaw(i2c, 0x49)
import adafruit_seesaw.rotaryio
encoders = [adafruit_seesaw.rotaryio.IncrementalEncoder(seesaw, n) for n in range(4)]
encoders[0].position = 100
encoders[1].position = 200
encoders[2].position = 300
encoders[3].position = 400Results in this, as I would expect:
get version and stuff:
I2CWRITE @ 0x49 ::
I2CWRITE @ 0x49 :: 0x0, 0x7f, 0xff
I2CWRITE @ 0x49 :: 0x0, 0x1
I2CREAD @ 0x49 :: 0x87
I2CWRITE @ 0x49 :: 0x0, 0x2
I2CREAD @ 0x49 :: 0x16, 0x78, 0xdb, 0x17
set values
I2CWRITE @ 0x49 :: 0x11, 0x30, 0x0, 0x0, 0x0, 0x64
I2CWRITE @ 0x49 :: 0x11, 0x31, 0x0, 0x0, 0x0, 0xc8
I2CWRITE @ 0x49 :: 0x11, 0x32, 0x0, 0x0, 0x1, 0x2c
I2CWRITE @ 0x49 :: 0x11, 0x33, 0x0, 0x0, 0x1, 0x90
bytes seem to be reversed int32's, for example 0x2c, 0x1, 0, 0 is 300.
When I read the same rotary, I get all 0's though, so I don't think it worked:
print(f"{encoders[0].position} {encoders[1].position} {encoders[2].position} {encoders[3].position}") I2CWRITE @ 0x49 :: 0x11, 0x30
I2CREAD @ 0x49 :: 0x0, 0x0, 0x0, 0x0
I2CWRITE @ 0x49 :: 0x11, 0x31
I2CREAD @ 0x49 :: 0x0, 0x0, 0x0, 0x0
I2CWRITE @ 0x49 :: 0x11, 0x32
I2CREAD @ 0x49 :: 0x0, 0x0, 0x0, 0x0
I2CWRITE @ 0x49 :: 0x11, 0x33
I2CREAD @ 0x49 :: 0x0, 0x0, 0x0, 0x
Thinking it might be swapped, I tried this too, but still got 0:
i2c.writeto(0x49, bytes([0x11, 0x32, 0x2c, 0x1, 0, 0 ]))I also tried waiting for a bit, and looping, and it stays 0, so I don't think it's a timing issue (reading too fast after setting.)
Could it be bunk firmware, or is it a lib issue?
Also, I'd like to say great & useful contributions ya'll are making to circuitpython/blinka. It's very helpful to essentially be able to use the same easy-to-use python libs on any device I might work with, and I would definitely be using that, if I didn't require C (working on native puredata extensions, for use on pi, for a few devices.) DebugI2C has been incredibly helpful, since I can generally find working python code, and see the bytes, then just translate that into C. I really appreciate this. Keep up the good work!