Using SPIFFS (for using V1) - KL-Psychological-Methodology/TWatch-2020-ESM GitHub Wiki

A big reason for spicifically choosing Version 2 of the T-Watch 2020 as target for this firmware is it's micro-SD slot, which enables very easy data transfer and storage. However, with small adaptations the firmvare can also run on other models of the T-Watch 2020, using the internal Flash memory, using the SPIFFS (Serial Peripheral Interface Flash File System). This is also an option if for whatever reason you want to use a Version 2 devich without a micro-SD card.

A few notes on this:

  • From our experience with this alternative, we noticed access of the SPIFFS to be noticeably slower than accessing the SD-card. This can make the device feel slightly less responsive.
  • Flash memory is damaged over time by repeated write operations. We have no experience at what point this becomes relevant for this device and it's typical use case. While this is also true for SD cards, these can be more easily and cheaply replaced.
  • This option is currently only supported for Versions 1 and 2. Version 3 should work, but needs further code modifications and is so far untested.

Configuring the device for the use of the SPIFFS

To have the firmware access the SPIFFS instead of the SD card, you have to change the configuration of the firmware and recompile it. The relevant configuration is part of the file include/config.h.

This file defines the version of the watch the firmware should be compiled for. The watch version is defined by either #define LILYGO_WATCH_2020_V1, #define LILYGO_WATCH_2020_V2 (also make sure to remove or comment out any non-matching definitons). If you want to use the SPIFFS on a Version 2 device, uncomment #define V2_USE_SPIFFS.

Configuring the Device

To get the config.json into the Flash memory of the device, you need to burn it on there, similarly to uploading the firmware. The following instructions will work for PlatformIO.

First, create a directory called data in the root directory of the project. Then put the config.json for your study as well as the locale.json (if you have one) in that directory.

Next click on the PlatformIO icon. Under Project Tasks there should be a directory icon with the name ttgo-t-watch. Under it there is a category Platform. You now need to clich Build Filesystem Image, which will compile your files into the right format. Once that's done, you can connect the watch and click Upload Filesystem Image. Sometimes if you already have something uploaded in this file system this might not work properly. In that case you will first need to click Erase Flash before clicking Upload Filesystem Image again.

Accessing Generated Files

To download the collected data from the device you will need PlatformIO again. Establish a serial connection with the device. Now, on the device, go into the settings. This version of the firmware has an additional option in the settings menu called Download data (if you need to localize this in the locale file, the key for this string is settings_download_data). When you click on that setting you will see two buttons labeled Download data log and Download signal log (which can be localized with the keys download_data_log and download_signal_log respectively).

Clicking one of these two buttons will print respective file via the serial monitor. You then need to select the outputted text, copy it in a new text file in an editor of your choice, and save it to a location of your choice. If after this you want to reuse the device in the same study for another participant, you might need to repeat the upload process from above to clear the flash, otherwise the device will just continue appending the existing file.