Nextion显示串行客户端
nextion的Python项目详细描述
Nextion串行客户端
轻量级Python3.5+异步库来控制Nextion显示。
简单用法:
importasyncioimportloggingimportrandomfromnextionimportNextion,EventTypedefevent_handler(type_,data):iftype_==EventType.STARTUP:print('We have booted up!')logging.info('Event %s data: %s'%type,str(data))asyncdefrun():client=Nextion('/dev/ttyS1',9600,event_handler)awaitclient.connect()# await client.sleep(True)# await client.command('sendxy=0')print(awaitclient.get('sleep'))print(awaitclient.get('field1.txt'))awaitclient.set('field1.txt',"%.1f"%(random.randint(0,1000)/10))awaitclient.set('field2.txt',"%.1f"%(random.randint(0,1000)/10))awaitclient.set('field3.txt',random.randint(0,100))print('finished')if__name__=='__main__':logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',level=logging.DEBUG,handlers=[logging.StreamHandler()])loop=asyncio.get_event_loop()asyncio.ensure_future(run())loop.run_forever()
其他资源:
https://www.itead.cc/wiki/Nextion_Instruction_Set