|
@@ -88,7 +88,7 @@ extern int monotonic_queue_get_len(struct monotonic_queue *mq);
|
|
|
struct jump_rope_count_config
|
|
|
{
|
|
|
float lg, hg, la, ha, lgz, hgz, a_g_window;
|
|
|
- int cy_window, cy_crit, cy_suppress_time, wait_time;
|
|
|
+ int cy_window, cy_crit, cy_suppress_time, wait_time, dead_zone_time;
|
|
|
};
|
|
|
|
|
|
struct jump_rope_count_device
|
|
@@ -96,8 +96,8 @@ struct jump_rope_count_device
|
|
|
struct schmidt trig_g, trig_a, trig_gz;
|
|
|
struct ringbuf rbuf_g, rbuf_a;
|
|
|
struct monotonic_queue mq_min_cy, mq_max_cy;
|
|
|
- int cy_window, cy_crit, cy_suppress_time, wait_time;
|
|
|
- int cy_suppress, remain_time;
|
|
|
+ int cy_window, cy_crit, cy_suppress_time, wait_time, dead_zone_time;
|
|
|
+ int cy_suppress, wait_remain_time, dead_zone_remain_time;
|
|
|
float last_cy, last_cy_fixed;
|
|
|
};
|
|
|
|
|
@@ -161,9 +161,11 @@ int jump_rope_count_device_init(struct jump_rope_count_device *dev,
|
|
|
dev->cy_crit = cfg->cy_crit;
|
|
|
dev->cy_suppress_time = cfg->cy_suppress_time;
|
|
|
dev->wait_time = cfg->wait_time;
|
|
|
+ dev->dead_zone_time = cfg->dead_zone_time;
|
|
|
|
|
|
dev->cy_suppress = 0;
|
|
|
dev->last_cy = dev->last_cy_fixed = 0;
|
|
|
+ dev->wait_remain_time = dev->dead_zone_time = 0;
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -248,17 +250,23 @@ int process_packet(struct jump_rope_count_device *dev,
|
|
|
|
|
|
if (schmidt_trig(&dev->trig_gz, gz) == 1 &&
|
|
|
schmidt_get(&dev->trig_gz) == 0 &&
|
|
|
- dev->cy_suppress == 0)
|
|
|
+ dev->cy_suppress == 0 &&
|
|
|
+ dev->dead_zone_remain_time == 0)
|
|
|
{
|
|
|
- dev->remain_time = dev->wait_time;
|
|
|
+ dev->wait_remain_time = dev->wait_time;
|
|
|
+ dev->dead_zone_remain_time = dev->dead_zone_time;
|
|
|
*result = RESULT_TRIGGERED;
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
- if (dev->remain_time)
|
|
|
- dev->remain_time--;
|
|
|
+ if (dev->wait_remain_time)
|
|
|
+ dev->wait_remain_time--;
|
|
|
|
|
|
- *result = (dev->remain_time > 0 ? RESULT_NONE : RESULT_INACTIVE);
|
|
|
+ if (dev->dead_zone_remain_time)
|
|
|
+ dev->dead_zone_remain_time--;
|
|
|
+
|
|
|
+ *result = (dev->wait_remain_time > 0 ? RESULT_NONE :
|
|
|
+ RESULT_INACTIVE);
|
|
|
out:
|
|
|
if (dev->cy_suppress > 0)
|
|
|
dev->cy_suppress--;
|
|
@@ -453,6 +461,7 @@ int main()
|
|
|
cfg.cy_crit = 200;
|
|
|
cfg.cy_suppress_time = fs * 0.2;
|
|
|
cfg.wait_time = fs * 1;
|
|
|
+ cfg.dead_zone_time = fs * 0.2;
|
|
|
|
|
|
if (jump_rope_count_device_init(&dev, &cfg) != 0)
|
|
|
abort();
|