@@ -165,15 +165,6 @@ def __init__(self, i2c, address=0x6B, acc_range="2g", acc_data_rate="1.6Hz",
165165 print ("[WSEN_ISDS] Waiting 100ms for sensors to stabilize..." )
166166 time .sleep_ms (100 )
167167
168- # Debug: Read all control registers to see full sensor state
169- print ("[WSEN_ISDS] === Sensor State After Initialization ===" )
170- for reg_addr in [0x10 , 0x11 , 0x12 , 0x13 , 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 ]:
171- try :
172- reg_val = self .i2c .readfrom_mem (self .address , reg_addr , 1 )[0 ]
173- print (f"[WSEN_ISDS] Reg 0x{ reg_addr :02x} (CTRL{ reg_addr - 0x0f } ): 0x{ reg_val :02x} = 0b{ reg_val :08b} " )
174- except :
175- pass
176-
177168 print ("[WSEN_ISDS] Initialization complete" )
178169
179170 def get_chip_id (self ):
@@ -193,7 +184,6 @@ def _write_option(self, option, value):
193184 config_value &= opt ["mask" ]
194185 config_value |= (bits << opt ["shift_left" ])
195186 self .i2c .writeto_mem (self .address , opt ["reg" ], bytes ([config_value ]))
196- print (f"[WSEN_ISDS] _write_option: { option } ={ value } → reg { hex (opt ['reg' ])} : { hex (old_value )} → { hex (config_value )} " )
197187 except KeyError as err :
198188 print (f"Invalid option: { option } , or invalid option value: { value } ." , err )
199189
@@ -280,11 +270,14 @@ def acc_calibrate(self, samples=None):
280270 if samples is None :
281271 samples = self .ACC_NUM_SAMPLES_CALIBRATION
282272
273+ print (f"[WSEN_ISDS] Calibrating accelerometer with { samples } samples..." )
283274 self .acc_offset_x = 0
284275 self .acc_offset_y = 0
285276 self .acc_offset_z = 0
286277
287- for _ in range (samples ):
278+ for i in range (samples ):
279+ if i % 10 == 0 :
280+ print (f"[WSEN_ISDS] Accel sample { i } /{ samples } " )
288281 x , y , z = self ._read_raw_accelerations ()
289282 self .acc_offset_x += x
290283 self .acc_offset_y += y
@@ -294,6 +287,7 @@ def acc_calibrate(self, samples=None):
294287 self .acc_offset_x //= samples
295288 self .acc_offset_y //= samples
296289 self .acc_offset_z //= samples
290+ print (f"[WSEN_ISDS] Accelerometer calibration complete: offsets=({ self .acc_offset_x } , { self .acc_offset_y } , { self .acc_offset_z } )" )
297291
298292 def _acc_calc_sensitivity (self ):
299293 """Calculate accelerometer sensitivity based on range (in mg/digit)."""
@@ -324,19 +318,15 @@ def read_accelerations(self):
324318
325319 def _read_raw_accelerations (self ):
326320 """Read raw accelerometer data."""
327- print ("[WSEN_ISDS] _read_raw_accelerations: checking data ready..." )
328321 if not self ._acc_data_ready ():
329- print ("[WSEN_ISDS] _read_raw_accelerations: DATA NOT READY!" )
330322 raise Exception ("sensor data not ready" )
331323
332- print ("[WSEN_ISDS] _read_raw_accelerations: data ready, reading registers..." )
333324 raw = self .i2c .readfrom_mem (self .address , Wsen_Isds ._REG_A_X_OUT_L , 6 )
334325
335326 raw_a_x = self ._convert_from_raw (raw [0 ], raw [1 ])
336327 raw_a_y = self ._convert_from_raw (raw [2 ], raw [3 ])
337328 raw_a_z = self ._convert_from_raw (raw [4 ], raw [5 ])
338329
339- print (f"[WSEN_ISDS] _read_raw_accelerations: raw values = ({ raw_a_x } , { raw_a_y } , { raw_a_z } )" )
340330 return raw_a_x , raw_a_y , raw_a_z
341331
342332 def gyro_calibrate (self , samples = None ):
@@ -348,11 +338,14 @@ def gyro_calibrate(self, samples=None):
348338 if samples is None :
349339 samples = self .GYRO_NUM_SAMPLES_CALIBRATION
350340
341+ print (f"[WSEN_ISDS] Calibrating gyroscope with { samples } samples..." )
351342 self .gyro_offset_x = 0
352343 self .gyro_offset_y = 0
353344 self .gyro_offset_z = 0
354345
355- for _ in range (samples ):
346+ for i in range (samples ):
347+ if i % 10 == 0 :
348+ print (f"[WSEN_ISDS] Gyro sample { i } /{ samples } " )
356349 x , y , z = self ._read_raw_angular_velocities ()
357350 self .gyro_offset_x += x
358351 self .gyro_offset_y += y
@@ -362,6 +355,7 @@ def gyro_calibrate(self, samples=None):
362355 self .gyro_offset_x //= samples
363356 self .gyro_offset_y //= samples
364357 self .gyro_offset_z //= samples
358+ print (f"[WSEN_ISDS] Gyroscope calibration complete: offsets=({ self .gyro_offset_x } , { self .gyro_offset_y } , { self .gyro_offset_z } )" )
365359
366360 def read_angular_velocities (self ):
367361 """Read calibrated gyroscope data.
@@ -379,19 +373,15 @@ def read_angular_velocities(self):
379373
380374 def _read_raw_angular_velocities (self ):
381375 """Read raw gyroscope data."""
382- print ("[WSEN_ISDS] _read_raw_angular_velocities: checking data ready..." )
383376 if not self ._gyro_data_ready ():
384- print ("[WSEN_ISDS] _read_raw_angular_velocities: DATA NOT READY!" )
385377 raise Exception ("sensor data not ready" )
386378
387- print ("[WSEN_ISDS] _read_raw_angular_velocities: data ready, reading registers..." )
388379 raw = self .i2c .readfrom_mem (self .address , Wsen_Isds ._REG_G_X_OUT_L , 6 )
389380
390381 raw_g_x = self ._convert_from_raw (raw [0 ], raw [1 ])
391382 raw_g_y = self ._convert_from_raw (raw [2 ], raw [3 ])
392383 raw_g_z = self ._convert_from_raw (raw [4 ], raw [5 ])
393384
394- print (f"[WSEN_ISDS] _read_raw_angular_velocities: raw values = ({ raw_g_x } , { raw_g_y } , { raw_g_z } )" )
395385 return raw_g_x , raw_g_y , raw_g_z
396386
397387 def read_angular_velocities_accelerations (self ):
@@ -468,5 +458,4 @@ def _get_status_reg(self):
468458 gyro_data_ready = bool (status & 0x02 ) # Bit 1
469459 temp_data_ready = bool (status & 0x04 ) # Bit 2
470460
471- print (f"[WSEN_ISDS] Status register: 0x{ status :02x} = 0b{ status :08b} , acc_ready={ acc_data_ready } , gyro_ready={ gyro_data_ready } , temp_ready={ temp_data_ready } " )
472461 return acc_data_ready , gyro_data_ready , temp_data_ready
0 commit comments