Skip to content

Commit 5199a92

Browse files
Reduce debug output
1 parent 0f2bbd5 commit 5199a92

File tree

3 files changed

+21
-38
lines changed

3 files changed

+21
-38
lines changed

internal_filesystem/builtin/apps/com.micropythonos.settings/assets/calibrate_imu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,15 @@ def calibration_thread_func(self):
295295
print(f"[CalibrateIMU] Accel sensor: {accel}, Gyro sensor: {gyro}")
296296

297297
if accel:
298-
print("[CalibrateIMU] Calibrating accelerometer (100 samples)...")
299-
accel_offsets = SensorManager.calibrate_sensor(accel, samples=100)
298+
print("[CalibrateIMU] Calibrating accelerometer (30 samples)...")
299+
accel_offsets = SensorManager.calibrate_sensor(accel, samples=30)
300300
print(f"[CalibrateIMU] Accel offsets: {accel_offsets}")
301301
else:
302302
accel_offsets = None
303303

304304
if gyro:
305-
print("[CalibrateIMU] Calibrating gyroscope (100 samples)...")
306-
gyro_offsets = SensorManager.calibrate_sensor(gyro, samples=100)
305+
print("[CalibrateIMU] Calibrating gyroscope (30 samples)...")
306+
gyro_offsets = SensorManager.calibrate_sensor(gyro, samples=30)
307307
print(f"[CalibrateIMU] Gyro offsets: {gyro_offsets}")
308308
else:
309309
gyro_offsets = None

internal_filesystem/lib/mpos/hardware/drivers/wsen_isds.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

internal_filesystem/lib/mpos/sensor_manager.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -652,53 +652,47 @@ def read_temperature(self):
652652

653653
def calibrate_accelerometer(self, samples):
654654
"""Calibrate accelerometer (device must be stationary)."""
655-
print(f"[QMI8658Driver] calibrate_accelerometer: starting with {samples} samples")
655+
print(f"[QMI8658Driver] Calibrating accelerometer with {samples} samples...")
656656
sum_x, sum_y, sum_z = 0.0, 0.0, 0.0
657657

658658
for i in range(samples):
659659
if i % 10 == 0:
660-
print(f"[QMI8658Driver] Sample {i}/{samples}: about to read acceleration...")
660+
print(f"[QMI8658Driver] Accel sample {i}/{samples}")
661661
ax, ay, az = self.sensor.acceleration
662-
if i % 10 == 0:
663-
print(f"[QMI8658Driver] Sample {i}/{samples}: read complete, values=({ax:.3f}, {ay:.3f}, {az:.3f}), sleeping...")
664662
# Convert to m/s²
665663
sum_x += ax * _GRAVITY
666664
sum_y += ay * _GRAVITY
667665
sum_z += az * _GRAVITY
668666
time.sleep_ms(10)
669-
if i % 10 == 0:
670-
print(f"[QMI8658Driver] Sample {i}/{samples}: sleep complete")
671667

672-
print(f"[QMI8658Driver] All {samples} samples collected, calculating offsets...")
673668
# Average offsets (assuming Z-axis should read +9.8 m/s²)
674669
self.accel_offset[0] = sum_x / samples
675670
self.accel_offset[1] = sum_y / samples
676671
self.accel_offset[2] = (sum_z / samples) - _GRAVITY # Expect +1G on Z
677672

678-
print(f"[QMI8658Driver] Calibration complete: offsets = {tuple(self.accel_offset)}")
673+
print(f"[QMI8658Driver] Accelerometer calibration complete: offsets = {tuple(self.accel_offset)}")
679674
return tuple(self.accel_offset)
680675

681676
def calibrate_gyroscope(self, samples):
682677
"""Calibrate gyroscope (device must be stationary)."""
683-
print(f"[QMI8658Driver] calibrate_gyroscope: starting with {samples} samples")
678+
print(f"[QMI8658Driver] Calibrating gyroscope with {samples} samples...")
684679
sum_x, sum_y, sum_z = 0.0, 0.0, 0.0
685680

686681
for i in range(samples):
687-
if i % 20 == 0:
688-
print(f"[QMI8658Driver] Reading sample {i}/{samples}...")
682+
if i % 10 == 0:
683+
print(f"[QMI8658Driver] Gyro sample {i}/{samples}")
689684
gx, gy, gz = self.sensor.gyro
690685
sum_x += gx
691686
sum_y += gy
692687
sum_z += gz
693688
time.sleep_ms(10)
694689

695-
print(f"[QMI8658Driver] All {samples} samples collected, calculating offsets...")
696690
# Average offsets (should be 0 when stationary)
697691
self.gyro_offset[0] = sum_x / samples
698692
self.gyro_offset[1] = sum_y / samples
699693
self.gyro_offset[2] = sum_z / samples
700694

701-
print(f"[QMI8658Driver] Calibration complete: offsets = {tuple(self.gyro_offset)}")
695+
print(f"[QMI8658Driver] Gyroscope calibration complete: offsets = {tuple(self.gyro_offset)}")
702696
return tuple(self.gyro_offset)
703697

704698
def get_calibration(self):

0 commit comments

Comments
 (0)