i set thsp=300 to switch off the display after 300sec on my arduino
but how to switch off this function thsp ?
i have a slider on my config page where i can change the time this work fine.
2-my arduino update a lot of values and text on the display ,but when this part of updating is running i can`t receive touche events
how can i solve this probleme i need to update data and i need to know when a bp is pressed at same time?
this is for an house automation
i use :
arduino mega with 7" display to show stats (i get this stats from mysql server)
arduino mega with 16 relays card, 6 analoge inputs , 4 digital inputs and 12 pwm outs (send stats to mysql server)
i hope you can help me with this 2 problems
@ attachment i put 2 arduino sketch and the php file to send and catch data
the missing hmi file
1- i set thsp=300 to switch off the display after 300sec on my arduino but how to switch off this function thsp ? i have a slider on my config page where i can change the time this work fine.
The Nextion Instruction Set includes the thsp System Variable.
But reading its description states in the Nextion Instruction Set:
If no touch operation, it will auto enter into sleep time (unit: second, minimum 3, maximum 65,535, power-on default 0), thsp=30(No touch operation within 30 seconds, it will auto enter into sleep mode), thsp=0(invalid).
So it would seem clear, that only reset (rest command) will return thsp to 0.
This is a design decision to either use or not use - but not both.
Still it is the users decision.
At 300 seconds or 5 minutes, I think it is clear the user has indeed completed their tasks by the time the Nextion device enters sleep mode. That is 300 seconds without any touches, then sleep. In 300 seconds, I have finished my coffee, left for work and am more than 1/2 way to my office. (Okay so I work in a home office - but that's not the point). In a real world situation, sleep in 300 seconds is more than enough - and saves well on the power bill.
2-my arduino update a lot of values and text on the display ,but when this part of updating is running i can`t receive touche events how can i solve this probleme i need to update data and i need to know when a bp is pressed at same time?
The Nextion is classed as a TTL device, not bidirectional full duplex.
Your sketches dealing with the Nextion device need to:
1) prioritize receive before send.
2) and question why you need to update so much data in single shot.
There are a couple of approaches that can be taken
Implement a Nextion user must wait state.
Disable touch while the update is in progress
Inform the user on the screen that the update is occurring
Inform user can not make changes until update is complete
.. perform updates
Remove user wait state once update is complete
Restore touch when update is completed
Decrease the time needed per update
At 9600 baud, this is 960 chars of data per second.
At 115200 baud this is 11520 chars of data per second
The easiest of these is increasing baud where it can be done
- this reduces the time needed to receive the update data
The one with a bit more effort is to shadow the data and
only update the data that has been changed.
An example is a date and time
- most often it is only the seconds that has changed
- yet too many users push the whole date and time every time.
When you design to fetch pages from the Internet
- expect delays - your Arduino is sequential processing.
But, I am certainly not debugging 1000+ lines of incomplete code.
- for the future, please limit your picture sizes to something reasonable
I may have 5760 x 1920 for my display
but few people are going to bother to look when your post is too large
and done in a dump and fix it for me fashion
Example using your code as a base for the example
THX for help
Think in smaller quick acting chunk that process rapidly from the start
- you will avoid many more issues down the road.
I have a more basic question. I want the display to goto sleep and dim way down after no touch activity. So if I understand this I use thsp=30 and the display goes to sleep in 30 seconds.
Where do I put that command ?
Does the screen automatically dim when the thsp is active?
I am not as concerned about the sleep mode I just want the display to dim way back and then by touching the screen it with brighten up again.
I looked at the dim command but I don't see anything there that allows me to automatically dim after a preset time. So maybe by using sleep it will do they dimming?
First it does not matter where the command is placed
- it could be put in page0 Preinitialization Event
- it could be sent over serial
- it could be put in a button release
Once thsp is set to non-zero value it cannot be reset to 0 unless Nextion is reset
In essence think of the thsp as a countdown timer (say we set to 30)
- every second where there is no touch, decreases a second
- every touch that happens, resets this back up to 30.
There is no dim in sleep. The display is then off.
A touch will bring it back to the dim level it was before sleep.
The dim command will not do anything after an amount of time
- the dim command sets the level immediately on processing it.
There is no harm is testing thsp.
Once you reset your Nextion, thsp will be back to power on default of 0