API Reference

qwiic_dual_encoder_reader

Python module for the[SparkFun Auto pHAT for Raspberry Pi](https://www.sparkfun.com/products/16328)

This python package enables the user to take count readings from the on-board ATTINY84 that handles reading the dual motor encoders.

The firmware that is used on the ATTiny84 is located in a separate repository here: [SparkFun Dual Encoder Reader Firmware Repository](https://github.com/sparkfun/Qwiic_Dual_Encoder_Reader)

This package can be used in conjunction with the overall [SparkFun qwiic Python Package](https://github.com/sparkfun/Qwiic_Py)

New to qwiic? Take a look at the entire [SparkFun qwiic ecosystem](https://www.sparkfun.com/qwiic).

class qwiic_dual_encoder_reader.QwiicDualEncoderReader(address=None, i2c_driver=None)[source]
Parameters:
  • address – The I2C address to use for the device. If not provided, the default address is used.
  • i2c_driver – An existing i2c driver object. If not provided a driver object is created.
Returns:

The QwiicDualEncoderReader device object.

Return type:

Object

begin()[source]

Initialize the operation of the Dual Encoder Reader module

Returns:Returns true of the initializtion was successful, otherwise False.
Return type:bool
clear_interrupts()[source]

Clears the moved bit

Returns:No return Value
connected

Determine if a device is conntected to the system..

Returns:True if the device is connected, otherwise False.
Return type:bool
count1

Returns the number of “ticks” the encoder1 has turned

Returns:number of encoder pulses
Return type:word as integer
count2

Returns the number of “ticks” the encoder2 has turned

Returns:number of encoder pulses
Return type:word as integer
get_count1()[source]

Returns the number of “ticks” the encoder1 has turned

Returns:number of encoder pulses
Return type:word as integer
get_count2()[source]

Returns the number of “ticks” the encoder2 has turned

Returns:number of encoder pulses
Return type:word as integer
get_diff(clear_value=False)[source]

Returns the number of ticks since last check

Parameters:clearValue – Set to True to clear the current value. Default is False
Returns:the difference
Return type:integer
get_int_timeout()[source]

Get number of milliseconds that elapse between end of encoder turning and interrupt firing

Returns:the timeout value
Return type:integer
get_limit()[source]

Returns the limit of allowed counts before wrapping. 0 is disabled

Returns:The limit
Return type:integer
get_version()[source]

Returns a integer of the firmware version number

Returns:The firmware version
Return type:integer
has_moved()[source]

Returns true if encoder has moved

Returns:Moved state
Return type:Boolean
int_timeout

Get number of milliseconds that elapse between end of encoder turning and interrupt firing

Returns:the timeout value
Return type:integer
is_connected()[source]

Determine if a device is conntected to the system..

Returns:True if the device is connected, otherwise False.
Return type:bool
limit

Returns the limit of allowed counts before wrapping. 0 is disabled

Returns:The limit
Return type:integer
moved

Returns true if encoder has moved

Returns:Moved state
Return type:Boolean
set_count1(amount)[source]

Set the encoder count1 to a specific amount

Parameters:amount – the value to set the counter to
Returns:no return value
set_count2(amount)[source]

Set the encoder count2 to a specific amount

Parameters:amount – the value to set the counter to
Returns:no return value
set_int_timeout(timeout)[source]

Set number of milliseconds that elapse between end of encoder turning and interrupt firing

Parameters:timeout – the timeout value in milliseconds
Returns:No return value
set_limit(amount)[source]

Set the encoder count limit to a specific amount

Parameters:amount – the value to set the limit to
Returns:no return value
since_last_movement(clear_value=True)[source]

Returns the number of milliseconds since the last encoder movement By default, clear the current value

Parameters:clearValue – Clear out the value? True by default
Returns:time since last encoder movement
Return type:integer
version

Returns a integer of the firmware version number

Returns:The firmware version
Return type:integer