cmake: add explicit std::filesystem linking
g++8 compiler has C++17 support, but needs a link parameter for `std::filesystem` to work.
Add a cmake-module to find the needed link flag (if any) and provide a CMake target to
link against.
This can be removed once InfiniTime needs a newer compiler standard (like C++20).
Fixes: https://github.com/InfiniTimeOrg/InfiniSim/issues/57
The `BUILD_RESOURCES` option is also available in `InfiniTime`, but we
don't want to require building the firmware to test `resource.zip` file
generation.
This pull request allows my pull request InfiniTimeOrg/InfiniTime#1323 in the
InfiniTime project to build the simulator that's in this project. Both pull requests
add the feature that I requested here: InfiniTimeOrg/InfiniTime#1320
Co-authored-by: Dyllan Kobal <dddk500@gmail.com>
* print memory usage (p/P): Only print when changed, max-memory
No longer spam the memory usage constantly. This makes the output much
more useful by allowing to observe each change in memory usage, since
the values now no longer get pushed up and scroll out of view rapidly.
Changes:
- Add `max_used` peak memory usage
- Add labels in the output (slightly more verbose, but much clearer)
- Remove unnecessary `int64_t` cast
- Change "free" to "budget left" to clarify it shows mem that would be
free on the real hardware, making situations where it goes negative
less confusing
- Change field widths so 5 digit values no longer jump out of alignment
Example output:
```
Mem: 6720 used (change: -248, peak: 7928) 7616 budget left
Mem: 6832 used (change: +112, peak: 7928) 7504 budget left
Mem: 6584 used (change: -248, peak: 7928) 7752 budget left
Mem: 10856 used (change: +4272, peak: 10848) 3480 budget left
Mem: 10888 used (change: +32, peak: 10880) 3448 budget left
Mem: 10616 used (change: -272, peak: 10880) 3720 budget left
Mem: 6704 used (change: -3912, peak: 10880) 7632 budget left
Mem: 6808 used (change: +104, peak: 10880) 7528 budget left
```
Add a new command `littlefs-do res load resource.zip` which loads
resources from a zip file to the SPI raw file.
Below an example `resource.zip` is loaded:
```sh
$ ./littlefs-do res load infinitime-resources-1.10.0.zip --verbose
Calling FS::Init()
running 'res'
running 'res load'
loading resource file: "infinitime-resources-1.10.0.zip"
zip: num of files in zip: 8
copy file teko.bin from zip to SPI path '/teko.bin'
copy file lv_font_dots_40.bin from zip to SPI path '/lv_font_dots_40.bin'
copy file 7segments_40.bin from zip to SPI path '/7segments_40.bin'
copy file bebas.bin from zip to SPI path '/bebas.bin'
copy file 7segments_115.bin from zip to SPI path '/7segments_115.bin'
copy file matrix.bin from zip to SPI path '/matrix.bin'
copy file infineat-1.bin from zip to SPI path '/infineat-1.bin'
finished: zip file fully loaded into SPI memory: infinitime-resources-1.10.0.zip
```
Afterwards the files are listed in the SPI raw file:
```sh
$ ./littlefs-do ls
type: DIR
name: /
type: DIR name: .
type: DIR name: ..
type: REG size: 4928 name: 7segments\_115.bin
type: REG size: 760 name: 7segments\_40.bin
type: REG size: 4420 name: bebas.bin
type: REG size: 1430 name: infineat-1.bin
type: REG size: 1840 name: lv\_font\_dots\_40.bin
type: REG size: 115204 name: matrix.bin
type: REG size: 440 name: teko.bin
```
Fixes: https://github.com/InfiniTimeOrg/InfiniSim/issues/55
The build dependencies section says to install `lv_font_conv` to the
source directory. But the instructions to download the InfiniSim sources
was after the build dependencies.
Move the "get sources" section before the "build dependencies" to
clairify the instructions.
Fixes: https://github.com/InfiniTimeOrg/InfiniSim/issues/53
Add helper to modify spi raw file, to make experimenting with it easier.
```sh
$ ./littlefs-do --help
Usage: ./littlefs-do <command> [options]
Commands:
-h, --help show this help message for the selected command and exit
-v, --verbose print status messages to the console
stat show information of specified file or directory
ls list available files in 'spiNorFlash.raw' file
mkdir create directory
rmdir remove directory
rm remove directory or file
cp copy files into or out of flash file
settings list settings from 'settings.h'
```
In the process restructure the CMake file for less duplicate
includes/defines for both executables (`infinisim` and `littlefs-do`).
Upload the `littlefs-do` binary built by the CI additionally to the `infinisim` binary.
Use the updated upload-artifact@v3 template to do that.
Support changes in InfiniTimeOrg/InfiniTime#1258
The file `lv_pinetime_theme.c` is renamed to `InfiniTimeTheme.cpp`.
Need to pick up that change in the simulator to compile with the new cpp
file if it exists.
Furthermore use the new `InfiniTimeTheme.h` header in simulator files.
Fixes: https://github.com/InfiniTimeOrg/InfiniSim/issues/49