InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.64k stars 903 forks source link

Move Navigation font to external memory #1838

Closed JF002 closed 10 months ago

JF002 commented 10 months ago

The TTF font used by the navigation app is ~20KB and is stored in internal flash memory. To free this space, the TTF font is now converted in 2 "atlas pictures" (pictures that contain multiple concatenated images) stored in the external flash memory. The navigation app now accesses one of those 2 files and apply an offset to display the desired picture.

The corresponding documentation has also been updated.

The final binary file is now 19380B lighter.

Here is a quick video I made while testing the implementation :

https://github.com/InfiniTimeOrg/InfiniTime/assets/2261652/da878cb6-520a-4083-bf45-169f7015a17f

github-actions[bot] commented 10 months ago
Build size and comparison to main: Section Size Difference
text 376560B -19396B
data 940B -56B
bss 63420B 0B
JF002 commented 10 months ago

@FintasticMan I've just pushed #1847 which disables the Navigation app if the resource files are not available. We'll be able to use this implementation for other applications when needed as well.

If you're OK with this, we can merge #1847 after we merge this one.

JF002 commented 10 months ago

Builds with -DBUILD_RESOURCES=1 fail for me with this PR. Could totally be a problem with my dependency setup if it works for you. [...] Using "lv_font_conv": "^1.5.2","lv_img_conv": "^0.3.0" (npm chose the versions for me)

This is probably not related to this PR since it doesn't to any change on how the images and fonts are converted. Does it work fine on the main branch ?

These are the versions I'm using on my dev setup:

$ lv_font_conv -v
1.5.2
$lv_img_conv --version
0.3.0
mark9064 commented 10 months ago

Builds with -DBUILD_RESOURCES=1 fail for me with this PR. Could totally be a problem with my dependency setup if it works for you. [...] Using "lv_font_conv": "^1.5.2","lv_img_conv": "^0.3.0" (npm chose the versions for me)

This is probably not related to this PR since it doesn't to any change on how the images and fonts are converted. Does it work fine on the main branch ?

These are the versions I'm using on my dev setup:

$ lv_font_conv -v
1.5.2
$lv_img_conv --version
0.3.0
  • Built fine before this commit
  • I've tried nodejs 16,18,20 with the dependency versions you use, no dice
  • Creates the pine_logo image without problem, only breaks on the navigation atlases
  • Broken on both my laptop and desktop (though they run pretty much the same software)

But it works on your machine and CI, so I have no clue. I've basically never used node before so I guess I will have to find out how to debug it... strange behaviour all round

FintasticMan commented 10 months ago

Maybe try using the node lockfile from #1764.

jackwilsdon commented 10 months ago

I experienced this issue in #1819, try pinning @swc/core to 1.2.160 (see my changes on that PR). It probably needs adding to the Dockerfile (and anywhere else we install @swc/core).

mark9064 commented 10 months ago

Maybe try using the node lockfile from #1764.

Good idea, I gave this a go. After installing from the package(-lock), the build failed with error message asking for swc/core, which I then installed. Unfortunately the original error then returned :(

I've been digging through lv_img_conv and it looks like it's trying to create a palette with no colours in it. Still working on figuring out the root problem

mark9064 commented 10 months ago

I experienced this issue in #1819, try pinning @swc/core to 1.2.160 (see my changes on that PR). It probably needs adding to the Dockerfile (and anywhere else we install @swc/core).

Spot on, this resolved the issue. Cheers!

Now I'm wondering: why do newer versions of swc/core break? Is there a regression we can track upstream (or should we report one)

JF002 commented 9 months ago

Spot on, this resolved the issue. Cheers!

Great! I honestly don't know why it doesn't work with more recent version of swc (in fact, I don't know what it is... I don't know Node either, but that's what the LVGL tools are based on). The only think I can think of is that it's the 1st time we use CF_INDEXED_1_BIT as output format. Maybe there was a breaking change in lv_img_conv in recent versions?

JF002 commented 9 months ago

I experienced this issue in #1819, try pinning @swc/core to 1.2.160 (see my changes on that PR). It probably needs adding to the Dockerfile (and anywhere else we install @swc/core).

If I understand correctly, this change is needed to ensure that the correct version will be installed? If so, I guess we would appreciate a PR for this :)