Closed oldtimerflyer closed 3 years ago
Example code please.
Check Instruction set documentation as well. https://nextion.tech/instruction-set/
example code :+1: async def run(): global client client = Nextion('/dev/ttyAMA0', 9600, event_handler) await client.connect()
#await client.sleep()
#await client.wakeup()
#await client.command('sendxy=0')
#print(await client.get('sleep'))
temp = await client.get('Slider.val')
print ('slider = %d' % temp) #
name = 'Hoogte'
await client.set('t0.txt', "%s" % name)
await client.set('ALT100.val', "%d" % 4) <----------- generates 2020-11-22 15:44:17,556 - DEBUG - received: b'1c'
print('finished')
And why not?
await client.set('ALT100.val', 4)
hmmmmm..... thanks. I have a lot to learn. But i will get there step by step.
Get the same " 1c" error if put it in like this. temp is an int.
await client.set('ALT100.val', (temp / 10))
await client.set('ALT100.val', int(temp / 10))
did the trick.
because temp was actually not an int =)
temp = await client.get('Slider.val')
it should be an int but not sure
put a breakpoint and check =)
When setting values to xx.val objects in Nextion an error " 1C" occurs.
In .set routine in client.py the value is converted to a string format. Could it be that .val objects in Nextion need a number format ?
And how do i change it in the class client.py in my program then?
async def set(self, key, value, timeout=IO_TIMEOUT): if isinstance(value, str): out_value = '"%s"' % value elif isinstance(value, float): logger.warning("Float is not supported. Converting to string") out_value = '"%s"' % str(value) elif isinstance(value, int): out_value = str(value)