Qwiic_Button_Py
Python for SFE Qwiic Button
Loading...
Searching...
No Matches
qwiic_button.QwiicButton Class Reference

" QwiicButton More...

Inheritance diagram for qwiic_button.QwiicButton:

Public Member Functions

def __init__ (self, address=None, i2c_driver=None)
 
def is_connected (self)
 Determine if a Qwiic Button device is connected to the system. More...
 
def begin (self)
 Initialize the operation of the Qwiic Button Run is_connected() and check the ID in the ID register. More...
 
def get_firmware_version (self)
 Read the register and get the major and minor firmware version number. More...
 
def set_I2C_address (self, new_address)
 Change the I2C address of the Qwiic Button. More...
 
def get_I2C_address (self)
 Returns the current I2C address of the Qwiic Button. More...
 
def is_button_pressed (self)
 Returns the value of the is_pressed status bit of the BUTTON_STATUS register. More...
 
def has_button_been_clicked (self)
 Returns the value of the has_been_clicked status bit of the BUTTON_STATUS register. More...
 
def get_debounce_time (self)
 Returns the value in the BUTTON_DEBOUNCE_TIME register. More...
 
def set_debounce_time (self, time)
 Write two bytes into the BUTTON_DEBOUNCE_TIME register. More...
 
def enable_pressed_interrupt (self)
 Set pressed_enable bit of the INTERRUPT_CONFIG register to a 1. More...
 
def disable_pressed_interrupt (self)
 Clear the pressed_enable bit of the INTERRUPT_CONFIG register. More...
 
def enable_clicked_interrupt (self)
 Set the clicked_enable bit of the INTERRUPT_CONFIG register. More...
 
def disable_clicked_interrupt (self)
 Clear the clicked_enable bit of the INTERRUPT_CONFIG register. More...
 
def available (self)
 Return the event_available bit of the BUTTON_STATUS register. More...
 
def clear_event_bits (self)
 Clear the is_pressed, has_been_clicked, and event_available bits of the BUTTON_STATUS register. More...
 
def reset_interrupt_config (self)
 Enable pressed and clicked interrupts and clear the event_available bit of BUTTON_STATUS register. More...
 
def is_pressed_queue_full (self)
 Returns the is_full bit of the PRESSED_QUEUE_STATUS register. More...
 
def is_pressed_queue_empty (self)
 Returns the is_empty bit of the PRESSED_QUEUE_STATUS register. More...
 
def time_since_last_press (self)
 Returns the four bytes of PRESSED_QUEUE_FRONT. More...
 
def time_since_first_press (self)
 Returns the four bytes of PRESSED_QUEUE_BACK. More...
 
def pop_pressed_queue (self)
 Returns contents of PRESSED_QUEUE_BACK register and writes a 1 to popRequest bit of PRESSED_QUEUE_STATUS register. More...
 
def is_clicked_queue_full (self)
 Reads the is_full bit of the CLICKED_QUEUE_STATUS register. More...
 
def is_clicked_queue_empty (self)
 Reads the is_empty bit of the CLICKED_QUEUE_STATUS register. More...
 
def time_since_last_click (self)
 Returns the four bytes of CLICKED_QUEUE_FRONT register. More...
 
def time_since_first_click (self)
 Returns the four bytes of CLICKED_QUEUE_BACK register. More...
 
def pop_clicked_queue (self)
 Returns contents of CLICKED_QUEUE_BACK register and writes a 1 to popRequest bit of CLICKED_QUEUE_STATUS register. More...
 
def LED_config (self, brightness, cycle_time, off_time, granularity=1)
 Write brightness, cycle_time, off_time, and granularity parameters to their respective registers: LED_BRIGHTNESS, LED_PULSE_CYCLE_TIME, LED_PULSE_OFF_TIME, LED_PULSE_GRANULARITY. More...
 
def LED_off (self)
 Write zero's to all the LED registers: LED_BRIGHTNESS, LED_PULSE_CYCLE_TIME, LED_PULSE_OFF_TIME, and LED_PULSE_GRANULARITY defaults to zero. More...
 
def LED_on (self, brightness)
 Set LED on without pulse. More...
 

Public Attributes

 address
 
 is_pressed
 
 has_been_clicked
 
 pressed_enable
 
 clicked_enable
 
 event_available
 
 pressed_is_full
 
 pressed_is_empty
 
 pressed_pop_request
 
 clicked_is_full
 
 clicked_is_empty
 
 clicked_pop_request
 

Static Public Attributes

 device_name = _DEFAULT_NAME
 
 available_addresses = _AVAILABLE_I2C_ADDRESS
 
int DEV_ID = 0x5D
 
int ID = 0x00
 
int FIRMWARE_MINOR = 0x01
 
