-
Notifications
You must be signed in to change notification settings - Fork 34
button callback not working #32
Comments
Have you enabled the button press/release events in the Nextion Editor? |
I have enabled the release event since I only need that; do both events need to be enabled? I am using the latest nextion editor; |
That should be enough. Not too sure of the issue then, I haven't used these displays for a while now and have no hardware to test with. |
yeah, really strange; I checked the official library and it seems
cumbersome to use but not sure where to head now;
…On Wed, Aug 16, 2017 at 4:42 PM, Dan Nixon ***@***.***> wrote:
That should be enough.
Not too sure of the issue then, I haven't used these displays for a while
now and have no hardware to test with.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWd8IePH4xHGZ0oC5H8I-SJ8eIeqmmTwks5sYs6ZgaJpZM4O4BEB>
.
|
I'm using this library since a while, no issues in button callback (or other components) |
I figured the issue; it does work with simple examples but it does not work with examples where I read or write values from other components in the loop() method after nex.poll(); Not sure how to fix this issue; I need to be able to set values to some components in loop method and also be able to handle button click callbacks; Please share your insights; |
I experienced is not a good method to update components in loop: the serial will be always (or almost) committed to send data (anche check return values). |
but even in that case it would definitely conflict right??? Also in my
case, data is from sensors so I have to either update it in loop or timer
anyway and in arduino, loop is like running a timer itself;
…On Sat, Sep 9, 2017 at 6:23 PM, Vittorio ***@***.***> wrote:
I experienced is not a good method to update components in loop: the
serial will be always (or almost) committed to send data (anche check
return values).
In my projects, components update is always done either after a touch
event or on a timer basis (using millis or TimeAlarm library).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWd8IfvolnvQVInV6kqOq6zzxqCw8CA6ks5sgopBgaJpZM4O4BEB>
.
|
Yes, loop is like a timer but, even with get sensor data and other operations, it's too fast. In one of my project I've a timer on screen and, of course, it's updated every second (using TimeAlarms library, but will be the same using millis() ). The serial is set to 38400 (software serial, cannot be faster), and the touch buttons (stop, pause, restart) are working perfectly without any conflict. |
Another tip, I don't know if it's your case, is to update components only on the page currently displayed (even with components set as global). |
loop is definitely fast if we dont put a delay but it can be used like a
timer with delays; I already have 2-3 second delays;
Also, None of the things you mentioned above are issues I am facing and I
am already following those practices; I have even tried updating only one
visible text field and the callbacks wont work even with setting or getting
one value after a poll; This must be something to do with how its handled
in the library for sure;
…On Sat, Sep 9, 2017 at 6:57 PM, Vittorio ***@***.***> wrote:
Another tip, I don't know if it's your case, is to update components only
on the page currently displayed (even with components set as global).
I've a variabile that tracks the current page (page switch is managed by
Arduino) so if, for example, I'm on the page 2 it's not necessary to update
date/time and sensor data on page 0. When I'll go back on page 0, the
callback attached will call the function to update the display.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFCFefVyJGCs0G-uWukQuus7P7ruIAgfks5sgpJJgaJpZM4O4BEB>
.
|
The most probable issue that can cause what you're experiencing is wrong ID component in variable declarations. Where sr is the serial attached to Nextion. |
Buddy, I told you it is working fine if I dont write values to the display
components or read values from them; I have fair amount of experience with
this library and nextion display to understand and make sure the
correctness of component ids, component names and page ids;
Please dont give speculative answers without really reading what I wrote; I
clearly wrote it works if I am not getting or setting a component value in
loop;
I will wait for the library author's response; You are welcome to provide a
reasoning if any but please try out my scenario first; You can start with
the Button example, just add one more number field on the screen and set
or get its value in the loop and you will clearly see that the callback
does not get fired no matter whatever delay you put in loop;
…On Sat, Sep 9, 2017 at 8:30 PM, Vittorio ***@***.***> wrote:
The most probable issue that can cause what you're experiencing is wrong
ID component in variable declarations.
But are you sure the display is communicating with Arduino?
A simple code to show what Nextion is sending
while(sr.available()) { Serial.print((uint8_t)sr.read()); }
Where sr is the serial attached to Nextion.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWd8IVcJQN-ZbdV-9Jmb8x9JujKx7cGhks5sgqf5gaJpZM4O4BEB>
.
|
Any insights Dan? |
I did: 3 buttons, 3 number field and 2 text field. Here's the video: https://youtu.be/ozAMaVkeW9c And here's the code:
|
@rangathedon You are probably expecting things to happen much faster than what they can. Nextion displays are really slow. There are not many reasons to be updating values periodically let alone in the main program loop, save this for when the values actually change (or at least change a sufficient amount to be relevant to the user). Even if you do your updating periodically I'd guess you have a cluster of update calls which is probably leading to the display not reading the full payloads of subsequent messages. Without looking at your code it is difficult to tell and the best I can offer is speculation. If you really need a value to be updated at less than 1 second intervals then Nextion displays are not the solution. |
@DanNixon you're right. That's the same I wrote (loop too fast); I modified my code above: it works even with a 100ms interval, below that value it's unresponsive. But @rangathedon wrote he has 2-3 seconds delays (I hope not delay(2000) ) so my thoughts is an error in his code, since no one else has reported this "issue". |
I had a similar problem and in my case it was because I did a Moving the code from the Press event to the Release event in the editor solved it for me. |
I have followed the example but button callbacks dont seem to work; Any idea? does anything special need to be done on the nextion editor to the HMI file to get callbacks working? This is both on arduino nano and mega;
The text was updated successfully, but these errors were encountered: