@@ -203,7 +203,7 @@ def _read_reg(self, reg):
203203
204204 _MAG_LSB_TO_uT = 0.15 # 1.5 mG/LSB ≈ 0.15 µT/LSB
205205
206- def read_magnet_uT (self ):
206+ def read_magnet_uT (self ): # noqa: N802
207207 """Reads the magnetic field in µT, uncalibrated (simple conversion from LSB)."""
208208 x , y , z = self .read_magnet ()
209209 return (
@@ -220,7 +220,7 @@ def read_magnet_calibrated_norm(self):
220220 z = (z - self .z_off ) / self .z_scale
221221 return (x , y , z )
222222
223- def magnitude_uT (self ) -> float :
223+ def magnitude_uT (self ) -> float : # noqa: N802
224224 """Total magnetic field strength (µT)."""
225225 x , y , z = self .read_magnet_uT ()
226226 return math .sqrt (x * x + y * y + z * z )
@@ -328,11 +328,11 @@ def read_registers(self, start_addr: int, length: int) -> bytes:
328328 def read_all (self ) -> dict :
329329 """Grouped reading useful for debug & logs."""
330330 raw = self .read_magnet_raw ()
331- uT = self .read_magnet_uT ()
331+ mag_ut = self .read_magnet_uT ()
332332 cal = self .read_magnet_calibrated_norm ()
333- T = self .read_temperature_c ()
333+ temp = self .read_temperature_c ()
334334 st = self .read_status ()
335- return {"raw" : raw , "uT" : uT , "cal_norm" : cal , "tempC" : T , "status" : st }
335+ return {"raw" : raw , "uT" : mag_ut , "cal_norm" : cal , "tempC" : temp , "status" : st }
336336
337337 ##
338338 # --- CALIBRATIONS ---
@@ -508,9 +508,9 @@ def _filter_heading(self, angle_deg):
508508 self ._hf_cos = (1.0 - a ) * self ._hf_cos + a * c
509509 self ._hf_sin = (1.0 - a ) * self ._hf_sin + a * s
510510 # light normalization to avoid amplitude drift
511- NORMALIZATION_THRESHOLD = 1e-6
511+ norm_threshold = 1e-6
512512 norm = math .sqrt (self ._hf_cos * self ._hf_cos + self ._hf_sin * self ._hf_sin )
513- if norm > NORMALIZATION_THRESHOLD :
513+ if norm > norm_threshold :
514514 self ._hf_cos /= norm
515515 self ._hf_sin /= norm
516516 ang = math .degrees (math .atan2 (self ._hf_sin , self ._hf_cos ))
@@ -556,13 +556,13 @@ def heading_with_tilt_compensation(self, read_accel):
556556 roll = math .atan2 (ay , az )
557557 pitch = math .atan2 (- ax , math .sqrt (ay * ay + az * az ))
558558 # straighten the magnetic vector
559- Xh = x * math .cos (pitch ) + z * math .sin (pitch )
560- Yh = (
559+ xh = x * math .cos (pitch ) + z * math .sin (pitch )
560+ yh = (
561561 x * math .sin (roll ) * math .sin (pitch )
562562 + y * math .cos (roll )
563563 - z * math .sin (roll ) * math .cos (pitch )
564564 )
565- ang = math .degrees (math .atan2 (Yh , Xh )) # atan2(Yh, Xh )
565+ ang = math .degrees (math .atan2 (yh , xh ) )
566566 ang = self ._apply_heading_offsets (ang )
567567 return self ._filter_heading (ang )
568568
0 commit comments