Git Product home page Git Product logo

Comments (17)

nicodonte avatar nicodonte commented on May 18, 2024

I managed to solve partially by converting integer to String, and then convert to char. But I don't know if there is an easier way to do it.

int nivelBlight=200;
String nivelBlightText = "Nivel: ";
char nivelText[10 + 1];

MENU(configMenu, "Configuracion",
SUBMENU (relojMenu),
OP(nivelText, bklMenu)
);

String nivelBlightText = "Nivel: ";
nivelBlightText.concat(map(nivelBlight, 0 , 255 , 0 , 100));
nivelBlightText.toCharArray(nivelText,11);

Regards,
Nico.

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

Hi, could you make an example of:
menuNode::activeMenu;
menuNode::activeMenu->sel;

I can't figure out how to use it.

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024

you can change the menu text of a prompt, ex:

mainMenu.data[2]->text="Some new text";//change third option text
mainMenu.redraw(lcd,allIn);

this works, but flicks the menu on redraw, so frequent changes will leave the menu flicking

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

Thanks for your reply.
I'm still struggling with the POINTER variables to know where I am located in the menu. I do not understand how to make a comparison of these variables.

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024

each menu prompt has an associated function that is called when the prompt is selected, if you have a different function for each prompt then you will just know.
the idea is to leave the navigation details to the menu.
however the associated function can be as simple as a "void f()" or can have extra information passed to it "void sayIt(prompt& p,menuOut& o,Stream &c)", on this version you will have a reference to the activated prompt, menuOut device , and input stream.
you can have any combination of the above, from () to the full length (it allows parameters to be omitted).
so you still need the navigation info?

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

Yes, I still need it, it will simplify my code if I could use switch ... case structure. It will be useful for me also if I can put a variable to the OP menu command or maybe calling a procedure with a variable inside OP("text", routine(variable)).

Thanks in advance for your time and helpful hints!!

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024

well it might not be safe as internal navigation details can change... anyway
menuNode::activeNode is the pointer to an active menu node (or zero if none)
this is an object of type menuNode, but you can cast it to menu if you are sure it is a menu

((menu*)menuNode::activeNode)->...

with the casting you can access any of menu data members (you can cast to a menuField if its the case).

((menu*)menuNode::activeNode)->sel; // its the last selected option on current active menu

is that what you want?
p.s. I've not tested this

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

I don't need to access to one specific menu right now, I need to know which menu was the last selected, cos I can call the same routine and change variables according to the menu I was. In my project, I have four timers, each of them has same options, start time, period, fade time, and level max. If I use OP in the menu, I have to write four times the same code, but if I knew where I came, it could be easy as using an array variable to set the timers variables.

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

When I tried to use menuNode::activeNode->sel;

I get error: 'class menuNode' has no member named 'sel'
'class menuNode' has no member named 'sel'

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024

not it has not, you need to cast it to menu*
menuNode::activeNode can point to a menu or a menuField, if you are using both then you can check

menuNode::activeNode->isMenu()

before casting

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

How I do that?

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024
int selOp=menuNode::activeMenu->isMenu()?((menu*)menuNode::activeNode)->sel:-1;

this will set the variable selOp to the selected menu option or -1 if none

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

if I use int selOp=menuNode::activeMenu->isMenu()?((menu*)menuNode::activeNode)->sel:-1; in the main loop, it makes the screen to blink constantly.

If I use int selOp=((menu*)menuNode::activeNode)->sel; I can see the menu number, but as you said before, I can't know in which submenu that I came.

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024

maybe you should look at the NoMacros example, as a way of build a menu-system without using the macros. That way you will have variables for each menu and prompt and can compare them.
The problem with macros is that you don't know the addresses of prompts menus other than the main menu.
guess that a

if (menuNode::activeMenu==mySubMenu1) ...

will solve your problem

from arduinomenu.

nicodonte avatar nicodonte commented on May 18, 2024

Ok I will try that method. I'm a bit newbie programming in C.

Thank you so much for your time and patience.

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024

You're welcome. :D

from arduinomenu.

neu-rah avatar neu-rah commented on May 18, 2024

just for reference

#293

5c9710a

from arduinomenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.