Skip to content

Commit 7b865af

Browse files
committed
lis2mdl : fix remove duplicate.
1 parent 488ba5b commit 7b865af

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

lib/lis2mdl/exemple/magnet_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def test_heading_after_calib(dev, n=200, delay_ms=20):
400400
maxA = max(angles)
401401
span = (maxA - minA) % 360.0
402402
print("Angle min={:.1f}°, max={:.1f}°, span~{:.1f}°".format(minA, maxA, span))
403-
print("=> If you rotated ~one complete turn flat, we expect ~300360° span.")
403+
print("=> If you rotated ~one complete turn flat, we expect ~300-360° span.")
404404

405405

406406
def run_all_calibration_tests(dev):

lib/lis2mdl/lis2mdl/device.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,19 +420,11 @@ def calibrate_step(self):
420420
# --- Heading functions ---
421421
##
422422

423-
_heading_offset_deg = 0.0 # user setting: align your physical 0°
424-
_declination_deg = 0.0 # true north vs magnetic north
425423
# angle filter via vector averaging (robust around 0/360)
426424
_hf_alpha = 0.0
427425
_hf_cos = None
428426
_hf_sin = None
429427

430-
def set_heading_offset(self, deg: float):
431-
self._heading_offset_deg = float(deg)
432-
433-
def set_declination(self, deg: float):
434-
self._declination_deg = float(deg)
435-
436428
def set_heading_filter(self, alpha: float):
437429
"""
438430
alpha=0 -> no filtering. 0.1..0.3 = light/medium smoothing.
@@ -465,8 +457,9 @@ def _filter_heading(self, angle_deg):
465457
self._hf_cos = (1.0 - a) * self._hf_cos + a * c
466458
self._hf_sin = (1.0 - a) * self._hf_sin + a * s
467459
# light normalization to avoid amplitude drift
460+
NORMALIZATION_THRESHOLD = 1e-6
468461
norm = math.sqrt(self._hf_cos * self._hf_cos + self._hf_sin * self._hf_sin)
469-
if norm > 1e-6:
462+
if norm > NORMALIZATION_THRESHOLD:
470463
self._hf_cos /= norm
471464
self._hf_sin /= norm
472465
ang = math.degrees(math.atan2(self._hf_sin, self._hf_cos))

0 commit comments

Comments
 (0)