Skip to content

Commit 219f55f

Browse files
IMU: fix mounted_position handling
1 parent e581843 commit 219f55f

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def onCreate(self):
8585
btn_cont.set_height(lv.SIZE_CONTENT)
8686
btn_cont.set_style_border_width(0, 0)
8787
btn_cont.set_flex_flow(lv.FLEX_FLOW.ROW)
88-
btn_cont.set_style_pad_all(1,0)
8988
btn_cont.set_style_flex_main_place(lv.FLEX_ALIGN.SPACE_BETWEEN, 0)
9089

9190
# Action button
@@ -135,7 +134,7 @@ def update_ui_for_state(self):
135134
"""Update UI based on current state."""
136135
if self.current_state == CalibrationState.READY:
137136
self.status_label.set_text("Place device on flat, stable surface\n\nKeep device completely still during calibration")
138-
self.detail_label.set_text("Calibration will take ~2 seconds\nUI will freeze during calibration")
137+
self.detail_label.set_text("Calibration will take ~1 seconds\nUI will freeze during calibration")
139138
self.action_button_label.set_text("Calibrate Now")
140139
self.action_button.remove_state(lv.STATE.DISABLED)
141140
self.progress_bar.add_flag(lv.obj.FLAG.HIDDEN)
@@ -187,7 +186,7 @@ def start_calibration_process(self):
187186
if self.is_desktop:
188187
stationarity = {'is_stationary': True, 'message': 'Mock: Stationary'}
189188
else:
190-
stationarity = SensorManager.check_stationarity(samples=30)
189+
stationarity = SensorManager.check_stationarity(samples=25)
191190

192191
if stationarity is None or not stationarity['is_stationary']:
193192
msg = stationarity['message'] if stationarity else "Stationarity check failed"
@@ -206,12 +205,12 @@ def start_calibration_process(self):
206205
gyro = SensorManager.get_default_sensor(SensorManager.TYPE_GYROSCOPE)
207206

208207
if accel:
209-
accel_offsets = SensorManager.calibrate_sensor(accel, samples=100)
208+
accel_offsets = SensorManager.calibrate_sensor(accel, samples=50)
210209
else:
211210
accel_offsets = None
212211

213212
if gyro:
214-
gyro_offsets = SensorManager.calibrate_sensor(gyro, samples=100)
213+
gyro_offsets = SensorManager.calibrate_sensor(gyro, samples=50)
215214
else:
216215
gyro_offsets = None
217216

internal_filesystem/lib/mpos/board/linux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def adc_to_voltage(adc_value):
116116

117117
# Initialize with no I2C bus - will detect MCU temp if available
118118
# (On Linux desktop, this will fail gracefully but set _initialized flag)
119-
SensorManager.init(None)
119+
SensorManager.init(None, mounted_position=SensorManager.FACING_EARTH)
120120

121121
print("linux.py finished")
122122

internal_filesystem/lib/mpos/sensor_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def init(i2c_bus, address=0x6B, mounted_position=FACING_SKY):
8787
Returns:
8888
bool: True if initialized successfully
8989
"""
90-
global _i2c_bus, _i2c_address, _initialized, _has_mcu_temperature
90+
global _i2c_bus, _i2c_address, _initialized, _has_mcu_temperature, _mounted_position
9191

9292
_i2c_bus = i2c_bus
9393
_i2c_address = address
@@ -226,7 +226,7 @@ def read_sensor(sensor):
226226
if sensor.type == TYPE_ACCELEROMETER:
227227
if _imu_driver:
228228
ax, ay, az = _imu_driver.read_acceleration()
229-
if _mounted_position == SensorManager.FACING_EARTH:
229+
if _mounted_position == FACING_EARTH:
230230
az += _GRAVITY
231231
return (ax, ay, az)
232232
elif sensor.type == TYPE_GYROSCOPE:

0 commit comments

Comments
 (0)