derkyjadex / M8WebDisplay

Display for headless M8 tracker
https://derkyjadex.github.io/M8WebDisplay/
MIT License
199 stars 41 forks source link

Autosave not working when disconnecting Teensy #13

Closed Baegus closed 2 years ago

Baegus commented 2 years ago

When I close the browser tab, disconnect my Teensy, reconnect it and then reopen the tab, all my work is restored. However, if I don't close the window and disconnect Teensy, my work is discarded.

Would it possible to autosave at this point as well?

jakerr commented 2 years ago

In my understanding, disconnecting the Teensy from the computer will remove it from power, so at that point it would be too late to trigger an autosave.

derkyjadex commented 2 years ago

It isn't possible to trigger anything on the Teensy after the USB has been removed, since there's no way of communicating with it and it won't have any power anyway. Neither the Teensy nor your computer know that you are about to remove the USB plug, so there's nothing we can do beforehand either.

The only way this could possibly work is if there was some kind of periodic autosave, eg. every 30 seconds, or 5 minutes. This is something that would be entirely for the M8 firmware to handle and not something we can control over serial from the web page.