addGyro method

void addGyro(
  1. SensorEvent event
)

Adds a new gyroscope event to update the angle and notifies listeners if movement is detected.

Implementation

void addGyro(SensorEvent event) {
  final now = DateTime.now();
  double value = _calculateMagnitude(event);
  bool isMoving = value.abs() > threshold;

  if (_lastTime != null && isMoving) {
    final dt = now.difference(_lastTime!).inMicroseconds / 1e6;
    _angle += value * dt;
    liveAngle.value = _angle;
  }
  _lastTime = now;
}