Skip to content

Commit 4f5aec7

Browse files
authored
Merge pull request #2383 from CedarGroveStudios/main
Update to be compatible with latest version of NAU7802 driver Thank you!!
2 parents b06fd02 + f5f1667 commit 4f5aec7

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

Clue_Scale/clue_scale_calibrator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: MIT
33
#
44
# clue_scale_calibrator.py
5-
# 2022-07-29 v1.1.0
5+
# 2023-01-13 v1.1.1
66
#
77
# Clue Scale Calibrator - Single Channel Version
88
# Adafruit NAU7802 Stemma breakout example
@@ -15,7 +15,7 @@
1515
clue.pixel.brightness = 0.2 # Set NeoPixel brightness
1616
clue.pixel[0] = clue.YELLOW # Set status indicator to yellow (initializing)
1717

18-
SAMPLE_AVG = 500 # Number of sample values to average
18+
SAMPLE_AVG = 3 # Number of sample values to average
1919
DEFAULT_GAIN = 128 # Default gain for internal PGA
2020

2121
# Instantiate 24-bit load sensor ADC
@@ -37,7 +37,7 @@ def read(samples=100):
3737
sample_sum = 0
3838
sample_count = samples
3939
while sample_count > 0:
40-
if nau7802.available:
40+
if nau7802.available():
4141
sample_sum = sample_sum + nau7802.read()
4242
sample_count -= 1
4343
return int(sample_sum / samples)

Clue_Scale/code.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# SPDX-FileCopyrightText: 2022 Jan Goolsbey for Adafruit Industries
1+
# SPDX-FileCopyrightText: 2023 Jan Goolsbey for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33
#
44
# clue_scale_code.py
5-
# 2022-07-29 v1.2.0
5+
# 2023-01-13 v1.2.1
66
#
77
# Clue Scale - Single Channel Version
88
# Adafruit NAU7802 Stemma breakout example
@@ -25,7 +25,7 @@
2525
# Set Scale Defaults
2626
MAX_GR = 100 # Maximum (full-scale) display range in grams
2727
DEFAULT_GAIN = 128 # Default gain for internal PGA
28-
SAMPLE_AVG = 100 # Number of sample values to average
28+
SAMPLE_AVG = 5 # Number of sample values to average
2929
SCALE_NAME_1 = "COFFEE" # 6 characters maximum
3030
SCALE_NAME_2 = "SCALE" # 6 characters maximum
3131

@@ -128,12 +128,12 @@ def zero_channel():
128128
nau7802.calibrate("OFFSET")
129129

130130

131-
def read(samples=100):
131+
def read(samples=1):
132132
"""Read and average consecutive raw samples; return averaged value."""
133133
sample_sum = 0
134134
sample_count = samples
135135
while sample_count > 0:
136-
if nau7802.available:
136+
if nau7802.available():
137137
sample_sum = sample_sum + nau7802.read()
138138
sample_count -= 1
139139
return int(sample_sum / samples)

0 commit comments

Comments
 (0)