int FIRMWARE_MAJOR = 0x02
 
int BUTTON_STATUS = 0x03
 
int INTERRUPT_CONFIG = 0x04
 
int BUTTON_DEBOUNCE_TIME = 0x05
 
int PRESSED_QUEUE_STATUS = 0x07
 
int PRESSED_QUEUE_FRONT = 0x08
 
int PRESSED_QUEUE_BACK = 0x0C
 
int CLICKED_QUEUE_STATUS = 0x10
 
int CLICKED_QUEUE_FRONT = 0x11
 
int CLICKED_QUEUE_BACK = 0x15
 
int LED_BRIGHTNESS = 0x19
 
int LED_PULSE_GRANULARITY = 0x1A
 
int LED_PULSE_CYCLE_TIME = 0x1B
 
int LED_PULSE_OFF_TIME = 0x1D
 
int I2C_ADDRESS = 0x1F
 
int event_available = 0
 
int has_been_clicked = 0
 
int is_pressed = 0
 
int clicked_enable = 0
 
int pressed_enable = 0
 
int pressed_pop_request = 0
 
int pressed_is_empty = 0
 
int pressed_is_full = 0
 
int clicked_pop_request = 0
 
int clicked_is_empty = 0
 
int clicked_is_full = 0
 

Detailed Description

" QwiicButton

Parameters
addressThe I2C address to use for the device. If not provided, the default address is used.
i2c_driverAn existing i2c driver object. If not provided a driver object is created.
Returns
Object The GPIO device object.

Constructor & Destructor Documentation

◆ __init__()

def qwiic_button.QwiicButton.__init__ (   self,
  address = None,
  i2c_driver = None 
)

Member Function Documentation

◆ available()

def qwiic_button.QwiicButton.available (   self)

Return the event_available bit of the BUTTON_STATUS register.

Returns
event_available bit :rtye: bool

◆ begin()

def qwiic_button.QwiicButton.begin (   self)

Initialize the operation of the Qwiic Button Run is_connected() and check the ID in the ID register.

Returns
bool Returns true if the intialization was successful, otherwise False.

◆ clear_event_bits()

def qwiic_button.QwiicButton.clear_event_bits (   self)

Clear the is_pressed, has_been_clicked, and event_available bits of the BUTTON_STATUS register.

Returns
Void Nothing

◆ disable_clicked_interrupt()

def qwiic_button.QwiicButton.disable_clicked_interrupt (   self)

Clear the clicked_enable bit of the INTERRUPT_CONFIG register.

Returns
Void Nothing

◆ disable_pressed_interrupt()

def qwiic_button.QwiicButton.disable_pressed_interrupt (   self)

Clear the pressed_enable bit of the INTERRUPT_CONFIG register.

Returns
Void Nothing

◆ enable_clicked_interrupt()

def qwiic_button.QwiicButton.enable_clicked_interrupt (   self)

Set the clicked_enable bit of the INTERRUPT_CONFIG register.

Returns
Void Nothing

◆ enable_pressed_interrupt()

def qwiic_button.QwiicButton.enable_pressed_interrupt (   self)

Set pressed_enable bit of the INTERRUPT_CONFIG register to a 1.

Returns
Void Nothing

◆ get_debounce_time()

def qwiic_button.QwiicButton.get_debounce_time (   self)

Returns the value in the BUTTON_DEBOUNCE_TIME register.

Returns
int debounce time in milliseconds

◆ get_firmware_version()

def qwiic_button.QwiicButton.get_firmware_version (   self)

Read the register and get the major and minor firmware version number.

Returns
int 16 bytes version number

◆ get_I2C_address()

def qwiic_button.QwiicButton.get_I2C_address (   self)

Returns the current I2C address of the Qwiic Button.

Returns
int current I2C address

◆ has_button_been_clicked()

def qwiic_button.QwiicButton.has_button_been_clicked (   self)

Returns the value of the has_been_clicked status bit of the BUTTON_STATUS register.

Returns
bool has_been_clicked bit

◆ is_button_pressed()

def qwiic_button.QwiicButton.is_button_pressed (   self)

Returns the value of the is_pressed status bit of the BUTTON_STATUS register.

Returns
bool is_pressed bit

◆ is_clicked_queue_empty()

def qwiic_button.QwiicButton.is_clicked_queue_empty (   self)

Reads the is_empty bit of the CLICKED_QUEUE_STATUS register.

Returns
bool clicked_is_empty

◆ is_clicked_queue_full()

def qwiic_button.QwiicButton.is_clicked_queue_full (   self)

Reads the is_full bit of the CLICKED_QUEUE_STATUS register.

Returns
bool clicked_is_full

◆ is_connected()

def qwiic_button.QwiicButton.is_connected (   self)

Determine if a Qwiic Button device is connected to the system.

Returns
bool True if the device is connected, otherwise False.

◆ is_pressed_queue_empty()

def qwiic_button.QwiicButton.is_pressed_queue_empty (   self)

Returns the is_empty bit of the PRESSED_QUEUE_STATUS register.

Returns
bool pressed_is_empty

◆ is_pressed_queue_full()

def qwiic_button.QwiicButton.is_pressed_queue_full (   self)

Returns the is_full bit of the PRESSED_QUEUE_STATUS register.

Returns
bool pressed_is_full

◆ LED_config()

def qwiic_button.QwiicButton.LED_config (   self,
  brightness,
  cycle_time,
  off_time,
  granularity = 1 
)

Write brightness, cycle_time, off_time, and granularity parameters to their respective registers: LED_BRIGHTNESS, LED_PULSE_CYCLE_TIME, LED_PULSE_OFF_TIME, LED_PULSE_GRANULARITY.

Parameters
brightnessbetween 0 (led off) and 255 (max brightness)
cycle_timetotal pulse cycle in in milliseconds Range 0 to 0xFFFF
off_timeoff time between pulses in milliseconds Range 0 to 0xFFFF
granularitythe amount of steps it takes to get to led brightness If not provided, granularity defaults to 1
Returns
Void Nothing

◆ LED_off()

def qwiic_button.QwiicButton.LED_off (   self)

Write zero's to all the LED registers: LED_BRIGHTNESS, LED_PULSE_CYCLE_TIME, LED_PULSE_OFF_TIME, and LED_PULSE_GRANULARITY defaults to zero.

Returns
void Nothing

◆ LED_on()

def qwiic_button.QwiicButton.LED_on (   self,
  brightness 
)

Set LED on without pulse.

Parameters
brightnessbetween 0 (led off) and 255 (max brightness)
Returns
Void Nothing

◆ pop_clicked_queue()

def qwiic_button.QwiicButton.pop_clicked_queue (   self)

Returns contents of CLICKED_QUEUE_BACK register and writes a 1 to popRequest bit of CLICKED_QUEUE_STATUS register.

Returns
int CLICKED_QUEUE_BACK

◆ pop_pressed_queue()

def qwiic_button.QwiicButton.pop_pressed_queue (   self)

Returns contents of PRESSED_QUEUE_BACK register and writes a 1 to popRequest bit of PRESSED_QUEUE_STATUS register.

Returns
int PRESSED_QUEUE_BACK

◆ reset_interrupt_config()

def qwiic_button.QwiicButton.reset_interrupt_config (   self)

Enable pressed and clicked interrupts and clear the event_available bit of BUTTON_STATUS register.

Returns
Void Nothing

◆ set_debounce_time()

def qwiic_button.QwiicButton.set_debounce_time (   self,
  time 
)

Write two bytes into the BUTTON_DEBOUNCE_TIME register.

Parameters
timethe time in milliseconds to set debounce time to The max debounce time is 0xFFFF milliseconds, but the function checks if the entered parameter is valid
Returns
void Nothing

◆ set_I2C_address()

def qwiic_button.QwiicButton.set_I2C_address (   self,
  new_address 
)

Change the I2C address of the Qwiic Button.

Parameters
new_addressthe new I2C address to set the Qwiic Button to The function itself checks if the entered parameter is a valid I2C address
Returns
bool True if the change was successful, false otherwise.

◆ time_since_first_click()

def qwiic_button.QwiicButton.time_since_first_click (   self)

Returns the four bytes of CLICKED_QUEUE_BACK register.

Time in milliseconds

Returns
int CLICKED_QUEUE_BACK

◆ time_since_first_press()

def qwiic_button.QwiicButton.time_since_first_press (   self)

Returns the four bytes of PRESSED_QUEUE_BACK.

Time in milliseconds

Returns
int PRESSED_QUEUE_BACK

◆ time_since_last_click()

def qwiic_button.QwiicButton.time_since_last_click (   self)

Returns the four bytes of CLICKED_QUEUE_FRONT register.

Time in milliseconds

Returns
int CLICKED_QUEUE_FRONT

◆ time_since_last_press()

def qwiic_button.QwiicButton.time_since_last_press (   self)

Returns the four bytes of PRESSED_QUEUE_FRONT.

Time in milliseconds.

Returns
int PRESSED_QUEUE_FRONT

Member Data Documentation

◆ address

qwiic_button.QwiicButton.address

◆ available_addresses

qwiic_button.QwiicButton.available_addresses = _AVAILABLE_I2C_ADDRESS
static

◆ BUTTON_DEBOUNCE_TIME

