     default: return -1; // other button
   }
 }
-
-void test_speed(int angle) {
-  for (int i = 0; i < 20; ++i) {
-    myservo.write(90 - angle);
-    delay(300);
-    myservo.write(90 + angle);
-    delay(300);
-  }
-}


  if (previous_servo_move && current_millis - previous_servo_move >= SERVO_INTERVAL) {
    // check if it should return
    if (current_angle >= 60000 / current_bpm * 4 / 5 / (2 * SERVO_INTERVAL / DEGREE_STEP)) {
      --current_angle;
      current_velocity_positive = !current_velocity_positive;
    }
    // move the servo
    current_angle += (current_velocity_positive ? 1 : -1) * DEGREE_STEP;
    myservo.write(SERVO_BASE_ANGLE + current_angle);
    if (current_angle == 0 && !current_velocity_positive) {
      previous_servo_move = 0;
    } else {
      previous_servo_move += SERVO_INTERVAL;
    }
  }
}

void flash_beat(bool is_downbeat, unsigned long current_millis) {
  digitalWrite(LED_BUILTIN, HIGH);
  digitalWrite(is_downbeat ? RED : BLUE, HIGH);
  digitalWrite(is_downbeat ? LED_1 : LED_2, HIGH);
  start_servo(current_millis);
  (is_downbeat ? previous_blink_downbeat : previous_blink_upbeat) = current_millis;
}

void stop_beat() {
  digitalWrite(LED_BUILTIN, LOW);
  digitalWrite(RED, LOW);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, LOW);
  digitalWrite(LED_1, LOW);
  digitalWrite(LED_2, LOW);
}

void stop_blink(bool is_downbeat) {
  digitalWrite(LED_BUILTIN, LOW);
  digitalWrite(is_downbeat ? RED : BLUE, LOW);
  digitalWrite(is_downbeat ? LED_1 : LED_2, LOW);
  (is_downbeat ? previous_blink_downbeat : previous_blink_upbeat) = 0;
}

  Serial.begin(9600);

  // initialize digital pin LED_BUILTIN as an output.
  // pinMode(LED_BUILTIN, OUTPUT);
  // pinMode(RED, OUTPUT);
  // pinMode(GREEN, OUTPUT);
  // pinMode(BLUE, OUTPUT);
  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);

  // digitalWrite(LED_BUILTIN, LOW);
  // digitalWrite(RED, LOW);
  // digitalWrite(GREEN, LOW);
  // digitalWrite(BLUE, LOW);
  digitalWrite(LED_1, LOW);
  digitalWrite(LED_2, LOW);

