feat(lis2mdl): Add OLED digital compass example.#362
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new lis2mdl hardware example that combines the LIS2MDL magnetometer with an SSD1327 OLED to render a live digital compass display, including a startup calibration flow.
Changes:
- Added
lib/lis2mdl/examples/compass_display.pyexample integrating LIS2MDL heading + SSD1327 drawing loop. - Implements a startup 3D min/max calibration routine with on-screen prompts.
- Renders a compass UI (ring, cardinal points, needle, numeric heading + direction label).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Draw the compass outer border (circle) | ||
| display.framebuf.ellipse(CENTER_X, CENTER_Y, COMPASS_RADIUS, COMPASS_RADIUS, 15) | ||
|
|
There was a problem hiding this comment.
framebuf.FrameBuffer on MicroPython typically doesn’t provide an ellipse() method, and the ssd1327 driver doesn’t add one either. Calling display.framebuf.ellipse(...) will raise AttributeError on most ports. Consider replacing this with a small helper that draws a circle using pixel()/line() (e.g., midpoint circle algorithm or a low-resolution polygon approximation), or drop the ring if you want to keep the example minimal.
There was a problem hiding this comment.
Good catch! I implemented the midpoint circle algorithm to keep the UI clean while avoiding the AttributeError.
975fd3c to
47398cf
Compare
|
💡 Suggestion: cette PR utilise le SSD1327 directement avec Tu pourrais simplifier ton code en utilisant : from steami_screen import Screen, SSD1327Display
display = SSD1327Display(ssd1327.WS_OLED_128X128_SPI(spi, dc, res, cs))
screen = Screen(display)
screen.clear()
screen.compass(heading)
screen.show()Cela remplacerait tout le code de dessin manuel (cercles, aiguille, labels cardinaux). Pas obligatoire pour cette PR, mais à considérer. |
Revue — LIS2MDL Compass Display ExampleBon ajout global L’exemple est visuellement intéressant, exploite bien le SSD1327 et démontre une vraie utilisation du LIS2MDL (heading + direction). 1. README non mis à jourL’exemple À faire : 2. PR description — issue non liéeLa PR ne contient pas : Obligatoire selon les conventions GitHub du projet. 3. Commentaire en français dans le codeDans le code : # Si tu préfères l'initiale française pour Ouest...À corriger : 4. Import inutiliséfrom math import cos, pi, sin
À corriger : Points positifs ✓
Résumé des corrections à faire
|
da04777 to
6e9171b
Compare
6e9171b to
a849196
Compare
Summary
Closes #328
Adds a new hardware example demonstrating a digital compass by combining the LIS2MDL magnetometer and the SSD1327 OLED display.
Changes
lib/lis2mdl/examples/compass_display.py.calibrate_minmax_3d()) with on-screen user instructions.sin/cos).display.power_off()) in thefinallyblock according to project conventions.Checklist
ruff checkpassespython -m pytest tests/ -k mock -vpasses (no mock test broken)<scope>: <Description.>format