@@ -61,10 +61,10 @@ def pressure_string(pressure_type):
61
61
return pressure_str
62
62
63
63
def check_for_puff (self , current_pressure ):
64
+ """Updates the internal state to detect if a sip/puff has been started or stopped"""
64
65
puff_polarity = None
65
66
puff_peak_level = None
66
67
puff_duration = None
67
- #######################
68
68
polarity , level = self .catagorize_pressure (current_pressure )
69
69
70
70
# if (polarity != 0) or (level != 0):
@@ -94,48 +94,3 @@ def check_for_puff(self, current_pressure):
94
94
self .duration = 0
95
95
self .counter += 1
96
96
return (puff_polarity , puff_peak_level , puff_duration )
97
- ##############################################
98
-
99
-
100
- # pylint:disable=pointless-string-statement
101
- """
102
- pressure_list = []
103
- prev_pressure_type = tuple()
104
- prev_polarity = None
105
- current_level = 0
106
- prev_level = 0
107
-
108
- def old_detect(self):
109
- if pressure_type != prev_pressure_type:
110
- puff_end = time.monotonic()
111
- puff_duration = puff_end - puff_start
112
- puff_start = puff_end
113
- if DEBUG and CONSOLE: print("\t pressure type:", pressure_type)
114
- if DEBUG and CONSOLE: print("duration:", puff_duration)
115
- if CONSOLE: print("polarity:", polarity, "level:", level)
116
-
117
- # hack to handle triggering twice on the way up or down
118
- if (polarity == 1) and (prev_level > level):
119
- if CONSOLE: print("Down")
120
- puff_duration += prev_duration
121
- level = prev_level
122
- if (polarity == -1) and (prev_level < level):
123
- if CONSOLE: print("Up")
124
- puff_duration += prev_duration
125
- level = prev_level
126
-
127
- if DEBUG and CONSOLE: print("polarity:", polarity, "level:", level)
128
- if puff_duration > 0.2:
129
- if CONSOLE: print("polarity:", polarity, "level:", level)
130
-
131
- if CONSOLE: print("\t duration:", puff_duration)
132
- if DEBUG and CONSOLE: print(current_pressure)
133
- label = detector.pressure_string((polarity, level))
134
- label = detector.pressure_string(pressure_type)
135
- if CONSOLE: print("\t \t \t \t ", label)
136
- if CONSOLE: print("____________________")
137
- prev_pressure_type = pressure_type
138
- prev_duration = puff_duration
139
- prev_level = level
140
- prev_level = level
141
- """
0 commit comments