ITEAD-Thierry/NextionX

getValue method

Opened this issue · 5 comments

Hi,

I'm interested in migrating my project from the standard library to this one, but I can't understand how to implement the getValue or getText call, to retrieve the data from a slider, a text or any other Nextion object

I assumed I could use the commands:

mySlider.setAttr("val", NULL);
or
versionText.setAttr("txt", NULL);

to invoke data return, but after ? original Nextion library do a loop to read return data

Can You explain me ?

Hi @frdoni,
the reading back of component attributes is not yet implemented in this library. It’s planned to have something like getAttr() methods, but I’m currently still looking on how to best realize these ideally without the MCU being blocked between invoking the method, sending the request to Nextion, and waiting for its return.
This should be done in one or two weeks, combined with a new article in the Nextion Sunday blog.

Hi,

in the past I want to modify standard library to make the getAttr() asyncronous, but I've some C++ problems to resolve before

today's MCU can execute myNex.loop() many times, so You can read a byte for each loop, and put it in a asyncronous list

next loop, if there is (are) some complete answers, instead to read serial, with_nexSer->read(), myNex.loop() can invoke a new method like getAnswers() or similar

I conclude by specifying that I would like to have an asynchronous method implemented

Frdoni

I can promise you that it will be asynchronous! :)

BTW (and just for info): The NextionX .loop() method does not only process one single byte at a time. It consumes and processes everything which is in the serial buffer to avoid overrun. The .loop() exits when the buffer is empty. If a return sequence isn't finished at that moment, it remains in memory until it sees the terminator during one of the next .loop() runs. So, nothing is lost.

Hi @ITEAD-Thierry

is there any update about getValue method ?

I would also like to know, as i am currently deciding if we are going to use the original library (with some modifications) or this one