Skip to content

Commit

Permalink
Take last 20 magnetometer readings for metal detector calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Nov 23, 2023
1 parent 4345263 commit d0366f1
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class FragmentToolMetalDetector : BoundFragment<FragmentToolMetalDetectorBinding
}

private fun calibrate(){
referenceMagnitude = readings.average().toFloat()
referenceMagnitude = readings.takeLast(20).average().toFloat()
calibratedField = lowPassMagnetometer.magneticField
calibratedOrientation = orientation.orientation
calibrateTimer.stop()
Expand Down

0 comments on commit d0366f1

Please sign in to comment.