Skip to content

Commit 2833073

Browse files
committed
display bugfix
1 parent b11b6e0 commit 2833073

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

SipNPyuff/code.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,16 @@
8181
######################################
8282
current_pressure = lps.pressure
8383
pressure_string = "Pressure: %0.3f" % current_pressure
84-
if not CONSOLE:
84+
if CONSOLE:
85+
print(pressure_string)
86+
else:
8587
print((current_pressure,))
88+
8689
puff_polarity, puff_peak_level, puff_duration = detector.check_for_puff(
8790
current_pressure
8891
)
92+
if CONSOLE:
93+
print("STATE:", detector.state)
8994
if DEBUG and CONSOLE:
9095
print(
9196
"Pol: %s Peak: %s Dir: %s"
@@ -95,7 +100,9 @@
95100
# if puff_duration:
96101
if detector.state == DETECTED:
97102
state = DETECTED
98-
duration_string = "Duration: %0.2f" % puff_duration
103+
duration_string = (
104+
"Duration: %0.2f" % puff_duration
105+
) # puff duration can be none? after detect?
99106
state_string = "DETECTED:"
100107
print(state_string)
101108
if puff_peak_level == 1:
@@ -130,11 +137,9 @@
130137
state = WAITING
131138
if (curr_time - state_display_start) > state_display_timeout:
132139
state_string = "Waiting for Input"
133-
detector_result_string = " "
140+
input_type_string = " "
134141
duration_string = " "
135142

136-
if CONSOLE:
137-
print("STATE:", state)
138143
# Create the tet label
139144
print((curr_time - state_display_start))
140145

@@ -145,6 +150,12 @@
145150
detector_result = label.Label(font, text=input_type_string, color=color)
146151
duration = label.Label(font, text=duration_string, color=color)
147152
pressure_label = label.Label(font, text=pressure_string, color=color)
153+
if CONSOLE:
154+
print(banner.text)
155+
print(state.text)
156+
print(detector_result.text)
157+
print(duration.text)
158+
print(pressure_label.text)
148159

149160
banner.x = 0
150161
banner.y = 0 + Y_OFFSET

SipNPyuff/puff_detector.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,15 @@ def check_for_puff(self, current_pressure):
7272
puff_peak_level = None
7373
puff_duration = None
7474
polarity, level = self.catagorize_pressure(current_pressure)
75-
75+
if CONSOLE:
76+
print("pol", polarity, "lev:", level)
7677
if self.state == DETECTED:
77-
if polarity == 0 and level == 0:
78-
self.state = WAITING
78+
# if polarity == 0 and level == 0:
79+
self.state = WAITING
7980

81+
self.start_polarity = 0
82+
self.peak_level = 0
83+
self.duration = 0
8084
if level != 0 and self.start_polarity == 0:
8185
self.state = STARTED
8286
self.start_polarity = polarity
@@ -95,8 +99,5 @@ def check_for_puff(self, current_pressure):
9599
puff_peak_level = self.peak_level
96100
puff_duration = self.duration
97101

98-
self.start_polarity = 0
99-
self.peak_level = 0
100-
self.duration = 0
101102
self.counter += 1
102103
return (self.start_polarity, puff_peak_level, puff_duration)

0 commit comments

Comments
 (0)