Start a new topic

Sleep mode - but data is still working

i'm using this display in combination with ESP8266 devices to manage other devices via MQTT.


i would like to switch the screen off after some inactivity, and reactivate the screen after a touch event.

Currently this is possible, but when there is a new incomming event to update the status of one of the variables, then the value is not updated in the background.


I'm looking for a kind of dim function (dim the screen to 0 after x seconds) and restore the screen to standard dim value after a touch event, so that the device is still updating the variables (although the screen is black at the same time)


1 person likes this idea

There are already many ways to accomplish this


Using the dim function, you screen can be dimmed to 0 at any time you see fit.

Inside your hmi touch events you can set dim to whichever level of brightness you wanted.


this can be controlled via your HMI or via an MCU


Please refer to the Nextion Instruction Set - System Variables List section


Ok, thx for the feedback!


I know the dim function and how you can use ths function to change the brightness of the screen based on an event, but i cannot find a solution to dim the screen automatically after 'x' seconds after te last event (like sleep does).

I cannot find a timer function (there is a delay function, but then the processor stops too)


I can use my controller to modify the brightness using the dim function, but my controller is not aware of of all touch events (the controller act as a mqtt client - interface towards the nextion display)


Actually re-reading your request.

As of the v0.39 editor, data via serial is now processed while in sleep mode. 

It may not be being refreshed to the screen while sleeping, but up wake on touch should bring that back up to date.

The Nextion also contains print and printh functions

The Nextion Editor contains a timer component


The complexities you are trying to create as part your project would require you to implement the various mechanisms to track when a user has last used the Nextion Device.  ie: in every button or event, reset a local value that state user is still using the nextion device, or send that event to the mcu.

If the time since last function is greater than last event + time_until_dim -> dim the screen


Try and answer these to questions

is the Nextion model Basic or Enhanced

and how much time is given before your last use and dim.

I'll do some thinking

i'ts a basic Nextion model that i 'm using for the moment, the idea was to dim the screen after 30 seconds.


I'm using editor version 0.4, so if the serial data is still processed (or buffered) then it should be ok 

(i've just started a quick check, it was not working, but i have to analyse the serial communication to be sure if there was no other problem)


I've tried to use the sleep function,  and i've added a command to request the mcu to get & update the status of all items in the preinitialize/postinitialize or touch press event actions for the page.

It works when you enter the screens, but not on wake up after sleep (the actions are not executed after wake up)


I'll try some additional tests & setups.

(For the moment i've added a kind of 'refresh status' button on every page, and this action requests the MCU to fetch the actual status of the devices to update the status on the Nextion screen.)


Thanks again for the support & thinking!

Please see this thread

Does anyone else have a problem with "thsp=0"


Jan has a few workarounds implemented that seem similar to your goal.


ok, i found a solution!


now i'm using the normal sleep function on the nextion, When you touch the device in sleep mode, then the device is sending a sleep touch event (x-y coordinates, message starts with an 0x68 character)

Now i'm using this message @ mcu side to trigger an mqtt message that will request the status of the devices and to update the screen.


So now the screen has always up to data data!


1: When the screen is awake, it receives data from different sensors & devices so the status on the screen is always correct (status of devices / sensors can change triggered by another screen, an app or a local switch action)


2: When you switch to another screen, an event is triggered to request a status update for the elements --> nextion will update the status of the elements on the display


3: when de device is in sleep mode, no data is received / processed, but on wake up the device will send a 'touch event in sleep mode' and that will trigger the ESP to request the sensors & devices to update their status.


Steven.

I am now reviewing all of the Feature Requests, this will take some time, patience please.

Although this wasn't a real feature request, it is now marked as reviewed.


I am Glad you found a solution.

Hallo Patrick,

any progress with this problem?

I've tested it a few times. There's no problem with other components:

Serial data isn't processed by the display while in sleep mode. Since there no update my whole
setup is worth nothing (not everyone uses mqtt). So all my display aren't showing acutal data if
they are in sleep mode while data is coming in (esp82669).

I'm using Nextion Editor v.043.

By the way: Is there a detailed explanation (and the difference between) of "Preinitialize Event" and "Postinitialize Events" and when the command will be executed. Why does "ref 0" not refresh the
background color of a button assigned by a variable on another page (everything "global")?

 

Greetings, hmitec99

Sorry hmitec99, but progress?

This is a user domain coding issue, nothing I can make progress with.


Serial data is processed by the display while in sleep mode

- how could Nextion receive sleep=0 to come out of sleep if this were no so.

- That is to say that the user has configured their sleep correctly


Your statement is confusing,

  if display is sleeping, display is off, what is there to display?

  MCU is not OFF when sleeping, but limited - hence sleep.


Plenty of explanations have been made on pre and post - I posted these many time.

When changing pages, Nextion dumps from memory old page to load new page.

- Pre happens just before new page is loaded,

- Page is loaded as per the HMI design - static as was designed in the HMI file.

- Post happens just after page is loaded.

- Nextion loops waiting for event (serial, touch, gpio, timers)


Every page in you HMI design has a page component (id of is 0 - always)

- therefore ref 0, updates component with id of 0 - the page component

So why the background color doesn't change is:

   you would be missing some logic "glue" somewhere.


 Hallo Patrick,


thanks for your reply.


My problem is descibed by other users too.


>>

I've tried to use the sleep function,  and i've added a command to request the mcu to get & update the status of all items in the preinitialize/postinitialize or touch press event actions for the page.

It works when you enter the screens, but not on wake up after sleep (the changes are not visible after wake up)

<<


The display does not update the items on the current screen when it wakes up! So if any component is

updated in sleep (or a variable which it depends on) it doesn't show the change till I reenter the page.


What is the difference between "page 0" and "ref 0"? Can you describe the process of both commands?


So I think the logic glue is right there.

>>

My problem is descibed by other users too.

<<

... as are many such coding issues described by many


I never said every component was updated during sleep.

I contradicted your logic assumption serial was off during sleep.

If that was the logic glue, we wouldn't be having this conversation.


Programming logic is super simple. 

- The MCU/CPU will follow their machine coded instructions exactly.

- If the result is not as desired, the instructions were not correct to achieve such.

- debug tools and statements allow temporary insertions, can be removed later.


ref 0 is described above, a redraw of the component.

- historically there was a black, gray, green and bold green colored attributes.

- bold green attributes would also auto refresh the components.

- now all components auto refresh when any green attribute is changed (~ v0.38)

- bold green is obsoleted - redundantly refreshes - twice as many cycles used.


page 0 is the command to change to 0th indexed page with page number 0 left of the pagename in Nextion Editor's Page Pane. Definitive execution of Pre, HMI, Post.


But I fail to see what purpose sleep is if you expect all processing to occur during sleep.

I rarely perform work functions during my sleep cycle. Likewise the MCU is limited during sleep.

In general terms sleep is used to reduce power, not continue processing. (Think Rosetta)

Is there a way to make a refresh when i wake up the display by touch without changing page or complete refresh? I think there have to be changes in the logic of the display to achive this? What do you mean?

 

The users coding logic has to change.

Logic of the displays is to provide the functionality not implement user use case.

Login or Signup to post a comment