Commit graph

7 commits

Author SHA1 Message Date
Mikael Degerfält
5b59b4cd0f Final push to unify all menu states
All states are now handled by the new menu system, although some are flagged to have a custom handler that does everything by itself.

I replaced most reference parameters to pointers to be able to typecast in a nicer way.

Key input is not passed as a parameter to the menu functions instead of having global variables they all access. I think I broke one thing by doing this, since there is no way to propagate key input changes to the next frame.
2019-06-23 17:14:18 +02:00
Mikael Degerfält
be0d08d8d6 Renamed some stuff for clarity 2019-06-23 17:14:18 +02:00
Mikael Degerfält
bddbffd51d Moved over the rotation menu to new system
Had to change how the values where stored in RAM from singed to unsigned to be able to use the generic menu features. Also had to add the MenuEntrySub as a parameter to the menu callback functions to be able fo display and store the correct values.

Did some major cleanup now that the special case of rotator menu is gone together with all uses of the old version of the sub menu struct.
2019-06-23 17:14:18 +02:00
Mikael Degerfält
65aa0f4dab Converted more of the sub menus to the new sub definitions
Found out that it’s the lambda functions used for pointer that forces the structs to be in ram instead or rom.
2019-06-23 17:14:18 +02:00
Mikael Degerfält
699546df8c Handle sub menus in a generic way and moved adjust menu logic to separate file
This is a big one where I can finally reap what I sown. Sub menu entries now provide two functions, one to get the text for the current value and one to apply changes aka save to EEPROM. With this I can replace so much code in the menu() function that handles input, but was _almost_ identical. The process of converting the old menus are not completed, and I can probably remove about 200 lines more code.

The question is still what to do with less general menus like the rotator and fast patch menu.

One problem with the current implementation is that it is RAM heavy. It seems the const MenuEntry structs are placed in ram, because there is a pointer to RAM that I assume is allocated during execution and therefore the address cannot be stored in ROM.

My plan has been to put all the configuration fields (that are stored in EEPROM) into a struct or an array. When that is implemented, I can instead store the offset into the array in the const struct, which should be available at compile time and therefore can reside completely in ROM.
2019-06-23 17:14:17 +02:00
Mikael Degerfält
0d0ea5051d Made the sensor adjust menu driven by data
* Moved menu titles and option names into data structures.
 * Unified select menu option code
 * Also unified handling of menu selection, although main and rotator menus are still handled the old way.
 * Moved struct definitions to numenu.h
 * Grouped functions and variables together based on usage.
2019-06-23 17:14:17 +02:00
Mikael Degerfält
e362546e3c First iteration of menu cleanup
* Broke up the code into more general functions instead of duplicating code
 * Made stuff const and removed variables no longer used
 * Use defines for menu button values
 * Changed the order or things to avoid forward declarations
 * Use array lookup instead of switch-case on some menu options
 * Adjust menu functionification
 * Cleaned up sensor rendering
2019-06-23 17:14:17 +02:00