[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 

How to Use the ListRuntimeMenuItem RSS feed
Forum Index » tcMenu Arduinio library
Author Message
Snafky


Joined: Jul 30, 2019
Messages: 4
Offline
Hi All!

I'm love the tcMenu lib and thank you so much for creating it!
I gives hobby/amateur programmers the ability to create something which would have taken me probably to long or even impossible (for me).

It is with this mindset that come to the following question.
How should I use ListRuntimeMenuItem to create a dynamic list of items during runtime(to select from).
I know it mainly my lack of understanding why i can't use is properly.
The main thing i don't understand is how to handle the "V" parts in the code ( buffer[0] = 'V'; buffer[1]=0 smilie.

I cannot find any examples how to use it in the "example" folder.
I did read the documentation but i'm not getting all of it (or how it fits together, sorry).
I hope that there is anyone out there that can help me....

This is the code stub created automaticly for handling the menu
// see tcMenu list documentation on thecoderscorner.com
int CALLBACK_FUNCTION fnDevicesRtCall(RuntimeMenuItem* item, uint8_t row, RenderFnMode mode, char* buffer, int bufferSize) {
   switch(mode) {
    case RENDERFN_INVOKE:
    	Serial.println("Index selected: " + String(row));
        // TODO - your code to invoke goes here - row is the index of the item
        return true;
    case RENDERFN_NAME:
        // TODO - each row has it's own name - 0xff is the parent item
    	
        ltoaClrBuff(buffer, row, 3, NOT_PADDED, bufferSize);
        return true;
    case RENDERFN_VALUE:
        // TODO - each row can has its own value - 0xff is the parent item
        buffer[0] = 'V'; buffer[1]=0;
        
        fastltoa(buffer, row, 3, NOT_PADDED, bufferSize);
        return true;
    case RENDERFN_EEPROM_POS: return 0xffff; // lists are generally not saved to EEPROM
    default: return false;
    }
}
davetcc


Joined: Jan 19, 2019
Messages: 532
Offline
Thanks for the post. TcMenu took quite a bit of work to get it where it is.

Agreed there are no real examples of lists at the moment. I’ll add a list item to one of the examples. The docs were updated for it yesterday but still not as good as an example.

Here’s a link to an actual use in the core code but by no means an example.

https://github.com/davetcc/tcMenuLib/blob/master/src/RemoteMenuItem.cpp Function: authenticationMenuItemRenderFn
Snafky


Joined: Jul 30, 2019
Messages: 4
Offline
Thank you for the quick reply!
And indeed i can see all the efforts in TcMenu and i can imagen some examples are not there. smilie

Tonight (i'm in europe) i'll try to interpret what is on your link and do my best to understand it smilie.
Please let me know if i can help with anything. smilie
Snafky


Joined: Jul 30, 2019
Messages: 4
Offline
Thanks to your tip to look at the other function i did get something more to go.
Unfortunatly i miss the knowledge/skill to wrap my had around the way the names of the menu items are derrived.
I see they come from a "const char XXX[] PROGMEM = "xxxxx";.
But my intention is to have the values dynamic at runtime.
As is said i miss some understanding and knowledge

I'll continue later with finding the exact way and understanding it.
Thank you for your help so far.
davetcc


Joined: Jan 19, 2019
Messages: 532
Offline
There’s nothing that says they have to come from program memory. When the callback asks for the name the only thing you need to do is copy it as a zero terminated string into the buffer parameter provided. The buffer parameter is an array of char. The buffer size parameter is the number of elements in that array.

To be honest for this level of embedded C / C++ coding you’re going to need to fully understand c zero terminated character arrays. There are many online guides for that.
Snafky


Joined: Jul 30, 2019
Messages: 4
Offline
thanks for your reply and i'll dig into the subject for sure.
I have noticed its my tripping point in many source code i see and indeed the problem lies with me.
Thank you for the patient i'll have to learn how to use this stuff so i won't hold you longer with my questions.
Cheers.
davetcc


Joined: Jan 19, 2019
Messages: 532
Offline
No problem, hope you enjoy learning C strings and pointers!
 
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

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.