-
Notifications
You must be signed in to change notification settings - Fork 84
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
Dynamic Settings Menu #19
Open
dmadison
wants to merge
38
commits into
UnexpectedMaker:master
Choose a base branch
from
dmadison:menu-options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Distinguishing between the current menu items and the buttons to control them
Now supports an "infinite" (2^16) number of menu items!
9 items per page, not 8. Caused by indexing 'items per' at 1 and the items themselves at 0.
Not quite as pretty as filling the whole screen with options no matter where you are, but more efficient to redraw it once rather than every time the user pushes down.
Because these work around the buttons and are not specific to the settings page, I'm moving them to the main file so they can (potentially) be called by other menu modes.
Don't do a 'clear all' on the buttons to avoid clipping long menu items at the end of the list, and clear the description box on redraw for description text longer than the 'standard' items area.
STOP. FREAKING. BEEPING.
All defaults are set in the struct definition itself. This avoids mixed messages about what settings are actually 'default'.
To disable the buzzer, but ONLY when pressing buttons and not for functional purposes (e.g. opening the oven door at the end of reflow).
Avoids having to repeat the colors everywhere, and makes it easier to change them. Can still be overridden if necessary.
Visual feedback that the mode can't be entered. Particularly useful when the buzzer is disabled.
Allows the pointer to loop around from the bottom to the top and vice-versa. Helpful for long settings lists.
Small quality of life change, but if you cancel the "reset to default" menu option, the menu stays at that setting (and that page) instead of starting over at 0.
Making it clear that we're returning the object rather than some reference to position
Reduces flickering by only updating the menu item value rather than the name and value (at the expense of calculating the text bounds each call)
Otherwise this is called twice
Since this function isn't "updating" anything but the display, and the name makes me think it's doing calculations on the pointer value itself.
This is redundant, as all modes with "SELECT" are used to load new pages and do not need to refresh on change.
Allowing the class to override these buttons as-needed.
Not strictly necessary, but increases encapsulation and avoids any weirdness with modifying the global selection value when switching between menus.
This way the entire page is drawn with a call to 'draw' (something something encapsulation).
For overwriting the button text exactly, rather than bulk clearing an area.
These functions were all static anyways, and this better fits with the mostly functional programming at use elsewhere.
Better encapsulation yada yada
Handling nullptr for the 'get' function, and going directly to the 'show' pages rather than using a helper.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR rebuilds the settings menu from the ground up using objects and a linked list. This enables you to define new menu items using only a few lines of code, and lets the menu scroll to accommodate more items than can fit on the screen.
The menu supports two scroll modes: 'smooth' and 'paged'. By default this uses 'paged' because it requires fewer refreshes of the screen. Both modes insert a positional indicator between the up and down arrows (3rd + 4th buttons) if the number of options exceeds a single page. The up/down selections now also wrap around from the edges of the screen (e.g. at the top pressing 'up' will select the last item).
There are three new menu options:
(the buzzer was annoying me)
There are a few miscellaneous quality of life changes in here as well. When the thermocouple is not connected the 'Reflow' menu item will flash red when selected to indicate an error in addition to beeping the buzzer. The settings struct resets to defaults by copy instead of with a second function (to avoid two sets of default options). I also rebuilt the button drawing system to use a single function that takes the button index, text, and color as an argument. This saves a lot of repeated code for each different page.
I'm guessing that these changes are too sweeping due to your secret development branch, but I thought I would submit the PR nonetheless. Perhaps you can cherry-pick any commits that work with your version.