[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Dynamic enum menu RSS feed
Forum Index » tcMenu Arduinio library
Author Message
pmst


Joined: Oct 4, 2020
Messages: 2
Offline
Hello,
I am new to tcmenu and I have the need to dynamically create the list of enum items at startup (from a eeprom saved string which is then parsed and builds up the list and other information for the rest of the system).
What would be a good way to do this ? Subclassing EnumMenuItem ? And in this scenario how would I use the designer ? Am I missing something ?

Thanks,
Al
davetcc


Joined: Jan 19, 2019
Messages: 167
Offline
Hi there,

At the moment this is not implemented in the core but we do plan to support it. Two options for right now:

* you could try locally modifying the EnumMenuItem to handle this for now, but the designer wouldn't be able to work with that item. However, you can add items into a menu yourself at runtime, a menu list is nothing more than a linked list (where each menu item has a next pointer).
* My favoured approach would be to implement it as a editable RuntimeMenuItem, these are quite new so the documentation is not great, but the reference implementations in RuntimeMenuItem.cpp/.h should point you in the right direction. Again as above, you'd just add this custom menu item into the linked list at the right place in code.

This may suffice for you in the immediate/short term, while we get around to this feature. You'll even see how to add extra menu items at runtime in the packaged esp8266 example.

As I said above, we have a plan to add it, as in the longer term we need it ourselves for a few projects. However, at the moment we are on a stability drive, the last two releases have introduced bugs onto some of the platforms, as there have been a few huge changes introduced (RTOS support, multi-core safe task manager). We need a couple of cycles where there are no new major features. But we'll add it to the 1.7 issues.

May I ask that you add an issue into https://github.com/davetcc/tcMenuLib/issues with the information about how you see it working, and I'll combine with our existing thoughts on it.

So for now, you could do as suggested above, and add a menu item yourself with my preference being a editable runtime menu item.
davetcc


Joined: Jan 19, 2019
Messages: 167
Offline
Actually, I've chatted a long time user, and they had one internally. It was based directly on RuntimeMenuItem and I should have something working soon. Given this, and it's a very low-risk addition, we'll do it in a patch release.

We'll try and get it into the next designer release as well. Again it's low risk and only affects anyone who uses it.
pmst


Joined: Oct 4, 2020
Messages: 2
Offline
Hi Dave,

thanks for the helpful hints and suggestions ! After reading it I just realized that for my application use case adding programmatically the menu is enough (the configuration that creates the menu is read at startup time), so for this application I created the items, the EnumMenu and added to the linked list...
I think that anyway the additional solution you mentioned in last reply would be very nice and helpful so I will keep an eye on it.


Al
davetcc


Joined: Jan 19, 2019
Messages: 167
Offline
Yes, actually, I've taken it a step further and am creating a ScrollMenuItem, this will be able to scroll through large lists of items that change at runtime. For example, the channels on a DAB radio or the tracks on a CD. It will have several choices:

1. The ability to fill it as you go, by providing a delegate callback that's just asked for the string value of each item index.
2. The ability to provide a number of values from EEPROM in a fixed array, again the size can change at runtime, and if less than 255bytes can be cached into RAM, as EEPROM is very slow to read.
3. The ability to provide a fixed array in RAM (similar to the EEPROM example but in RAM).
4. Stick with the existing enum item for smaller fixed arrays like now.
 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer