https://github.com/michel-cf/micropytho ... nextion.py
Sending commands to the Nextion also works great.
But what I can't do at all is the callback method.
Code: Select all
My code:
import machine
import utime
import nextion
n = nextion.Nextion(1)
def nextion_callback(command, page, id, touch_event):
print('command: %s page: %s id: %s, touch_event: %s' % (command, page, id, touch_event))
x1= ('command: %s' % (command))
print(x1)
while True:
utime.sleep(1)
print("Läuft noch")
n.check_data(nextion_callback)
65010401FFFFFF
Code: Select all
#Code in the lib:
def check_data (self, callback):
if self.any ():
chars = self.readinto (self.read_buffer, 100)
index = 0
if self.any (): stand.
Only when I often send commands will I continue to work from time to time.
When I query the content of chars, this is the result:
bytearray(b'e\x01\x04\x01\xff\xff\xffe\x01\x04\x01\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
The correct result is output on my console:
command: 101 page: 1 id: 4, touch_event: 1
From time to time it continues.
but often it depends again on if self.any ():
I'm still a very inexperienced Phyhton newbie, maybe someone can help me.
Maybe also with an improved code: