Skip to content

Commit c7d4a19

Browse files
committed
Update is_full and pop_request functions & bump version numbers
Some queue functions needed to be updated because of the bug found in the Qwiic Button Firmware. The register map defined bit fields in reverse order. This way, the user will be able to actually pop the is_pressed/is_clicked queues
1 parent 2c559ec commit c7d4a19

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'SparkFun Electronics'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '2.0.0'
25+
release = '2.0.1'
2626

2727

2828
# -- General configuration ---------------------------------------------------

qwiic_button.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ def is_pressed_queue_full(self):
473473
# First, read the PRESSED_QUEUE_STATUS register
474474
pressed_queue_stat = self._i2c.readByte(self.address, self.PRESSED_QUEUE_STATUS)
475475
# Convert to binary and clear all bits but isFull
476-
self.pressed_is_full = int(pressed_queue_stat) & ~(0xFE)
476+
self.pressed_is_full = int(pressed_queue_stat) & ~(0xFB)
477+
self.pressed_is_full = self.pressed_is_full >> 2
477478
# Return pressed_is_full as a bool
478479
return bool(self.pressed_is_full)
479480

@@ -554,7 +555,7 @@ def pop_pressed_queue(self):
554555
pressed_queue_stat = self._i2c.readByte(self.address, self.PRESSED_QUEUE_STATUS)
555556
self.pressed_pop_request = 1
556557
# Set pop_request bit to 1
557-
pressed_queue_stat = pressed_queue_stat | (self.pressed_pop_request << 2)
558+
pressed_queue_stat = pressed_queue_stat | (self.pressed_pop_request)
558559
self._i2c.writeByte(self.address, self.PRESSED_QUEUE_STATUS, pressed_queue_stat)
559560
return temp_data
560561

@@ -573,7 +574,8 @@ def is_clicked_queue_full(self):
573574
# First, read the CLICKED_QUEUE_STATUS register
574575
clicked_queue_stat = self._i2c.readByte(self.address, self.CLICKED_QUEUE_STATUS)
575576
# Convert to binary and clear all bits but clicked_is_full
576-
self.clicked_is_full = int(clicked_queue_stat) & ~(0xFE)
577+
self.clicked_is_full = int(clicked_queue_stat) & ~(0xFB)
578+
self.clicked_is_full = self.clicked_is_full >> 2
577579
# Return clicked_is_full as a bool
578580
return bool(self.clicked_is_full)
579581

@@ -654,7 +656,7 @@ def pop_clicked_queue(self):
654656
clicked_queue_stat = self._i2c.readByte(self.address, self.CLICKED_QUEUE_STATUS)
655657
self.clicked_pop_request = 1
656658
# Set pop_request bit to 1
657-
clicked_queue_stat = clicked_queue_stat | (self.clicked_pop_request << 2)
659+
clicked_queue_stat = clicked_queue_stat | (self.clicked_pop_request)
658660
self._i2c.writeByte(self.address, self.CLICKED_QUEUE_STATUS, clicked_queue_stat)
659661
return temp_data
660662

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
# Versions should comply with PEP440. For a discussion on single-sourcing
5353
# the version across setup.py and the project code, see
5454
# http://packaging.python.org/en/latest/tutorial.html#version
55-
version='2.0.0',
55+
version='2.0.1',
5656

5757
description='SparkFun Electronics qwiic button package',
5858
long_description='This package allows the user to: determine whether or not the button/switch is pressed or has been clicked, \

0 commit comments

Comments
 (0)