Allows the user to read angle measurements from the encoder. More...
Public Member Functions | |
def | __init__ (self, encoderA_pin, encoderB_pin, timerNumber, prescaler, period) |
Creates a EncoderDriver object to read an encoder. More... | |
def | update (self) |
Updates the position of the encoder and calculates the amount of change in position to store in delta. More... | |
def | get_position (self) |
Returns the most recently updated position of the encoder. | |
def | set_position (self, position) |
Sets the position of the encoder. | |
def | get_delta (self) |
Returns the amount of change in position since the last update. | |
def | zero (self) |
Sets the position of the encoder to 0. | |
Public Attributes | |
EncoderA_pin | |
Encoder A pin. | |
EncoderB_pin | |
Encoder B pin. | |
TimerNumber | |
Encoder timer number. | |
Prescaler | |
Encoder timer prescaler. | |
Period | |
Encoder timer period. | |
Timer | |
Encoder timer object. | |
CurCount | |
Encoder timer current value. | |
PrevCount | |
Encoder timer previous value. | |
Position | |
Encoder position. | |
Delta | |
Encoder change in position. | |
Allows the user to read angle measurements from the encoder.
def EncoderDriver.EncoderDriver.__init__ | ( | self, | |
encoderA_pin, | |||
encoderB_pin, | |||
timerNumber, | |||
prescaler, | |||
period | |||
) |
Creates a EncoderDriver object to read an encoder.
encoderA_pin | A pyb.Pin object used as the encoder's A pin. |
encoderB_pin | A pyb.Pin object used as the encoder's B pin. |
timerNumber | A value used to create a pyb.Timer object to count for the encoder. |
prescaler | A value used for the timer. |
period | A value used for the timer. |
def EncoderDriver.EncoderDriver.update | ( | self | ) |
Updates the position of the encoder and calculates the amount of change in position to store in delta.
If theres is overflow or underflow, the delta is adjusted. The delta value is added to the current position.