Dimming the display automatically

Does anybody have another idea how to automatically dim the display on inactivity?

In my application, I would like to dim the display when tere is no activity for 1 minute.
My simplest idea: on “whatever” touch event: trigger a 1 minute timer and set light to MAX.
The timer would set the backlight to DIMMED.
Nice. Except that there is no way to detect “whatever” event.

Thence: in every event (that is in every key, every hotspot, every slider,…) I would call the set-timer instructions. I found a way to simulate a subroutine (take a hotspot, hide it behind some other control, attach an event to the hotspot and call “click hotspot” whenever needed). Still, it is a bunch of work to write the call in every control…

So, if anybody has a better idea…
(PS: I absolutely want it to be autonomously done by the Nextion, not by a “dim” instruction sent by the MCU host)

Hi DirkH,

Why don’t you use the thsp/thup for this problem? This commands let the Nextion sleep after a period of no touch and wake up on a touch.
From the manual:

THSP
Sets internal No-touch-then-sleep timer to specified value in seconds
min 3, max 65535, default 0 (max: 18 hours 12 minutes 15 seconds)
Nextion will auto-enter sleep mode if and when this timer expires.

The built-in sleep turns off the display completely, whereas I need a ‘dim’ function…
I think I will revert from my idea that it “must” be done by the Nextion. I must keep in mind that the Nextion is a HMI, not a computer. Thence, the logic should be in te host MCU, not in the Nextion…

I have test this, you can use in each page a timer where “tim” is set to 1000 , in the timer Event you need start counting like this:

va0.val=va0.val+1
if(va0.val>60)
{
dim=20 // or something else
}else
{
dim=100
}

And by “Touch Press Event” from the page you can reset the va0.val from the timer, so it starts counting over again.
(each touch will reset va0.val again and the display go or stay at 100% brightness)

va0.val=0

If you have more pages, then you need to add these Events and timer + variable to each page.

I hope this helps.

2 Likes