@@ -186,8 +186,7 @@ class LSM6DS: # pylint: disable=too-many-instance-attributes
186
186
_raw_temp_data = Struct (_LSM6DS_OUT_TEMP_L , "<h" )
187
187
_emb_func_en_a = Struct (_LSM6DS_EMB_FUNC_EN_A , "<b" )
188
188
_emb_func_en_b = Struct (_LSM6DS_EMB_FUNC_EN_B , "<b" )
189
- _mlc0_src = Struct (_LSM6DS_MLC0_SRC , "<b" )
190
- # _all_int = Struct(_LSM6DS_ALL_INT_SRC, "<bbbbbbbb")
189
+ _mlc0_src = Struct (_LSM6DS_MLC0_SRC , "<bbbbbbbb" )
191
190
# RWBits:
192
191
_accel_range = RWBits (2 , _LSM6DS_CTRL1_XL , 2 )
193
192
_accel_data_rate = RWBits (4 , _LSM6DS_CTRL1_XL , 4 )
@@ -241,7 +240,6 @@ def __init__(
241
240
self .accelerometer_range = AccelRange .RANGE_4G # pylint: disable=no-member
242
241
self .gyro_range = GyroRange .RANGE_250_DPS # pylint: disable=no-member
243
242
# Load and configure MLC if UCF file is provided
244
- print (ucf )
245
243
if ucf is not None :
246
244
self .load_mlc (ucf )
247
245
@@ -406,17 +404,15 @@ def temperature(self) -> float:
406
404
407
405
return temp * 0.0625
408
406
409
- def set_embedded_functions (self , enable , emb_ab = None ):
410
- """DocString Here """
407
+ def _set_embedded_functions (self , enable , emb_ab = None ):
408
+ """Enable/disable embedded functions - returns prior settings when disabled """
411
409
self ._mem_bank = 1
412
410
if enable :
413
411
self ._emb_func_en_a = emb_ab [0 ]
414
412
self ._emb_func_en_b = emb_ab [1 ]
415
413
else :
416
414
emb_a = self ._emb_func_en_a
417
415
emb_b = self ._emb_func_en_b
418
- print (emb_a )
419
- print (emb_b )
420
416
self ._emb_func_en_a = (emb_a [0 ] & 0xC7 ,)
421
417
self ._emb_func_en_b = (emb_b [0 ] & 0xE6 ,)
422
418
emb_ab = (emb_a , emb_b )
@@ -425,20 +421,20 @@ def set_embedded_functions(self, enable, emb_ab=None):
425
421
return emb_ab
426
422
427
423
def load_mlc (self , ucf ):
428
- """DOCString Here """
424
+ """Load MLC configuration file into sensor """
429
425
buf = bytearray (2 )
430
426
with self .i2c_device as i2c :
431
427
# Load MLC config from file
432
428
with open (ucf , "r" ) as ucf_file :
433
429
for line in ucf_file :
434
430
if line .startswith ("Ac" ):
435
431
command = [int (v , 16 ) for v in line .strip ().split (" " )[1 :3 ]]
436
- print (line )
437
432
buf [0 ] = command [0 ]
438
433
buf [1 ] = command [1 ]
439
434
i2c .write (buf )
440
435
441
- emb_ab = self .set_embedded_functions (False )
436
+ # Disable embudded function -- save current settings
437
+ emb_ab = self ._set_embedded_functions (False )
442
438
443
439
# Disable I3C interface
444
440
self ._i3c_disable = 1
@@ -449,19 +445,19 @@ def load_mlc(self, ucf):
449
445
# Route signals on interrupt pin 1
450
446
self ._mem_bank = 1
451
447
self ._route_int1 &= 1
452
- self ._mem_bank = 1
448
+ self ._mem_bank = 0
453
449
454
450
# Configure interrupt pin mode
455
451
self ._tap_latch = 1
456
452
self ._tap_clear = 1
457
453
458
- self .set_embedded_functions (True , emb_ab )
454
+ # Enabble Embedded Functions using previously stored settings
455
+ self ._set_embedded_functions (True , emb_ab )
459
456
460
457
def read_mlc_output (self ):
461
- """DOCString here """
458
+ """Read MLC results """
462
459
buf = None
463
460
if self ._mlc_status :
464
- # junk = self._all_int
465
461
self ._mem_bank = 1
466
462
buf = self ._mlc0_src
467
463
self ._mem_bank = 0
0 commit comments