Comments (7)
A more object oriented approach could be to add
class NexObject
{
public: /* methods */
...
bool setVisible(bool flag);
}
to NexObject.h
and
bool NexObject::setVisible(bool flag)
{
const char *name = getObjName();
if (!name)
{
return false;
}
String cmd = String("vis ");
cmd += name;
cmd += ",";
if (flag) {
cmd += "1";
} else {
cmd += "0";
}
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
to NexObject.cpp
PS : be aware that it's untested... so you probably need some fixes.
from iteadlib_arduino_nextion.
Code from @scls19fr worked well for me, with some fixes:
- few missing semi-colons
- need to add include statement for NexHardware.h at NexObject.cpp beginning
#include "NexHardware.h"
from iteadlib_arduino_nextion.
I'm in the same situation, needing to hide a button based on a specific status at run time. I got here first and thought that I wished there was an answer. I have been tinkering a little with this and have not found a direct way of either hiding/disabling the button or just moving it off the screen (this can be done at design time but not at run time as far as I have been able to test).
Here is what I plan on doing. I am using buttons with "crop images". I have created a 3rd version of the button image with a grayed out button (though you could create one without any button at all). You can programatically change the button image so I plan on setting the button state (both picc and picc2) to the 3rd image and when re-enabling the button setting them back to the original. You have to keep track of what the status of the button is within your arduino code as the button will still send events when the images are in the "disabled" mode so you will have to ignore button clicks in your code.
I will report back when I have tested this approach in arduino, so far I have only tested it in the debug window of the Nextion editor.
from iteadlib_arduino_nextion.
After some more tinkering I found that it is actually pretty straight forward to hide an element:
Serial1.print("vis b3,0");
Serial1.write(0xff);
Serial1.write(0xff);
Serial1.write(0xff);
in this case b3 = element to hide or show, 0 to hide, 1 to show.
Remember that Nextion is very particular about whitespace, leave no whitespace except between the vis instruction and the element name (you can also use element ID).
from iteadlib_arduino_nextion.
Can you tell me how I would use the above code ? I tried "objectName.setVisible(true);" and objectName::setVisible(true); and objectName.setVisible() = true; with no luck . Thank you.
from iteadlib_arduino_nextion.
I'm using pointer objects to some text fields and radiobuttons, and it works well for me
text_field->setVisible(true);
from iteadlib_arduino_nextion.
from iteadlib_arduino_nextion.
Related Issues (20)
- How to send timer id to uart? HOT 1
- Examples are out of date HOT 2
- Nextion library contains compile errors HOT 2
- Problem regarding upload example
- Not really and Arduino issue HOT 1
- testNextionNumberBox
- set pco issues
- Examples to old HOT 3
- Arduino Giga Problem HOT 3
- FIXED unable to change picture
- Compile error in arduino IDE of the library
- Filename of the exaples differs from the Foldername
- When i try to upload file in my Ardunio mega i get error
- Library update for Arduino Nano 33 IoT and 33 BLE? HOT 5
- Library wastes too much memory
- Compatibility with Controllino HOT 1
- nextion setText dosent work fine in arduino esp32 HOT 1
- Nextion
- Read the current page nextion
- subtle recvRetNumber coding error
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 iteadlib_arduino_nextion.