2023-01-25 02:16 AM
I try to implement a multilevel menusystem with one scrollwheel-widget and pysical buttons.
I added a scrollwheel with 10 items(even if my menu has not 10 items in every level of hierachy) and want to manage the items on my own, as i want to use this scrollwheel to show every level of my menusystem
root
A
A0
A1
B
B0
B1
C
C0
C1
But i'm having some troubles with foring the correct redraw of the scrollwheel.
I overloaded
void MenuLevel1View::scrollWheel1UpdateItem(menuItemNormal& item, int16_t itemIndex)
void MenuLevel1View::scrollWheel1UpdateCenterItem(menuItemSelected& item, int16_t itemIndex)
I can navigate trough my root menu level and the overloaded update functions are called and i see ABC in a list as expected.
When i want to switch to another menulevel i call a function to set the root of my scroolwheel to the new tree-node to show all it's leafes (set to C should show C0 and C1)
When i have selected "C" the itemindex of the scrollwheel is 2
I tried to call
scrollWheel1.invalidate();
scrollWheel1.initialize();
scrollWheel1.itemChanged(0);
but no matter what i do the UpdateItem functions are always called with itemindex starting at the position which was last selected. So when i try to switch into the Level A it works because last itemindex is 0.
But on Level B or C it does not work as expected because the last itemindex is 1(B) or 2(C)
So when i switch into B B1 is selected. When i switch into C the element C2 is selected (which does not exist) I can then scroll up and i see the elements C0 & C1
So what do i have to do to force the redraw of all the scrollwheel list elements staring with itemindex 0?
Solved! Go to Solution.
2023-01-26 04:55 AM
Hey again,
I analyzed your project quickly, and I think the issue comes from the fact that you are using only one ScrollWheel object in all your application, and so when you navigate to the second item of your first view "System Config", the item index will be set to one.
Then, when you switch to the sub-wheel, it will animate automatically to the item number 1 of your wheel, so it will go to "Contrast" rather than the first element "Address". I deduct from that that the initialize() method does not reset the current item index to 0.
I would recommend you to use the animateToItem(0, 0) like you did, it is a good way to ensure that the sub-wheel start at the first index.
/Yoann
2023-01-25 02:28 AM
the same happens when i switch back from my submenus to the root level.
if i had selected menuindex 0 in my submenu it switches back to root level and A is selected
with selected menuindex 1 it switches back to B, with menuindex 2 in the submenu it switches back to C
If i have more elements in my submenu than in my root level it switches to this index and nothing is selected but i can then scroll up and see ABC
2023-01-25 03:04 AM
Hello @Jnevi.1,
I'm sorry but what you are trying to do is really hard to understand.
Could you please reformulate and try to add some screenshots, so we can better understand the problem ?
Thank you,
/Yoann
2023-01-25 03:58 AM
:D ok
In braces this is the item index
Menu level
(0) Language
-(0) German
-(1) English
(1)System Config
-(0) Address
-(1) Contrast
-(2) Keytone
- (3) factory reset
- etc etc
(2)Info
-(0) Hardware
-(1)Firmware
i added some screenshots
this is all done in the same scrollwheel.
When i enter the submenu of "system config" i would expect i land at "address" but i don't because "system config" was itemIndex 1 and when i reinitialize/invalidate the scroolwheel it somehow starts to update with itemIndex 1.
when i go into submenu of "Info" which is itemIndex 2 i would expect to go to "Hardware" but i go to a non existing itemIndex becaue it starts the update with itemIndex 2
So my methods
void MenuLevel1View::scrollWheel1UpdateItem(menuItemNormal& item, int16_t itemIndex)
void MenuLevel1View::scrollWheel1UpdateCenterItem(menuItemSelected& item, int16_t itemIndex)
are called with wrong itemIndex
When i invalidate or initialize the scrollwheel i would expect it starts to redraw with itemIndex 0 which it somehow does not
Is this clearer explained?
2023-01-25 04:09 AM
but now when i enter my submenu level (or switch back from submenu level to root level) i do
scrollWheel1.animateToItem(0, 0);
scrollWheel1.initialize();
This always animates the scrollwheel from the wrong position to itemIndex 0 (which always exists) and i get the result i want.
But i still would expect after scrollWheel.initalize() it starts to init with itemIndex 0, or are my expectations wrong?
2023-01-25 04:22 AM
That's much clearer, thanks.
Is it possible for you to share your project ? I would like to try some things on it.
/Yoann
2023-01-25 04:58 AM
i sent you a pm with a stripped down project via PM. hope you can make sense of it
currently the
scrollWheel1.animateToItem(0, 0);
scrollWheel1.initialize();
in btn0Long & btn1Long fixes the error. so if you comment these out you should get the described error
2023-01-26 04:55 AM
Hey again,
I analyzed your project quickly, and I think the issue comes from the fact that you are using only one ScrollWheel object in all your application, and so when you navigate to the second item of your first view "System Config", the item index will be set to one.
Then, when you switch to the sub-wheel, it will animate automatically to the item number 1 of your wheel, so it will go to "Contrast" rather than the first element "Address". I deduct from that that the initialize() method does not reset the current item index to 0.
I would recommend you to use the animateToItem(0, 0) like you did, it is a good way to ensure that the sub-wheel start at the first index.
/Yoann