Skip to content

Commit c175a9f

Browse files
author
brentru
committed
separate the pulse read and parsing to satisfy pylint
1 parent f18507a commit c175a9f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

adafruit_dymoscale.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def toggle_unit_button(self, switch_units=False):
9090
time.sleep(2)
9191
toggle_times += 1
9292

93-
def get_scale_data(self):
94-
"""Read a pulse of SPI data on a pin that corresponds to DYMO scale
95-
output protocol (12 bytes of data at about 14KHz), timeout is in seconds
93+
def _read_pulse(self):
94+
"""Reads a pulse of SPI data on a pin that corresponds to DYMO scale
95+
output protocol (12 bytes of data at about 14KHz).
9696
"""
9797
timestamp = time.monotonic()
9898
self.dymo.pause()
@@ -102,6 +102,11 @@ def get_scale_data(self):
102102
if (time.monotonic() - timestamp) > self.timeout:
103103
raise RuntimeError("Timed out waiting for data - is the scale turned on?")
104104
self.dymo.pause()
105+
106+
def get_scale_data(self):
107+
"""Reads a pulse of SPI data and analyzes the resulting data.
108+
"""
109+
self._read_pulse()
105110
bits = [0] * 96 # there are 12 bytes = 96 bits of data
106111
bit_idx = 0 # we will count a bit at a time
107112
bit_val = False # first pulses will be LOW
@@ -139,7 +144,7 @@ def get_scale_data(self):
139144
if data_bytes[2] & 0x1:
140145
weight *= -1
141146
print('Tare - press the tare button to reset the scale to zero.')
142-
if self.units == OUNCES:
147+
elif self.units == OUNCES:
143148
if data_bytes[4] & 0x80:
144149
data_bytes[4] -= 0x100
145150
print('Tare - press the tare button to reset the scale to zero.')

0 commit comments

Comments
 (0)