I have a Nextion 7" 'Intelligent" Touch screen see:
https://itead.cc/product/7-0-nextion-in ... enclosure/
It features a HMI (Human Machine Interface) which basically means it comes with it's own Visual Designer.
You design your canvas (pages), then you send your program (flash) to your screen.
The screen then responds to the messages sent/received.
From their web pages: Nextion HMI display connects to peripheral MCU via TTL Serial (5V, TX, RX ,GND) to provide event notifications that peripheral MCU can act on, the peripheral MCU can easily update progress and status back to Nextion display utilizing simple ASCII text based instructions.
I realize they'd like to dump the info into a microchip, such as Raspberry Pi, but I'd like to do this directly.
Using:
Code: Select all
Define Ok.i, Timeout.i
Define Byte.b
If OpenSerialPort(1, "COM4", 115200, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 1024)
Ok = #False
Timeout = 500
Repeat
If AvailableSerialPortInput(1)
If ReadSerialPortData(1, @Byte, 1) = 1
Debug RSet(Hex(PeekB(@Byte), #PB_Byte), 2, "0")
EndIf
Else
Delay(10)
Timeout - 1
EndIf
Until Timeout = 0 Or Ok
EndIf
I created a screen with a button that sends the number '105' to the serial port.
This is what is returned from the serial port: 1E 86 7E 1E 86 98 66 66 1E 66 18 98 E6 98 F8
But from the Visual Designer, I get:
HexValue: 43 3A 43 4E 55 4D 31 30 35 3F
String Value: C:CNUM105?
And the 7" Display Simulator returns:
HexValue: 43 3A 43 4E 55 4D 31 30 35 3F
String Value: C:CNUM105?
The results from both are the same:
C:C = Unique ID
NUM = says that a number is being sent
105 = the value sent
? = Stop character
So I need to find a way to corelate the output to something that makes sense to me. haha
I'd prefer the output send a string, to that i can see if it is correct.
Any ideas from you serial port experts?
Thanks in advance