Comments (17)
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.
Hi, could you make an example of:
menuNode::activeMenu;
menuNode::activeMenu->sel;
I can't figure out how to use it.
from arduinomenu.
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.
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.
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.
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.
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.
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.
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.
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.
How I do that?
from arduinomenu.
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.
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.
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.
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.
You're welcome. :D
from arduinomenu.
just for reference
from arduinomenu.
Related Issues (20)
- EDIT via rotary encoder
- is your libary compatible with OLED display with 1309 controller
- Use of SSD1306ASCII_OUT HOT 1
- Not working without serial connection HOT 1
- TFT_eSPI and FreeFont (custom font) HOT 1
- error: reference to 'config' is ambiguous
- Full graphic smart controller - cannot get the ecnoder to scroll nicely
- Disable SerialOut HOT 1
- Starting integration of LCDGFX display driver with ArduinoMenu HOT 1
- Events on SELECT-submenu out of sync
- Feature Request: Have a way to disable a menu entry by default
- After defining MENU_DEBUG project doesn't compile for ESP32
- Example request: A working ESP32WebMenu example would be nice
- SubMenu does not respond unless extra menu item is added
- noMacros example should also show how to incorporate inputs and outputs without macros
- Doesn't compile with latest board ESP32 v. 3.0.0-alpha2
- Hide a menu
- Support for EA DOGM series of displays using SSD1803 controller IC
- Support for Initialization Outside of Main HOT 2
- Debouncing Buttons HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinomenu.