If the LittleFS operations are interrupted- for example by the LEDs processing thread - the file system will become corrupted.
One solution is to ...
- set the
halt flag and then wait some number of milliseconds to insure the LEDs processing thread has finished and looped around again
- perform the necessary operations with LittleFS
- restore the
halt flag to allow LEDs processing to continue