diff --git a/config.py b/config.py index c499777..12f8900 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,7 @@ EVENT_THRESH = 45 #when to detect an event STD_MAX = 20 #stdev above which we skip the event -POLL_RATE = 0.2 #latency on detection vs cpu/usage +POLL_RATE = 0.1 #latency on detection vs cpu/usage GRAPH_DRAW_EVERY_FRAMES = 1 # skip frames, increase on older/slower devices GRAPH_FREEZE = 4 #how many seconds to freeze graphs after shot is detected:w diff --git a/main.py b/main.py index 5205748..9c1041b 100644 --- a/main.py +++ b/main.py @@ -215,7 +215,7 @@ def get_value(self): acc_time = acc_points_t[self.event_time_idx] debug = None if acc_time > points_t[-1]: - debug = 'accelerometer in future' + debug = 'accelerometer in the future' event_time_idx = len(points_t) - 1 else: event_time_idx = np.argmax(points_t >= acc_time) @@ -229,7 +229,7 @@ def get_value(self): log.warning(f"detect: '{debug}' ori: idx={event_time_idx}/{len(points_t)-1} buf={points_t[-6:]}\nacc_time: {acc_time} acc_idx={self.event_time_idx}/{len(acc_points_t)-1}") # remove a few samples that may have been contaminated with the event TODO: use mcmc or some other method to remove contaminated samples? - event_time_idx -= 5 + event_time_idx -= 7 orig_points = points orig_points_t = points_t @@ -258,8 +258,8 @@ def get_value(self): if detected: self.update_cnt = -int(GRAPH_FREEZE / POLL_RATE) #freeze graph after event - return True, points, std - return False, points, std + return True, acc_points, points, std + return False, acc_points, points, std class AccelerometerScreen(CommonScreen): @@ -286,7 +286,7 @@ def start(self): self.update_cnt = 0 def get_value(self, dt): - draw, points, _ = super().get_value() + draw, points, _, _ = super().get_value() if draw: gr = self.ids.graph gr.ymax = min(ACCELEROMETER_Y_LIMIT, max(1, int(points.max() + 1))) @@ -323,7 +323,7 @@ def start(self): self.update_cnt = 0 def get_value(self, dt): - draw, points, std = super().get_value() + draw, _, points, std = super().get_value() if draw: for i, plot in enumerate(self.plots):