TinyCircuits / TinyCircuits-Thumby-Code-Editor

https://code.thumby.us/
GNU General Public License v3.0
30 stars 20 forks source link

Automatically call machine.reset after games execute #33

Closed fuglaro closed 2 years ago

fuglaro commented 2 years ago

Previously it was encouraged that all games call thumby.reset, (which just calls machine.reset). This change eliminates that requirement and makes the menu system not vulnerable to subsequent corruption of state. Particularly noticable glitches can happen to the menu if games do not call machine.reset cleanly, and where the state is corrupted. This includes when a game calls thumbyGraphics.display.display.invert and then crashes, thus leaving the menu with inverted colors, or if a game uses _thread and then crashes, which would leave the second core running code. This could include calls to the display device and cause an interleaving of sending commands and data, leading to undefined commands being sent to the display, potentially outside the spefications of the display controller. Wierd effects have been seen in practise such as a flipped image or bright scrolling flashes. This protects from all the above scenarios.

ghost commented 2 years ago

This makes sense to me. The other purpose of calling thumby.reset() is to stop the program without needing to figure a way to break the main game loop, but games could use sys.exit(). Maybe we should add a thumby.exit() method?

In any case, this is another failsafe to prevent pollution of the menu space, so I'll merge and update the site with a version change to prompt people to update their Thumbys.