0

I have a nextion display. I want to implement this issue of it. Start the program. If for example I don't touch the display for 15seconds, it should to turn off its brightness. If I touch the screen on any point, it should to increase its brightness.

For this I m build this code:

In PreinitializeEvent of page 0, I have insert this code:

tm0.tim=0
tm0.en=1
dim=30

In Touch Release Event of page 0, I have insert this code:

dims=100

But if I try to start the program, the brightness is always the same. Not increase.

/EDIT

I use Nextion Edito 0.58 enter image description here

  • PreinitializeEvent is a View of NExtion IDE – bircastri Oct 11 at 15:35
  • @bircastri, in this stackexchange.com space we primarily concern our selves with answering questions about developing using the Arduino IDE. While the Nextion IDE looks interesting, some may consider it off topic. Also, consider the Nextion IDE its self may not have the feature you are looking for. – st2000 Oct 11 at 16:26
1

The original question has been improved (which is appreciated) to include the IDE which the poster is using. In this stackexchange.com space we primarily concern our selves with answering questions about developing using the Arduino IDE. While the Nextion Editor looks interesting, some may consider it off topic.

For those who come here interested in controlling the brightness of their Nextion Display and are using the Arduino IDE, there is this answer:

There appears to be several Nextion Arduino Library efforts to choose from. If you are using this Nextion Display Library, here is the example code which set the screen brightness. The part of the code which sets the screen brightness is rather simple and resides in the Arduino loop() function. In the loop() function the brightness is set repeatedly as the program continues to run:

void loop() {
  int brightness = analogRead(A0);
  int bright = map(brightness, 0, 1024, 0, 100);
  String dim = "dim=" + String(bright);
  myNextion.sendCommand(dim.c_str());

}

For those of you using the Nextion editor and the Nextion Arduino Libraries, there is this github.com Issue which talks about adding multiple missing Nextion features including a screen brightness function. This issues appears to still be OPEN (Bad support? / Bad house-keeping?). But is over a year old so may have be incorporated. If so, here is the example code from that link:

/**
* Set the brightness of the display.
*
* @param buffer - number (0 - 100).
*/
bool setBrightness(byte buffer);
  • Since you didn't specify which Nextion Library you are using and since you didn't show us the simplest version of your code which still does not work, we have to guess at the most probable answer. – st2000 Oct 11 at 15:30
  • I have added this information of the first post. I use anyway Nextion Edito 0.58v – bircastri Oct 11 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.