Conversation
nedseb
left a comment
There was a problem hiding this comment.
Revue complète — ISM330DL Driver
Bon travail sur ce driver, l'API est bien pensée (raw/g/ms², dps/rads, orientation/motion). Quelques points à corriger pour respecter les conventions du projet documentées dans le README (section Contributing).
Conventions du projet (README)
1. const.py — pas de micropython.const()
"Constants: use
from micropython import constwrapper inconst.pyfiles." (README L462)
Les constantes de registre et de configuration ne sont pas wrappées avec const(). Ajouter from micropython import const et wrapper les constantes scalaires. Les dicts (ACCEL_FS_BITS, ACCEL_SENSITIVITY_MG, etc.) restent tels quels.
2. device.py — class ISM330DL: → class ISM330DL(object):
"Class inheritance:
class Foo(object):is the existing convention." (README L464)
3. examples/ — sleep() → sleep_ms()
"Time: use
from time import sleep_ms(notutime, notsleep()with float seconds)." (README L465)
basic_read.py, static_orientation.py, motion_orientation.py utilisent from time import sleep + sleep(0.5). Remplacer par from time import sleep_ms + sleep_ms(500).
Qualité du code
4. device.py L14 — commentaire en français dans le code de production
if address is None: # Auto-detect address. Je ne sais pas si c'est nécessaire pour la STeaMi...À supprimer ou remplacer par un commentaire en anglais.
5. device.py L43 — allocation à chaque écriture I2C
self.i2c.writeto_mem(self.address, reg, bytes([value]))bytes([value]) alloue un nouvel objet à chaque appel. Les autres drivers utilisent un self.writebuffer = bytearray(1) pré-alloué dans __init__. Idem pour _read_u8 (L40) : readfrom_mem() alloue vs readfrom_mem_into() avec buffer pré-alloué.
6. device.py — lignes vides superflues en début de méthode
configure_accel, acceleration_g, gyroscope_dps, temperature_c, status, power_down, etc. ont une ligne vide entre la signature et le corps. Le style du repo n'en met pas.
README du driver
7. README.md L1 — artefact de génération
Voici un **README propre et complet** pour ton driver **ISM330DL**...
Cette phrase est un artefact LLM, à supprimer.
8. README.md L167 — méthode inexistante
imu.gyro_motion()La méthode s'appelle motion(), pas gyro_motion().
Fichiers
9. examples/test.py (387 lignes) — script de test standalone
Ce fichier duplique le rôle du framework tests/scenarios/. Il n'a pas sa place dans examples/ (qui est destiné aux exemples d'utilisation). Soit le supprimer, soit le déplacer hors de examples/.
10. examples/static_orientation.py L1 — import inutile
from machine import I2C, PinPin n'est pas utilisé.
11. exceptions.py — ISM330DLIOError jamais utilisée
Définie mais jamais levée dans le driver. Soit l'utiliser, soit la retirer.
Tests (scénario YAML)
12. Tests hardware trop faibles
acceleration_getgyroscope_dpstestent seulementexpect_not_none. Pour l'accéléromètre au repos, vérifier que la magnitude est ≈ 1g serait plus utile.- Pas de test hardware automatique pour
orientation(la carte posée à plat devrait retournerSCREEN_UPouSCREEN_DOWN). - Pas de test
temperature_cen hardware avec une plage raisonnable (la plage actuelle [-20, 80] est très large).
Points positifs ✓
- API complète : raw / g / ms² pour l'accéléromètre, raw / dps / rads pour le gyro
- Auto-détection d'adresse I2C
orientation()etmotion()bien implémentés comme fonctions de haut niveaureset()correct avec SW_RESET + attente + BDU/IF_INC- Mock tests avec des valeurs réalistes (z=0x4000 → ~1g)
- Scénario YAML bien structuré avec mock + hardware + manual
There was a problem hiding this comment.
Pull request overview
Adds a new MicroPython driver package for the ST ISM330DL 6‑axis IMU (accelerometer, gyroscope, temperature) along with examples, documentation, and a YAML scenario suite integrated into the existing test runner.
Changes:
- Introduces
lib/ism330dldriver implementation (I²C access, scaling/conversions, orientation/motion helpers, reset/power-down, custom exceptions). - Adds usage examples and a driver-local README.
- Adds a new scenario file
tests/scenarios/ism330dl.yamlcovering mock + hardware + manual checks.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tests/scenarios/ism330dl.yaml |
Adds scenario-based mock/hardware/manual tests for the new driver. |
lib/ism330dl/manifest.py |
Declares the new MicroPython package metadata and package name. |
lib/ism330dl/ism330dl/device.py |
Implements the ISM330DL driver (I²C helpers, configuration, readings, helpers). |
lib/ism330dl/ism330dl/const.py |
Defines registers, bit masks, ranges, sensitivities, and constants. |
lib/ism330dl/ism330dl/exceptions.py |
Adds driver-specific exception types. |
lib/ism330dl/ism330dl/__init__.py |
Exposes the driver class and exceptions at package level. |
lib/ism330dl/examples/basic_read.py |
Example: print accel/gyro/temp periodically. |
lib/ism330dl/examples/motion_orientation.py |
Example: simple motion detection from gyro. |
lib/ism330dl/examples/static_orientation.py |
Example: simple orientation detection from accel. |
lib/ism330dl/README.md |
Driver-local documentation and API description. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot review — changes made in 408be94
Test count went from 19 to 21 mock tests, all passing. |
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #4, closes #33
Summary
Add a new MicroPython driver for the ISM330DL 6-axis IMU from STMicroelectronics.
The driver provides access to the 3-axis accelerometer, 3-axis gyroscope, and internal temperature sensor over I²C. It follows the same structure and conventions used in the other drivers of this repository.
Features
ISM330DLIOErrortemp_ready,gyro_ready,accel_ready)0x6B(STeaMi board, SA0=1)Test plan
Mock test results (19 tests)
Hardware test results
Conventions checklist
const.py: constants wrapped withmicropython.const()device.py:class ISM330DL(object):device.py: pre-allocated buffer for_read_u8/_write_u8device.py:address=ISM330DL_I2C_DEFAULT_ADDR(0x6B, SA0=1)device.py:check_device()called in__init__device.py: I2C errors wrapped inISM330DLIOErrordevice.py: no French comments, no superfluous blank linesexamples/:sleep_ms()instead ofsleep()examples/: unusedPinimport removedexamples/test.py: removed (not an example)README.md: LLM artifact removedREADME.md:gyro_motion()corrected tomotion(),basic_reader.pycorrected tobasic_read.pyruff checkpasses