@@ -215,6 +215,7 @@ def __init__( # pylint: disable=too-many-arguments
215
215
filt : int = FILTER_7 ,
216
216
oversampling : int = OSR_3 ,
217
217
temperature_compensation : bool = False ,
218
+ temperature_oversampling : int = OSR_0 ,
218
219
offset : int = 0 ,
219
220
debug : bool = False ,
220
221
) -> None :
@@ -226,6 +227,7 @@ def __init__( # pylint: disable=too-many-arguments
226
227
self ._osr = oversampling
227
228
self ._gain_current = gain
228
229
self ._temperature_compensation = temperature_compensation
230
+ self ._osr2 = temperature_oversampling
229
231
# Typical value according the application note
230
232
self ._tref = 0xB668
231
233
self ._off_x = self ._off_y = self ._off_z = offset
@@ -247,6 +249,7 @@ def __init__( # pylint: disable=too-many-arguments
247
249
# Set gain to the supplied level
248
250
self .gain = self ._gain_current
249
251
self .temperature_compensation = self ._temperature_compensation
252
+ self .temperature_oversampling = self ._osr2
250
253
251
254
# Set offsets to supplied level
252
255
self .offset_x = self ._off_x
@@ -387,7 +390,7 @@ def filter(self, level: int) -> None:
387
390
388
391
@property
389
392
def oversampling (self ) -> int :
390
- """The oversampling level."""
393
+ """The magnetic sensor oversampling level."""
391
394
return self ._osr
392
395
393
396
@oversampling .setter
@@ -414,6 +417,21 @@ def temperature_compensation(self, temperature_compensation: bool) -> None:
414
417
self .write_reg (_CMD_REG_CONF2 , reg )
415
418
self ._temperature_compensation = temperature_compensation
416
419
420
+ @property
421
+ def temperature_oversampling (self ) -> int :
422
+ """The temperature sensor oversampling level."""
423
+ return self ._osr2
424
+
425
+ @temperature_oversampling .setter
426
+ def temperature_oversampling (self , level : int ) -> None :
427
+ if level not in range (4 ):
428
+ raise ValueError ("Incorrect oversampling level." )
429
+ reg = self .read_reg (_CMD_REG_CONF3 )
430
+ reg &= 0xE7FF
431
+ reg |= (level & 0x3 ) << 12
432
+ self .write_reg (_CMD_REG_CONF3 , reg )
433
+ self ._osr2 = level
434
+
417
435
@property
418
436
def offset_x (self ) -> int :
419
437
"""The X axis offset."""
0 commit comments