You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Fix SensorManager
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
- API: restore sys.path after starting app
|
||||
- API: add AudioFlinger for audio playback (i2s DAC and buzzer)
|
||||
- API: add LightsManager for multicolor LEDs
|
||||
- API: add SensorManager for IMU/accelerometers, temperature sensors etc.
|
||||
- About app: add free, used and total storage space info
|
||||
- AppStore app: remove unnecessary scrollbar over publisher's name
|
||||
- Camera app: massive overhaul!
|
||||
|
||||
@@ -1010,8 +1010,9 @@ def update_frame(self, a, b):
|
||||
- **Units**: Standard SI (m/s² for acceleration, deg/s for gyroscope, °C for temperature)
|
||||
- **Calibration**: Persistent via SharedPreferences (`data/com.micropythonos.sensors/config.json`)
|
||||
- **Thread-safe**: Uses locks for concurrent access
|
||||
- **Auto-detection**: Identifies IMU type via chip ID registers
|
||||
- **Auto-detection**: Identifies IMU type via chip ID registers (QMI8658: chip_id=0x05 at reg=0x00, WSEN_ISDS: chip_id=0x6A at reg=0x0F)
|
||||
- **Desktop**: Functions return `None` (graceful fallback) on desktop builds
|
||||
- **Important**: Driver constants defined with `const()` cannot be imported at runtime - SensorManager uses hardcoded values instead
|
||||
|
||||
### Driver Locations
|
||||
|
||||
|
||||
@@ -113,7 +113,10 @@ AudioFlinger.init(
|
||||
# === SENSOR HARDWARE ===
|
||||
# Note: Desktop builds have no sensor hardware
|
||||
import mpos.sensor_manager as SensorManager
|
||||
# Don't call init() - SensorManager functions will return None/False
|
||||
|
||||
# Initialize with no I2C bus - will detect MCU temp if available
|
||||
# (On Linux desktop, this will fail gracefully but set _initialized flag)
|
||||
SensorManager.init(None)
|
||||
|
||||
print("linux.py finished")
|
||||
|
||||
|
||||
@@ -98,7 +98,10 @@ def init(i2c_bus, address=0x6B):
|
||||
# Try QMI8658 first (Waveshare board)
|
||||
if i2c_bus:
|
||||
try:
|
||||
from mpos.hardware.drivers.qmi8658 import QMI8658, _QMI8685_PARTID, _REG_PARTID
|
||||
from mpos.hardware.drivers.qmi8658 import QMI8658
|
||||
# QMI8658 constants (can't import const() values)
|
||||
_QMI8685_PARTID = 0x05
|
||||
_REG_PARTID = 0x00
|
||||
chip_id = i2c_bus.readfrom_mem(address, _REG_PARTID, 1)[0]
|
||||
if chip_id == _QMI8685_PARTID:
|
||||
print("[SensorManager] Detected QMI8658 IMU")
|
||||
@@ -308,7 +311,10 @@ class _QMI8658Driver(_IMUDriver):
|
||||
"""Wrapper for QMI8658 IMU (Waveshare board)."""
|
||||
|
||||
def __init__(self, i2c_bus, address):
|
||||
from mpos.hardware.drivers.qmi8658 import QMI8658, _ACCELSCALE_RANGE_8G, _GYROSCALE_RANGE_256DPS
|
||||
from mpos.hardware.drivers.qmi8658 import QMI8658
|
||||
# QMI8658 scale constants (can't import const() values)
|
||||
_ACCELSCALE_RANGE_8G = 0b10
|
||||
_GYROSCALE_RANGE_256DPS = 0b100
|
||||
self.sensor = QMI8658(
|
||||
i2c_bus,
|
||||
address=address,
|
||||
|
||||
Reference in New Issue
Block a user