API Reference

top_phat_button

Python module for the[SparkFun Qwiic Joystick](https://www.sparkfun.com/products/15168)

This python package is a port of the existing [SparkFun Qwiic Joystick Arduino Library](https://github.com/sparkfun/SparkFun_Qwiic_Joystick_Arduino_Library)

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 top_phat_button.ToppHATButton(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 ToppHATButton device object.

Return type:

Object

begin()[source]

Initialize the operation of the button module

Returns:Returns true of the initializtion was successful, otherwise False.
Return type:bool
button_clicked

Returns 1 when a button has received a full click cycle (press and release). The interrupt must be cleared by the user. 7(MSB) 6 5 4 3 2 1 0(LSB)

INT CTR RGT LFT DWN UP B A
Returns:Clicked status of all buttons in a byte
Return type:integer
button_pressed

Updates and returns buffer for all buttons and whether or not they are pressed as well as the pressed interrupt flag Reading this register also clears it. 7(MSB) 6 5 4 3 2 1 0(LSB)

INT CTR RGT LFT DWN UP B A
Returns:button status
Return type:integer
clicked_interrupt_enable

Returns the status of the clicked interrupt enable

Returns:The clicked interrupt enable bit
Return type:bool
connected

Determine if the Top pHAT Buttons are connected to the system..

Returns:True if the device is connected, otherwise False.
Return type:bool
get_button_clicked()[source]

Returns 1 when a button has received a full click cycle (press and release). The interrupt must be cleared by the user. 7(MSB) 6 5 4 3 2 1 0(LSB)

INT CTR RGT LFT DWN UP B A
Returns:Clicked status of all buttons in a byte
Return type:integer
get_button_pressed()[source]

Updates and returns buffer for all buttons and whether or not they are pressed as well as the pressed interrupt flag Reading this register also clears it. 7(MSB) 6 5 4 3 2 1 0(LSB)

INT CTR RGT LFT DWN UP B A
Returns:button status
Return type:integer
get_clicked_interrupt()[source]

Returns the status of the clicked interrupt enable

Returns:The clicked interrupt enable bit
Return type:bool
get_pressed_interrupt()[source]

Returns the status of the pressed interrupt enable

Returns:The pressed interrupt enable bit
Return type:bool
get_version()[source]

Returns a string of the firmware version number

Returns:The firmware version
Return type:string
is_connected()[source]

Determine if the Top pHAT Buttons are connected to the system..

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

Returns the status of the pressed interrupt enable

Returns:The pressed interrupt enable bit
Return type:bool
set_clicked_interrupt(bit_setting)[source]

Sets the status of the clicked interrupt enable bit

Param:The clicked interrupt enable bit
Returns:The status of the I2C transaction
Return type:bool
set_pressed_interrupt(bit_setting)[source]

Sets the status of the pressed interrupt enable bit

Param:The pressed interrupt enable bit
Returns:The status of the I2C transaction
Return type:bool
version

Returns a string of the firmware version number

Returns:The firmware version
Return type:string