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

Reduce flash usage by 3.7K by changing CMS data structures #4380

Merged
merged 3 commits into from
Mar 1, 2019

Conversation

fiam
Copy link
Member

@fiam fiam commented Feb 17, 2019

After discussing CMS space optimisations with @hydra, the following changes were identified as potential flash savers:

  • Packing OSD_Entry struct. It's not used in performance critical code, so it shouldn't impact flight characteristics.
  • Reworking the fields in OSD_Entry so they're naturally aligned (reduces the code needed to deal with the packed struct)
  • Combine OSD_Back and OSD_END into a single OSD_BACK_AND_END item, saving an OSD_Entry per menu.

Tested and ready to merge. Could probably wait for 2.2.

@fiam fiam changed the base branch from master to development February 17, 2019 10:09
Saves ~3k flash without any significant performance impact
As suggested by @hydra. Saves another 260 bytes of flash.
As suggested by @hydra. OME_Back and OME_END continue to be valid
items, but we now also have OME_BACK_AND_END which creates a back
entry and indicates the end of the menu, saving an entry. On F3,
this saves 464 bytes of flash.
@fiam fiam added this to the 2.2 milestone Feb 17, 2019
@teckel12
Copy link
Contributor

@fiam Nice, keeping the F3 viable a bit longer.

@hydra
Copy link
Contributor

hydra commented Feb 18, 2019

i suspect that you might save even more flash if you drop the back/end marked all together and pass sound a structure for the menu.
something like:

typedef struct cmsMenu_s {
const OSD_Entry entries;
const uint8_t entry Count;
} cmsMenu_t

would save the size of OSDEntry_t - size of cmsMenu_t per menu.

likely the loops become easier and conditional code may be removed too.

@hydra
Copy link
Contributor

hydra commented Feb 19, 2019

Don't let my comment above prevent you from merging this however. You can do another PR for that later.

@digitalentity digitalentity merged commit 471849b into development Mar 1, 2019
@digitalentity digitalentity deleted the agh_cms_flash_reduction branch March 1, 2019 19:17
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.

4 participants