src/main: reworked the main loop
With the latest code cleanup, issues were introduced regarding the mounting and
unmounting of the filesystem.

* Sometimes the board would wake up from sleep and perform mounting and
unmounting of the filesystem in a more or less short loop before going
back to sleep. I suspect this might be due to the sleep getting
interrupted without any button press, aka every 10 minutes or so.
* This code also created a bug where it would create then mount a new
filesystem on the flash after erasing it, breaking the purpose for that
function in the first place which is to erase the flash and nothing
else.

Main is now calling mountFilesystem and unmountFilesystem where
appropriate:

* Before running doUSBMSD, main unmounts the filesystem. When doUSBMSD
is done, main once again mounts the filesystem.
* Before erasing the flash with doERASE, main unmounts the filesystem,
and never mounts it again.
* As a tidying up step, the filesystem gets unmounted, same as the
button thread terminating.
1 parent ebae203 commit 1399c7c1d19b9b9fbf6d4d987d265361b5fa8b0c
@Xogium Xogium authored on 26 Mar 2023
Showing 1 changed file
View
src/main.cpp