#include #include #include const int fs = 50; int main() { struct jump_rope_count_config cfg; struct jump_rope_count_device dev; struct sensor_packet packet; int count = 0, ret; enum jump_rope_count_result result; cfg.lg = 0.5; cfg.hg = 1.5; cfg.la = 4.0; cfg.ha = 6.0; cfg.lgz = -1.5; cfg.hgz = 2; cfg.a_g_window = 100; cfg.cy_window = fs * 0.1; cfg.cy_crit = 200; cfg.cy_suppress_time = fs * 0.2; cfg.wait_time = fs * 1; if (jump_rope_count_device_init(&dev, &cfg) != 0) abort(); while (scanf("%f%f%f%f%f%f%f", &packet.gx, &packet.gy, &packet.gz, &packet.ax, &packet.ay, &packet.az, &packet.cy) == 7) { ret = process_packet(&dev, &packet, &result); if (ret != 0) abort(); if (result == RESULT_INACTIVE) { if (count > 1) printf("%d\n", count - 1); count = 0; } else if (result == RESULT_TRIGGERED) count += 1; } if (count > 1) printf("%d\n", count - 1); return 0; } /* vim: set ts=8 sw=8 sts=8 noet: */