File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -90,9 +90,9 @@ def toggle_unit_button(self, switch_units=False):
90
90
time .sleep (2 )
91
91
toggle_times += 1
92
92
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).
96
96
"""
97
97
timestamp = time .monotonic ()
98
98
self .dymo .pause ()
@@ -102,6 +102,11 @@ def get_scale_data(self):
102
102
if (time .monotonic () - timestamp ) > self .timeout :
103
103
raise RuntimeError ("Timed out waiting for data - is the scale turned on?" )
104
104
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 ()
105
110
bits = [0 ] * 96 # there are 12 bytes = 96 bits of data
106
111
bit_idx = 0 # we will count a bit at a time
107
112
bit_val = False # first pulses will be LOW
@@ -139,7 +144,7 @@ def get_scale_data(self):
139
144
if data_bytes [2 ] & 0x1 :
140
145
weight *= - 1
141
146
print ('Tare - press the tare button to reset the scale to zero.' )
142
- if self .units == OUNCES :
147
+ elif self .units == OUNCES :
143
148
if data_bytes [4 ] & 0x80 :
144
149
data_bytes [4 ] -= 0x100
145
150
print ('Tare - press the tare button to reset the scale to zero.' )
You can’t perform that action at this time.
0 commit comments