Repository navigation
Rust Rewrite
Pre-releaseThe project has been rewritten in Rust!
This rewrite is very exciting because it improves the stability of the running pet, prevents the device from slowing down as the user plays with it, no longer requires hourly reboots to defragment the heap, and gives headroom to add new features, new minigames, and improve the overall polish. In addition, we now have compile-time checks that provide a higher level of confidence that the device won't error out and crash from issues like syntax errors or undefined variables. The borrow checker is a huge confidence booster.
Memory Improvements
There were a few issues with the older MicroPython version that were difficult, if not impossible, to surmount. The biggest one was the loading/unloading of modules as the pet's behaviors changed and as the user navigated around the project led to heap fragmentation. That would slowly put the device into a situation where it would OOM and crash.
The new Rust rewrite doesn't have that issue at all. The enum associated with scenes and behaviors uses the largest variant and swaps as needed. There is no allocation, no free, no fragmentation. The huge churn from module loading/unloading in MicroPython has been eliminated.
Single Flashable Binary
The old MicroPython project required loading a ton of files (handled by a script) to upload to the device. The Rust version generates and uploads a single binary.
Performance Improvements
There is a very noticeable improvement in responsiveness and FPS all across the project as a result of this rewrite, and a lower memory footprint in general. It's a very significant quality of life improvement for users.
Better Fonts
Switching away from the MicroPython version also meant switching away from the old graphics library. The newer Rust versions of this have a more compact font which allows for more text to be visible on the screen and actually improves readability significantly. It also allows for more languages since we can support characters that weren't supported in the old graphics library.
Save Files
Warning
Flashing the new Rust binary will erase all of the old files on the device, including old character save files.
If you want to keep a pet from the prior version you'll need to backup the save file.
Backing up the save on desktop
It's pretty trivial on desktop. Just rename save.json to catode32-save.json in the working directory.
Backing up on ESP32s
- Before flashing Rust: run
./tools/context.py --export save.jsonto pull the MicroPython save off with mpremote. - Flash the Rust firmware.
I'll be writing a script/tool soon to allow pushing the backup files onto the Rust versions of the devices.
Final Notes
The rewrite still includes the desktop emulation version, language support, and multiple board types. In addition, the save files from the old MicroPython version should still be compatible with the new Rust version.
The README has been updated to provide instructions for using Rust (toolchain, flashing, language features, desktop emulation, etc).
The old MicroPython version has been archived in its own folder for now for historical purposes. It might be moved to a separate archived project in the future to clean up this repo. But all future work will be moving forward on this Rust version.