Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit cfad2e7

Browse files
committed
address pr comments
1 parent 4e0988e commit cfad2e7

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/base_circuitpython/base_cp_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class CLUE_STATE:
3131
CPX = "CPX"
3232
CLUE = "CLUE"
3333
PIXELS = "pixels"
34+
SHAKE = "shake"
3435

3536
CLUE_PIN = "D18"
3637

src/clue/adafruit_clue.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ def __init__(self):
229229
self.__state[CONSTANTS.CLUE_STATE.GYRO_X] = 0
230230
self.__state[CONSTANTS.CLUE_STATE.GYRO_Y] = 0
231231
self.__state[CONSTANTS.CLUE_STATE.GYRO_Z] = 0
232+
self.button_mapping = {
233+
CONSTANTS.CLUE_STATE.BUTTON_A: "A",
234+
CONSTANTS.CLUE_STATE.BUTTON_B: "B",
235+
}
232236

233237
@property
234238
def button_a(self):
@@ -297,7 +301,7 @@ def shake(self, shake_threshold=30, avg_count=10, total_delay=0.1):
297301
:param total_delay: The total time in seconds it takes to obtain avg_count
298302
readings from acceleration. (Default 0.1)
299303
"""
300-
is_shaken = self.__state[CONSTANTS.CLUE_STATE.GESTURE] == "shake"
304+
is_shaken = self.__state[CONSTANTS.CLUE_STATE.GESTURE] == CONSTANTS.SHAKE
301305
return is_shaken
302306

303307
@property
@@ -418,6 +422,7 @@ def altitude(self):
418422
clue.sea_level_pressure = 1015
419423
print("Altitude: {:.1f}m".format(clue.altitude))
420424
"""
425+
# National Oceanic and Atmospheric Administration (NOAA) formula for converting atmospheric pressure to pressure altitude.
421426
altitude = 44330 * (
422427
1.0
423428
- math.pow(
@@ -730,13 +735,9 @@ def update_state(self, new_state):
730735

731736
# helpers
732737
def __update_button(self, button, value):
733-
buttonMapping = {
734-
CONSTANTS.CLUE_STATE.BUTTON_A: "A",
735-
CONSTANTS.CLUE_STATE.BUTTON_B: "B",
736-
}
737738
if value:
738739
self.__state[CONSTANTS.CLUE_STATE.PRESSED_BUTTONS].add(
739-
buttonMapping[button]
740+
self.button_mapping[button]
740741
)
741742
self.__state[button] = value
742743

0 commit comments

Comments
 (0)