-
-
Notifications
You must be signed in to change notification settings - Fork 954
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
Move Navigation font to external memory #1838
Conversation
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.
Build size and comparison to main:
|
Fix formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this! It doesn't look to me like you're checking that the image files exist in the filesystem before using them. That would be good to add so that if people haven't updated their resources yet, it doesn't cause issues. Other than that, this code looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
/home/laptop/Local/pinetime/InfiniTime/node_modules/lv_img_conv/lib/image-q/utils/point.ts:85
this.r = point.r;
^
TypeError: Cannot read properties of undefined (reading 'r')
at Point.from (/home/laptop/Local/pinetime/InfiniTime/node_modules/lv_img_conv/lib/image-q/utils/point.ts:85:20)
at ErrorDiffusionArray.<anonymous> (/home/laptop/Local/pinetime/InfiniTime/node_modules/lv_img_conv/lib/image-q/image/array.ts:128:15)
at step (/home/laptop/Local/pinetime/InfiniTime/node_modules/lv_img_conv/lib/image-q/image/array.ts:205:23)
at Object.next (/home/laptop/Local/pinetime/InfiniTime/node_modules/lv_img_conv/lib/image-q/image/array.ts:146:20)
at Immediate.next (/home/laptop/Local/pinetime/InfiniTime/node_modules/lv_img_conv/lib/image-q/basicAPI.ts:163:33)
at processImmediate (node:internal/timers:476:21)
Traceback (most recent call last):
File "/home/laptop/Local/pinetime/InfiniTime/src/resources/generate-img.py", line 56, in <module>
main()
File "/home/laptop/Local/pinetime/InfiniTime/src/resources/generate-img.py", line 51, in main
subprocess.check_call(line)
File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/laptop/Local/pinetime/InfiniTime/node_modules/.bin/lv_img_conv', '/home/laptop/Local/pinetime/InfiniTime/src/resources/images/navigation0.png', '--force', '--output-file', 'navigation0.bin', '--color-format', 'CF_INDEXED_1_BIT', '--output-format', 'bin', '--binary-format', 'ARGB8565_RBSWAP']' returned non-zero exit status 1.
Using "lv_font_conv": "^1.5.2","lv_img_conv": "^0.3.0"
(npm chose the versions for me)
Add comments about the layout of the pictures that contain the icon and about the indexing of those icons.
In documentation (buildAndProgram.md), edit the section about the debug compilation mode. Remove the part about removing the Navigation app to free some memory (since it's not relevant anymore) and explain how to selectively build parts of the firmware in Debug mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now! Shall we merge the PR that prevents starting the navigation app if the files aren't present after this one?
@FintasticMan If you're OK with this, we can merge #1847 after we merge this one. |
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 These are the versions I'm using on my dev setup:
|
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 |
Maybe try using the node lockfile from #1764. |
I experienced this issue in #1819, try pinning |
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 |
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) |
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). |
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 :) |
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. Add comments about the layout of the pictures that contain the icon and about the indexing of those icons. In documentation (buildAndProgram.md), edit the section about the debug compilation mode. Remove the part about removing the Navigation app to free some memory (since it's not relevant anymore) and explain how to selectively build parts of the firmware in Debug mode.
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 :
20230820_204038.mp4