Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package resources + a metadata file into a single .zip file. #1299

Merged
merged 5 commits into from
Sep 11, 2022

Conversation

JF002
Copy link
Collaborator

@JF002 JF002 commented Aug 26, 2022

Files (fonts and pictures) are converted and packed into a single .zip file using a CMake custom_target. This target

  • Converts the fonts into .bin files (using a slightly modified version of src/displayapp/fonts/generate.py)
  • Converts the images into .bin files (using a new script inspired from generate.py above)
  • Generates a .json file with metadata (see below)
  • Zip everything in a single infinitime-resources-1.11.0.zip

The content of the zip file looks like this:

infinitime-resources-1.11.0.zip
|
|---- 7segments_40.bin
|---- 7segments_115.bin
|---- infineat-1bin
...
|---- resources.json

resources.json:

{
    "resources": [
        {
            "filename": "7segments_40.bin",
            "path": "/fonts/7segments_40.bin"
        },
        {
            "filename": "7segments_115.bin",
            "path": "/fonts/7segments_115.bin"
        },i
        {
            "filename": "infineat-1.bin",
            "path": "/fonts/infineat-1.bin"
        }
    ],
    "obsolete_files": [
        {
            "path": "/background_v1.bin",
            "since": "1.11.0"
        },
        {
            "path": "/font_v2.bin",
            "since": "1.11.0"
        }
    ]
}
  • The array resources contains the list of files from the .zip file that must be uploaded to the watch. It contains the name of the file in the .zip file and the path (filename) where it must be written to the watch.
  • The array obsolete_files contains a list of files that can optionally remove from the watch. This is a hint to the companion app which lists the files that are not used anymore in this version of infinitime and that can be removed. It's up to the companion app to remove them to free some memory space. Each item contain the filename in the watch FS and the version of infinitime that made that file obsolete.

EDIT : here is an example package: infinitime-resources-1.10.0.zip

And this is the expected result once the files are uploaded (screenshots using ITD:
image

./itctl fs ls                            
d 0.0 B  .
d 0.0 B  ..
- 4.9 kB 7segments_115.bin
- 760 B  7segments_40.bin
- 4.4 kB bebas.bin
- 1.4 kB infineat-1.bin
- 1.8 kB lv_font_dots_40.bin
- 115 kB matrix.bin
-  40 B  settings.dat
- 440 B  teko.bin

To support this, companion apps will have to implement our BLE FS API.

See this comment

@Elara6331
Copy link
Contributor

I'm currently implementing this for ITD. Should be ready soon if everything goes well. I'll make a branch with it when I'm done and then merge when this is released.

@Elara6331
Copy link
Contributor

Elara6331 commented Aug 28, 2022

One question that I have is: should I load the resources (delete obsolete, upload new, etc.) before or after the DFU itself? After would be A LOT more complicated because I'd have to wait for the watch to boot back up and then reconnect to do it, which would require rewriting a lot of how ITD handles reconnects, which is already really annoying due to BLE having no way to check whether a device is in range.

@JF002
Copy link
Collaborator Author

JF002 commented Sep 4, 2022

should I load the resources (delete obsolete, upload new, etc.) before or after the DFU itself?

That's a good question! Loading the new resources (and potentially removing older ones) before the firmware update might break the firmware that is currently running, if it's still using the resources that will be deleted. Loading them after the firmware update might break the new firmware if it tries to load resources that do not exist yet...
This is actually one of to TODO task that need to be done before releasing the functionality : "InfiniTime must handle the case where an app/watchface needs a resource from the FS and the corresponding file does not exist" #321 (comment)

In the end, I think we need to ensure that the firmware (app & watchface) will never crash or misbehave if the resource does not exist. In this case, the update sequence (firmware then resource or resource then firmware) will be the choice of the user or the companion app.

@JF002
Copy link
Collaborator Author

JF002 commented Sep 6, 2022

Here is a new resource package that maps files into subdirectories (/fonts and /images). It might be useful to ensure that implementations in companion apps handle the subdirectories correctly

infinitime-resources-1.10.0.zip

Add lv_img_conf in Docker image to build resources at build time.
@JF002
Copy link
Collaborator Author

JF002 commented Sep 11, 2022

So my plan for this feature is:

  • Merge this branch to allow generation of resources
  • Extend Infineat to support external resource and merge it. It also brings Infineat watchface and the possibility to select more than 4 watchfaces in the settings.
  • Extend and merge the G7710 watchface
  • Talk with companion app developers and contributors hoping they'll add support for this feature in companion apps. ITD already supports it, and I'm currently working on the integration in Amazfish.
  • If anything goes wrong, we'll be able to temporarily disable the new watchfaces that need additional resources in the settings.
  • Release and enjoy!

@JF002 JF002 merged commit c9a5c3f into develop Sep 11, 2022
@JF002 JF002 added this to the 1.11.0 milestone Sep 11, 2022
@Avamander Avamander deleted the external-resources-packaging branch September 27, 2022 21:27
@JF002 JF002 mentioned this pull request Oct 10, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants