Skip to content

feat(ism330dl): Add Tetris example with accelerometer tilt controls.#423

Open
MatteoCnda1 wants to merge 4 commits intomainfrom
feat/ism330dl-tetris-game
Open

feat(ism330dl): Add Tetris example with accelerometer tilt controls.#423
MatteoCnda1 wants to merge 4 commits intomainfrom
feat/ism330dl-tetris-game

Conversation

@MatteoCnda1
Copy link
Copy Markdown
Contributor

@MatteoCnda1 MatteoCnda1 commented Apr 27, 2026

Summary

feat(ism330dl): Add Tetris example with accelerometer tilt controls. Closes #422

Changes

This example implements a fully playable Tetris game controlled by the ISM330DL accelerometer on the STeaMi board:

  • Tilt left/right to move pieces using the ay axis (threshold: 0.35g)
  • Shake the board to rotate pieces (magnitude > 2.2g)
  • Button A for hard drop
  • Button B for rotation
  • 7 classic tetrominoes with 4-bit greyscale colors
  • Ghost piece showing where the piece will land
  • Score, level and lines counter
  • Next piece preview
  • Speed increases with level (from 600ms to 100ms)
  • Start screen and game over screen
  • Display adapted to the SSD1327 128x128 round OLED screen

Checklist

  • ruff check passes
  • python -m pytest tests/ -k mock -v passes
  • Tested on hardware (STM32WB55 / STeaMi board)
  • README updated
  • Examples added (lib/ism330dl/examples/tetris.py)
  • Commit messages follow : <Description.> format

@Charly-sketch
Copy link
Copy Markdown
Contributor

Very nice work on this example overall.
Turning the ISM330DL into a tilt-controlled Tetris game is a creative idea, and the result is both playful and technically interesting. It adds a real “showcase” example to the driver and demonstrates well how the accelerometer, buttons, and OLED can be combined in a complete application.

The implementation is functional and the game loop is clear, but I noticed a few points that should be adjusted before merge:

  1. Issue metadata should be corrected

    In issue feat(ism330dl): Add Tetris example with accelerometer tilt controls. #422, the Driver / Component field is currently set to apds9960, while this PR clearly targets the ism330dl driver.
    Please update the issue metadata so the tracking remains coherent with the actual component involved.

  2. Button B behavior / wording inconsistency

    In the PR description, Button B is described as “soft rotation” instead of ”rotation".

  3. Unused constant

    COL_GRID is declared in the configuration section but never used in the rendering code.
    Please either remove it or actually use it if a background grid was initially planned. Keeping unused constants makes the example look unfinished.

  4. Start screen instructions are incomplete

    The start screen currently shows:

    • Tilt = move
    • Shake = rot
    • A = drop
    • A to start

    but does not mention Button B even though Button B also rotates the piece. This makes the user discover one control only by trial and error.
    Please update the start screen so all available controls are documented consistently.

  5. Comments should be written in English

    Most comments inside the file are still written in French (Parametres du jeu, Couleurs, Etat du jeu, Secousse, Inclinaison, etc.).
    The repository examples and source files should remain fully English for consistency and maintainability, so these comments need to be translated.

  6. Game area could be slightly better centered for the round OLED

    On the round SSD1327 screen, the current placement leaves the playfield visually a bit shifted and one corner feels closer to the clipped area of the display.
    It would be worth slightly reworking GRID_X, GRID_Y, and/or the right information panel spacing to visually recenter the gameplay zone and avoid the impression that one side is too close to the circular border.

Once these points are adjusted, this will be a very strong addition to the ISM330DL examples.
Again, this is a very good and genuinely engaging example—the idea is excellent and the implementation is already solid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ism330dl): Add Tetris example with accelerometer tilt controls.

2 participants