Is it possible with to do a do loop with the nextion such as
if a button or hotspot pressed
then whilst the button is pressed say
get return value
keep printing F until button/hotspot released
Very unclear question. Sorry.
Nextion does not have a do loop
Nextion doesn't get return values
In defining what you are asking more specifically
- I think you will define the logic needed to do what you ask
Assuming I understand correctly (assuming what is not stated)
the separation of Nextion duties and MCU duties
Then Yes. And perhaps several ways to achieve.
Doing it that way, you can never be sure that the incremented or decremented values are identical on Nextion and MCU.
Variables should be held only once (no redundancy and no sync problems), preferably in the MCU if these will be used there. From that, MCU should update the displayed values.
Thus, the correct approach approach:
- On button press send id to MCU.
- MCU starts intervalTimer object which will on each tick (via callback functions dynamically attached depending on id)
-- first increment or decrement (depending on button) the corresponding value
-- send the new value back to the Nextion
- On button release send id to MCU.
- MCU stops intervalTimer object.
I might take the approach such that
- the HMI device is allowed to process and capture user input,
- until the release has occurred that user input is being captured
- and then once the release has occurred report to the MCU
ON press, Nextion Logic to inc/dec value within range
ON release, send 0x65 notice to the MCU
MCU then uses get command to retrieve user input value.
This approach perhaps saves timer code and serial traffic.
Also, since month is numeric 1 to 12
- there is little reason to use a Text Component and cov commands
- Using a Number Component saves conversions.
One Variable Component to hold step value for inc/dec of -1,0,1
One Number Component for visual of value
One Timer Component that on trigger adds step to Number
Button Press then
sets the step value
starts the timer
Send Component ID
Stops the timer
Sets the step value back to 0
Multiple Buttons doing the same inc/dec logic
- add Variable for component ID to number Value
0x65 Return Code already contains which Button.
If this is indeed for date and time settings
- then reserve all communications for a "Done" button
- MCU then only needs to fetch 2 Variables
Cuts much code, cycles and serial
lol 1000 roads lead to Rome ... as long as one gets there before the Games start
You could use the Nextion keyboard and just let the users type the numbers in
Have a done button on the page when they are finished