int qwiic_button.QwiicButton.BUTTON_DEBOUNCE_TIME = 0x05
static

◆ BUTTON_STATUS

int qwiic_button.QwiicButton.BUTTON_STATUS = 0x03
static

◆ clicked_enable [1/2]

int qwiic_button.QwiicButton.clicked_enable = 0
static

◆ clicked_enable [2/2]

qwiic_button.QwiicButton.clicked_enable

◆ clicked_is_empty [1/2]

int qwiic_button.QwiicButton.clicked_is_empty = 0
static

◆ clicked_is_empty [2/2]

qwiic_button.QwiicButton.clicked_is_empty

◆ clicked_is_full [1/2]

int qwiic_button.QwiicButton.clicked_is_full = 0
static

◆ clicked_is_full [2/2]

qwiic_button.QwiicButton.clicked_is_full

◆ clicked_pop_request [1/2]

int qwiic_button.QwiicButton.clicked_pop_request = 0
static

◆ clicked_pop_request [2/2]

qwiic_button.QwiicButton.clicked_pop_request

◆ CLICKED_QUEUE_BACK

int qwiic_button.QwiicButton.CLICKED_QUEUE_BACK = 0x15
static

◆ CLICKED_QUEUE_FRONT

int qwiic_button.QwiicButton.CLICKED_QUEUE_FRONT = 0x11
static

◆ CLICKED_QUEUE_STATUS

int qwiic_button.QwiicButton.CLICKED_QUEUE_STATUS = 0x10
static

◆ DEV_ID

int qwiic_button.QwiicButton.DEV_ID = 0x5D
static

◆ device_name

qwiic_button.QwiicButton.device_name = _DEFAULT_NAME
static

◆ event_available [1/2]

int qwiic_button.QwiicButton.event_available = 0
static

◆ event_available [2/2]

qwiic_button.QwiicButton.event_available

◆ FIRMWARE_MAJOR

int qwiic_button.QwiicButton.FIRMWARE_MAJOR = 0x02
static

◆ FIRMWARE_MINOR

int qwiic_button.QwiicButton.FIRMWARE_MINOR = 0x01
static

◆ has_been_clicked [1/2]

int qwiic_button.QwiicButton.has_been_clicked = 0
static

◆ has_been_clicked [2/2]

qwiic_button.QwiicButton.has_been_clicked

◆ I2C_ADDRESS

int qwiic_button.QwiicButton.I2C_ADDRESS = 0x1F
static

◆ ID

int qwiic_button.QwiicButton.ID = 0x00
static

◆ INTERRUPT_CONFIG

int qwiic_button.QwiicButton.INTERRUPT_CONFIG = 0x04
static

◆ is_pressed [1/2]

int qwiic_button.QwiicButton.is_pressed = 0
static

◆ is_pressed [2/2]

qwiic_button.QwiicButton.is_pressed

◆ LED_BRIGHTNESS

int qwiic_button.QwiicButton.LED_BRIGHTNESS = 0x19
static

◆ LED_PULSE_CYCLE_TIME

int qwiic_button.QwiicButton.LED_PULSE_CYCLE_TIME = 0x1B
static

◆ LED_PULSE_GRANULARITY

int qwiic_button.QwiicButton.LED_PULSE_GRANULARITY = 0x1A
static

◆ LED_PULSE_OFF_TIME

int qwiic_button.QwiicButton.LED_PULSE_OFF_TIME = 0x1D
static

◆ pressed_enable [1/2]

int qwiic_button.QwiicButton.pressed_enable = 0
static

◆ pressed_enable [2/2]

qwiic_button.QwiicButton.pressed_enable

◆ pressed_is_empty [1/2]

int qwiic_button.QwiicButton.pressed_is_empty = 0
static

◆ pressed_is_empty [2/2]

qwiic_button.QwiicButton.pressed_is_empty

◆ pressed_is_full [1/2]

int qwiic_button.QwiicButton.pressed_is_full = 0
static

◆ pressed_is_full [2/2]

qwiic_button.QwiicButton.pressed_is_full

◆ pressed_pop_request [1/2]

int qwiic_button.QwiicButton.pressed_pop_request = 0
static

◆ pressed_pop_request [2/2]

qwiic_button.QwiicButton.pressed_pop_request

◆ PRESSED_QUEUE_BACK

int qwiic_button.QwiicButton.PRESSED_QUEUE_BACK = 0x0C
static

◆ PRESSED_QUEUE_FRONT

int qwiic_button.QwiicButton.PRESSED_QUEUE_FRONT = 0x08
static

◆ PRESSED_QUEUE_STATUS

int qwiic_button.QwiicButton.PRESSED_QUEUE_STATUS = 0x07
static

The documentation for this class was generated from the following file: