To get the encoder value, BrickPiUpdateValues()
will update the value that’s stored in BrickPi.Encoder[PORT_A]
. For example:
BrickPiUpdateValues() # update the value
Encoder_A_Value = BrickPi.Encoder[PORT_A] # use the encoder value
To reset the encoder value, after BrickPiSetup()
you’ll need to call BrickPiUpdateValues()
(get the current position), then BrickPi.EncoderOffset[PORT_A] = BrickPi.Encoder[PORT_A]
(set the offset value), then BrickPiUpdateValues()
again (make the offset take effect). It would look something like this:
BrickPiUpdateValues() # get the current encoder position
BrickPi.EncoderOffset[PORT_A] = BrickPi.Encoder[PORT_A] # assign the current encoder position as the offset
BrickPiUpdateValues() # make the offset take effect