Commit 83b480a
committed
fix(ism330dl): Fix recursive game loop and add cleanup in maze_game.
Address review comments on #390:
1. Replace recursive run_game() self-call with an outer `while True` loop.
On MicroPython's limited stack (8-16 KB), each completed game added a
stack frame that was never freed — a few wins would crash with a
RecursionError or silent stack overflow.
2. Add try/except/finally around the game loop: Ctrl+C now cleanly
clears the display and powers off the IMU (same pattern as
spirit_level.py) to avoid battery drain.
3. Add maze_game.py to the README examples table.1 parent 700b587 commit 83b480a
2 files changed
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
289 | 290 | | |
290 | 291 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
254 | 257 | | |
255 | 258 | | |
256 | 259 | | |
| |||
273 | 276 | | |
274 | 277 | | |
275 | 278 | | |
276 | | - | |
277 | 279 | | |
278 | 280 | | |
279 | | - | |
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
| |||
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
290 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
0 commit comments