pushups: stop detection when buzzing

pull/3669/head
frederic wagner 2024-01-23 16:13:31 +01:00
parent 926b2ef04c
commit 3b52354098
1 changed files with 7 additions and 0 deletions

View File

@ -79,6 +79,7 @@ class FitnessStatus {
]; ];
this.routine_step = 0; this.routine_step = 0;
this.current_status = 0; this.current_status = 0;
this.buzzing = false;
// to get rid of noise we'll need to count how many measures confirm where we think we are // to get rid of noise we'll need to count how many measures confirm where we think we are
this.counts_in_opposite_status = 0; this.counts_in_opposite_status = 0;
@ -157,6 +158,7 @@ class FitnessStatus {
this.activity_start = getTime(); this.activity_start = getTime();
this.current_status = 0; this.current_status = 0;
this.counts_in_opposite_status = 0; this.counts_in_opposite_status = 0;
this.buzzing = false;
} }
previous_activity() { previous_activity() {
@ -169,12 +171,16 @@ class FitnessStatus {
} }
detect(xyz) { detect(xyz) {
if (this.buzzing) {
return;
}
let activity = this.routine[this.routine_step][0]; let activity = this.routine[this.routine_step][0];
let detector = DETECTORS[activity]; let detector = DETECTORS[activity];
if (detector === null) { if (detector === null) {
// it's time based // it's time based
let activity_duration = getTime() - this.activity_start; let activity_duration = getTime() - this.activity_start;
if (activity_duration > this.remaining) { if (activity_duration > this.remaining) {
this.buzzing = true;
Bangle.buzz(500).then(() => { Bangle.buzz(500).then(() => {
status.next_activity(); status.next_activity();
}); });
@ -197,6 +203,7 @@ class FitnessStatus {
this.remaining -= 1; this.remaining -= 1;
// this.display(); // this.display();
if (this.remaining == 0) { if (this.remaining == 0) {
this.buzzing = true;
Bangle.buzz(500).then(() => { Bangle.buzz(500).then(() => {
status.next_activity(); status.next_activity();
}); });