Skip to content

feat(ism330dl): Add compass-guided maze game. #418

@nedseb

Description

@nedseb

What

Extend the existing maze game (#390) so that the physical compass orientation (LIS2MDL magnetometer) influences the movement direction, in addition to the accelerometer tilt.

Why

Combines two motion sensors (accelerometer + magnetometer) in a creative game context. Introduces the concept of absolute orientation (magnetic north) vs relative orientation (tilt).

Suggested approach

  1. Start from the existing `maze_game.py` (ISM330DL tilt input)
  2. Add LIS2MDL magnetometer reading to determine the board's heading
  3. The maze exit is always "north" on screen — rotating the physical board changes which screen direction maps to which D-PAD direction
  4. For example: if the board faces north, tilt-forward = move up on screen. If the board faces east, tilt-forward = move right on screen.
  5. Display a small compass indicator in a corner of the OLED
  6. The score bonus/penalty reflects how well the player orients themselves

Learning goals

  • Magnetometer heading computation (`atan2`)
  • Coordinate system rotation
  • Combining multiple IMU sensors
  • Game design with physical interaction

Hardware

  • ISM330DL accelerometer
  • LIS2MDL magnetometer
  • SSD1327 OLED

Documentation

Write a pedagogical activity sheet for the STeaMi wiki covering:

  • Learning objectives (magnetometer, heading, coordinate rotation, multi-sensor fusion)
  • Gameplay instructions
  • How to calibrate the magnetometer (reference to `calibrate_magnetometer.py`)
  • Extension ideas (procedural maze difficulty, multiplayer via BLE, time attack mode)

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions