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

feat(color): Replace static bitmap QR code with LVGL generated QR code #3880

Merged
merged 1 commit into from
Aug 28, 2023

Conversation

philmoz
Copy link
Collaborator

@philmoz philmoz commented Jul 30, 2023

This functionality could also be used in future to add 'help' links to pages.

@gagarinlg
Copy link
Member

I am still thinking about a way to share model settings via QR Code and a camera in the TX

@pfeerick
Copy link
Member

Bluetooth/wifi link to your phone, app on your phone? 🤭

@raphaelcoeffic
Copy link
Member

share model settings via QR Code and a camera in the TX

You'll have hard times encoding everything into a single QR code. Most apps doing this do upload everything and generate a single ID, which is exchanged via QR code, and then used to download whatever needs to be exchanged.

@raphaelcoeffic
Copy link
Member

@philmoz the most interesting question is: what is the impact on FLASH usage? Aka. is code more efficient than a pre-generated image?

@philmoz
Copy link
Collaborator Author

philmoz commented Jul 30, 2023

@philmoz the most interesting question is: what is the impact on FLASH usage? Aka. is code more efficient than a pre-generated image?

Replacing only a single QR image will use more FLASH for the LVGL QR library - ~6K on TX16S.
The libopenui refactor PR saves ~5K so overall it's not too expensive.

@pfeerick
Copy link
Member

pfeerick commented Jul 30, 2023

Last main build:

Totals         KB    usage  of ttl	KB free
  Flash:  1572.14   76.76%    2048	 475.86
  CCRAM:    47.15   73.68%      64	  16.85
  SRAM1:    72.75   64.96%     112	  39.25
  SRAM2:     0.00    0.00%      16	  16.00
  SRAM3:     0.00    0.00%      64	  64.00
 SDRAM2:  5116.00   62.45%    8192	3076.00

This PR:

Totals         KB    usage  of ttl  KB free
  Flash:  1577.86   77.04%    2048   470.14
  CCRAM:    47.15   73.68%      64    16.85
  SRAM1:    72.77   64.98%     112    39.23
  SRAM2:     0.00    0.00%      16    16.00
  SRAM3:     0.00    0.00%      64    64.00
 SDRAM2:  5116.00   62.45%    8192  3076.00

Given it opens up the avenue for more QR codes for other stuff, I can live with that... 90% is still far away (will regret that soon, I'm sure!)

@raphaelcoeffic
Copy link
Member

90% is still far away (will regret that soon, I'm sure!)

You didn't try the TW build, right? 😇

@gagarinlg
Copy link
Member

gagarinlg commented Jul 30, 2023

When the libopenui refactor PR is merged and it really saves 5kB, 2e are good.

@pfeerick
Copy link
Member

90% is still far away (will regret that soon, I'm sure!)

You didn't try the TW build, right? 😇

Not since 2.8.4, with extra heli and luamixer 🤭

Totals         KB    usage  of ttl	KB free
  Flash:  1971.34   96.26%    2048	  76.66

@philmoz
Copy link
Collaborator Author

philmoz commented Jul 30, 2023

Ouch - what causes that huge jump?

@raphaelcoeffic
Copy link
Member

Ouch - what causes that huge jump?

The fonts.... They are quite huge for asian languages (especially XXL).

@pfeerick
Copy link
Member

TW character set is a lot bigger than our paltry English one... plus that firmware still has all the binary conversion support, and luamixer on top.

@gagarinlg
Copy link
Member

So we need a ttf font renderer and cache used symbols in Ram?

@3djc
Copy link
Collaborator

3djc commented Jul 30, 2023

I was about to add a qr code for undisclosed hardware so I vote for this !

@philmoz
Copy link
Collaborator Author

philmoz commented Jul 30, 2023

RTTI costs about 78K on my TX16S build. Unfortunately it's required for a handful of places where dynamic_cast is being used. Has anyone tried to get this of this?

@gagarinlg
Copy link
Member

Where are dynamic casts used?

@philmoz
Copy link
Collaborator Author

philmoz commented Jul 30, 2023

Screen layouts and widgets.

@JimB40
Copy link
Collaborator

JimB40 commented Jul 30, 2023

Can it be used to generate qrcode in *.png that is saved to SD? I have qrcode LUA but it is so calculation intensive that is almost killing MCU.

@philmoz
Copy link
Collaborator Author

philmoz commented Jul 30, 2023

Can it be used to generate qrcode in *.png that is saved to SD? I have qrcode LUA but it is so calculation intensive that is almost killing MCU.

Possibly. Rendering to an off screen canvas should be ok; but not sure about saving to a png file.

@philmoz
Copy link
Collaborator Author

philmoz commented Jul 31, 2023

So we need a ttf font renderer and cache used symbols in Ram?

LVGL can load binary format fonts from files. Binary fonts can be created with the lv_font_conv program by changing the output format.

I've mocked up a quick test of this to load the XL and XXL fonts from the SD card instead of embedding them in the firmware.

Tested and working in the simulator and TX16S.

If the fonts can't be loaded then the L font is used instead.

Any thoughts - is it worth developing further? It would require adding font files to the SD card content.

@3djc
Copy link
Collaborator

3djc commented Jul 31, 2023

If XL and XXL are indeed not used by the non lua stuff (and likely not used by most lua add on either) then it would be something to look at as a side pr to reduce flash usage, imho

@pfeerick pfeerick changed the title feat(color): Replace static bitmap of 'https://edgetx.org' QR code with LVGL QR code generator. feat(color): Replace static bitmap QR code with LVGL generated QR code Aug 4, 2023
@JimB40
Copy link
Collaborator

JimB40 commented Aug 4, 2023

If you do research XXLSIZE is used mostly for numbers.
https://github.com/search?q=XXLSIZE+language%3ALua&type=code&p=1&l=Lua
Thats obvious as XXL font is way to big to use for anything meaningful as text.

There are 2 or 3 cases LUA dev used it for text.
Screenshot 2023-08-04 at 08 36 01

Not important though as "No Value" can be replaced with '-'.

So if it matters for reducing firmware size I'd left XXL font, but change it - so it contains Numbers & Special Characters like '-', ':'

@pfeerick
Copy link
Member

pfeerick commented Aug 4, 2023

@JimB40 Check #3881 ;)

@pfeerick pfeerick added this to the 2.10 milestone Aug 26, 2023
@pfeerick pfeerick added the color Related generally to color LCD radios label Aug 26, 2023
@pfeerick pfeerick self-requested a review August 28, 2023 02:55
@pfeerick pfeerick merged commit e56cffa into EdgeTX:main Aug 28, 2023
36 checks passed
@philmoz philmoz deleted the about-us-qr-code branch November 5, 2023 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
color Related generally to color LCD radios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants