Help
Help
Note:
1. The device receives the command end character of "0XFF 0XFF 0XFF" three bytes (HEX data, not string data).
2. All command names and parameters use ASCII string data, not HEX data, for easy reading and debugging.
3 . All command names use lowercase letters (here only refers to the command names are lowercase, parameters should still be uppercase when they should be uppercase).
Summary table of object and system operation instructions (clicking the instruction name or parameter will automatically jump to the detailed explanation of the instruction)
6 printh Print a Hex value from the serial port printh hex
sequence
29 wept Transmitted data is written into the user storage area wept add,length
30 rept Transmit data from the user storage area to the serial port rept add,lenth
move
37 move Control movement (supported only by X3 and X5 series)
obj,starx,stary,endx,endy,first,time
39 twfile Serial port transparent transmission file (only supported by X3 and X5 series) twfile filepath,filesize
42 findfile Search for files (supported only by X3 and X5 series) findfile filepath, that
43 rdfile Transparent reading of files (supported only by X3 and X5 series) rdfile filepath,addr,size,crc
48 finddir Search folder (only supported by X3 and X5 series) you find that
Machine Translated by Google
GUI drawing command summary table (click the command name or parameter to automatically jump to the
Note: GUI drawing instructions are mainly used in the following situations:
When the upper interface editing software cannot meet your special display requirements, use GUI instructions to draw your own pictures to achieve what you want.
Display effect
In most cases, it is not necessary to use these drawing commands. Most applications can be operated through the controls of the interface editing software.
to achieve it.
sequence instruction
Instruction function parameters
Number name
xstr
5 xstr write command
x,y,w,h,fontid,pointcolor,backcolor,xcenter,ycenter,sta,string
Area filling
6 fill fill x,y,w,h,color
make
page request
pageid: page ID or page name
Example 1: page 0 (refresh page with ID 0)
Example 2: page main (refresh the page named main)
Remark:
2. You can also assign a value to the system variable dp to jump to the page (such as dp=0). The system variable dp can be set and read. For details, please refer to the system
A list of variables.
3. The page instruction is a jump instruction. The code written after the page instruction will be ignored and will not be executed.
Machine Translated by Google
ref obj
Remark:
If a control is obscured by content drawn by GUI instructions or needs to be displayed again after being obscured by other controls, use ref to redraw it.
click b0, 1 (activate the press event of the control named b0)
Remark:
The press/pop-up event of the control is automatically activated when the screen is touched. If you want to activate it manually without touching it, just use the click command.
variable name
string "123") Example 4: get 123 (returns the constant value: "123")
Remark:
1. When the variable obtained by using the get command is of string type, the returned data is 0X70+string internal code+terminator. If it is of numerical type (such as the val
attribute of the progress bar), the device returns 0X71+4-byte hexadecimal data of the variable (int type)+terminator. The storage mode of the numerical value is little-endian
mode (that is, the low bit is in front and the high bit is in the back).
2. The get command can be sent via the serial port, or it can be written into the user code in the upper software editing interface to implement active screen sending of variables
(when actively sending, you can use the printh command to add a custom mark in front to tell the microcontroller which control this variable belongs to).
3. The get command is very similar to the print command, the only difference is that the data returned by get has a start identifier (0x70 or 0x71) and an end identifier (0xff
0xff 0xff), while print does not. 4. For the specific data return format, please refer to the "Serial Port HMI Device Return Data Format" at the end of this table.
Machine Translated by Google
length) Example 1: prints t0.txt,0 (Send the txt attribute value of control t0, the
length is the actual length) Example 2: prints j0.val,0 (Send the val attribute value of control j0, the default length is 4-
byte integer data, stored in little-endian mode) Example 3: prints "123",0 (Send the
constant string "123", i.e.: 0x31 0x32 0x33) Example 4: prints 123,0 (Send constant value:
123, i.e.: 0x7b 0x00 0x00 0x00) Example 5: prints 123,1 (Send constant value: the lower 1 bit of 123, i.e.: 0x7b)
Remark:
1. When the variable sent using prints is of string type, the device directly returns the string code. If it is of numeric type (such as the val attribute of the progress bar), the device
directly returns the 4-byte integer data of the variable (Hex data, stored in little-endian mode, that is, the low bit is first).
2. When using the prints command to obtain data, the device only sends the data content, without a start identifier or an end identifier.
3. The prints command can be used in conjunction with the printh command to add a custom mark in front to tell the microcontroller which control the variable belongs to).
4. The prints command is very similar to the get command, the difference is that the data sent by get has a start identifier (0x70 or 0x71) and an end identifier (0xff 0xff 0xff), while
prints does not. However, prints can continue to use the printh statement to add any custom identifiers.
printh hex
hex: hexadecimal string expression of the character to
be sent Example: printh d0 a0 (let the device send two bytes 0xd0 0xa0)
Remark:
1. When using the printh command to send data, the device only sends the specified characters, and does not send the start character, space, or end character.
2. Each group of characters in the parameter must be separated by one and only one space. Both uppercase and lowercase hexadecimal string expressions are supported.
3.printh can only send constants, not variables. Variables need to use the prints command.
Remark:
The first parameter is 255, which means all controls on the current page. For example: vis 255,0 (hide all controls on the current page) vis 255,1 (show all controls on the current
page).
Machine Translated by Google
state (0 or 1) Example 1:
tsw b0,0 (disable the touch of the control named b0) Example 2: tsw
b0,1 (enable the touch of the control named b0) Example 3: tsw 1,0
Remark:
The first parameter is 255, which means all controls on the current page. For example, tsw 255,0 (touch screen of all controls on the current page is disabled) tsw 255,1 (touch screen of all controls on
maximum value
Example: ranset 1,100 (set the current random number generation range to a minimum of 1 and a maximum of 100)
Remark:
1. Before using random numbers, you need to use the randset command to set the random number generation range. If not set, the default is 0 for the minimum and 2147483647 for the maximum.
After setting the range, each time the system variable rand is read, a random number will be obtained.
2. Each time you set a range using the randset command, it will remain valid until the power is turned on again or the device is reset, at which point the default value will be restored.
3. The data type of the random number setting range is int type (i.e. minimum -2147483648, maximum 2147483647).
curve control ID number (must be the ID number here, the control name is not supported) ch: curve
1: add 1,0,30 (add data 30 to channel 0 of the curve control with ID 1) Example 2: add 1,1,n0.val
Remark:
1. The curve data only supports 8-bit data, with a minimum of 0 and a maximum of 255.
2. Each page supports up to 4 curve controls, and each curve control supports up to 4 channels. Data can be sent continuously, and the control will automatically push and display the data. During the
data sending process, the control properties can also be modified at any time, such as modifying the foreground color or background color of each channel at any time.
Machine Translated by Google
curve control ID number (must be the ID number here, the control name is not supported)
channels) Example 1: cle 1,0 (clear the 0 channel data of the curve
control with ID 1) Example 2: cle 1,255 (clear all channel data of the curve control with ID 1)
Remark:
1. When the channel number is 255, it means clearing all channel data in this curve control.
control ID number (must be the ID number here, the control name is not supported) ch: the channel number in the
Example: addt 1,0,100 (the curve control with ID 1 enters the data transparent transmission mode, and the number of transparent transmission points is 100)
Remark:
1. Curve data only supports 8-bit data, with a minimum of 0 and a maximum of 255. The maximum amount of data transmitted in a single pass is 1024 bytes
2. After sending the transparent transmission command, the user needs to wait for the device to respond before starting transparent transmission of data. After the device receives the transparent transmission
command, it takes about 5ms to prepare the transparent transmission initialization data (if there are many other commands in the serial port buffer before the transparent transmission command is executed, the
time will be longer). After the device is ready for transparent transmission initialization, it will send a transparent transmission ready data to the user (0XFE+terminator), indicating that the device is ready and
can start sending transparent transmission data at this time. The transparent transmission data is pure hexadecimal data, no longer using strings, and no longer requiring terminators. The device will resume
the command receiving state only after receiving the specified amount of data. Otherwise, it will always be in the data transparent transmission state. After the transparent transmission of data is completed,
3. The curve will not refresh before the specified transparent transmission quantity is transmitted. It will refresh automatically immediately after the transparent transmission is completed.
doevents
Remark:
1. In the execution of a process with more instructions, or in a long loop statement, all control rights of the system are occupied by this process. Before the end of the process, although the corresponding
memory data can be read and written normally, the screen will not refresh. After adding doevents, the control right can be transferred to the screen refresh. After executing doevents, the screen will refresh all
the changed controls. After the refresh is completed, the control right is returned to the current process to continue execution. Prevent the screen from showing a false dead display state.
2. In most cases, doevents is used in conjunction with while or for statements. For usage, please refer to the examples of while or for statements.
Machine Translated by Google
sendme
Remark:
When the device receives this command, it will immediately send the ID of the current page to the serial port. If you want to automatically send the page ID every time you refresh the page,
please write a sendme statement in the initialization event of the page. For the sending format, please refer to the "Serial Port HMI Device Return Data Format" table behind this table.
variable att2:
length of the string (0 is automatic length, non-0 is fixed length) format: declare
h0.val,t0.txt,0,0 (convert the val value variable of the slider h0 into a decimal string and assign it to the txt variable of the text t0, the length is automatic) Example 2: covx
t0.txt,h0.val,0,0 (convert the txt decimal string variable of the text t0 into a numeric value and assign it to the val value variable of the slider h0, the length is automatic)
Remark:
1. lenth always indicates the length of the string. When converting a number to a string, it is the length of the target variable. When converting a string to a number, it is the length of the source
variable.
2. If the target variable and source variable are of the same type, the conversion fails.
Remark:
1. strlen tests the length in characters, while btlen tests the length in bytes. For example, the length of a Chinese character tested by btlen is 2 bytes, while the length tested by strlen is 1
character.
2. The variable being tested must be of string type, and the variable being written must be of numeric type, otherwise an error will be reported.
t0.txt,n0.val (assign the actual byte length of string variable t0.txt to n0.val)
Machine Translated by Google
Remark:
1.btlen tests the length in bytes, while strlen tests the length in characters. For example, the length of a Chinese character tested by btlen is 2 bytes, while the length tested by strlen is 1
character.
2. The variable being tested must be of string type, and the variable being written must be of numeric type, otherwise an error will be reported.
character in the source variable lenth: the length of the intercepted string
Example: substr t0.txt,t1.txt,0,2 (tick 2 characters from position 0 in t0.txt and assign them to t1.txt)
the src string with the key string, take the index-th part and assign it to the dec variable) Example: The d character content of data0.txt is: aaaa^bbbb^cccc^dddd
Execute command: spstr data0.txt,t0.txt,"^",2 Running result: The content of t0.txt is: cccc
touch_j
Example 1: touch_j (enter the touch calibration function, this command does not require parameters)
Remark:
All devices have been calibrated before leaving the factory, so this function is usually not necessary.
ref_stop
Remark:
1. After pausing screen refresh, all statements will continue to be parsed and executed, and the corresponding attribute assignment operations will also run normally, but the controls on
the screen will not be refreshed, and modifying any attribute of any control will not automatically refresh the display (but the attribute has been modified normally). Until the device receives
the resume refresh instruction (ref_star), the modified control will be refreshed immediately.
Machine Translated by Google
2. After pausing the refresh, even if the ref command is used, the refresh will not be immediate until the ref_star command is executed. However, all gui drawing commands (such as
drawing points, lines, circles, etc.) are not affected and will be displayed immediately.
touch_j
Example 1: touch_j (enter the touch calibration function, this command does not require parameters)
Remark:
com_stop
Remark:
1. After pausing the serial port command execution, the device will continue to receive commands, but will not execute them. All commands will be placed in the command buffer until
the "com_star" command is received. The device will then execute all commands from the command at the time of the pause to the current one.
2. When using the command pause and resume function, please evaluate whether the serial port buffer size and the maximum number of command buffer queues of your device are
sufficient to support the number of commands you need to cache. These two parameters can be found in the parameter table in the specification of the device you purchased.
com_star
Remark:
1. After receiving this instruction, the device will execute all instructions from the instruction when it was paused to the current one.
2. When using the command pause and resume function, please evaluate whether the serial port buffer size and the maximum number of command buffer queues of your device are
sufficient to support the number of commands you need to cache. These two parameters can be found in the parameter table in the specification of the device you purchased.
25.code_c Clear all unexecuted commands in the serial port command buffer
code_c
Immediately clear all the unexecuted commands in the serial port command buffer.
Machine Translated by Google
26.rest Reset
rest
variable/constant
0) Example 1: wepo t0.txt,10 (write the content of t0.txt to the 10th position of the user storage area, and the space occupied in the storage area is the maximum
setting value of t0.txt + 1, that is, the size represented by the txt-
maxl attribute of t0 + 1) Example 2: wepo "abcd",10 (write the string "abcd" to the 10th position of the user storage area, and the size occupied in the storage area
is 5 bytes) Example 3: wepo 125,10 (write the value 125 to the 10th position of the user storage area, and the size occupied in the storage area is 4 bytes)
Remark:
1. When the content written is a variable string, the space occupied in the storage area is the maximum number of characters of the variable + 1; when the content written is a constant string, the
space occupied in the storage area is the actual number of characters of the constant string + 1.
2. When the written content is a variable value or a constant value, the space occupied in the storage area is uniformly 4 bytes.
3. When using the user storage area for read and write operations, please remember to plan the data area location to avoid data overwriting errors caused by interlaced locations.
28.repo Read data from the user storage area (EEPRO) into a variable
Example 1: repo t0.txt,10 (read data from position 10 of the user storage area to the t0.txt variable. The amount of data read in the storage area is the maximum setting
value of t0.txt + 1, that is, the size indicated by the txt-maxl attribute
of t0 + 1) Example 2.repo n0.val,10 (read data from position 10 of the user storage area to n0.val. The amount of data read in the storage area is 4 bytes)
Remark:
1. When the content read is a variable string, the amount of data read in the storage area is the maximum number of characters of this variable + 1.
2. When the content read is a variable value, the amount of data read in the storage area is uniformly 4 bytes.
3. When using the user storage area for read and write operations, please remember to plan the data area location to avoid data overwriting errors caused by interlaced locations.
transparent transmission
length Example: wept 10,30 (transmit 30 bytes of data to the 10th position of EEPROM, occupying space 10-39)
Remark:
1. After sending the transparent transmission command, the user needs to wait for the device to respond before starting transparent transmission of data. After the device receives the transparent transmission
command, it takes about 5ms to prepare the transparent transmission initialization data (if there are many other commands in the serial port buffer before the transparent transmission command is executed, the
time will be longer). After the device is ready for transparent transmission initialization, it will send a transparent transmission ready data to the user (0XFE+terminator), indicating that the device is ready and
can start sending transparent transmission data at this time. The transparent transmission data is pure hexadecimal data, no longer using strings, and no longer requiring terminators. The device will resume
the command receiving state only after receiving the specified amount of data. Otherwise, it will always be in the data transparent transmission state. After the transparent transmission of data is completed,
30.rept Read data from the user storage area and transparently transmit it to the serial port
transmitted Example: rept 10, 30 (read 30 bytes from position 10 of the user storage area and transparently transmit to the serial port)
Remark:
Regardless of whether the data in the storage area is a string or a value, the device reads and sends the specified number of bytes to the serial port in hexadecimal, and does not send a terminator.
number of extended IO
state: configuration mode (0-pull-up input mode, 1-control event binding input mode, 2-push-pull output mode, 3-PWM output mode, 4-open-drain mode) obj: bound
control name or ID (this parameter is only valid when configured as control event binding input mode, and invalid in other modes) Example
1: cfgpio 0,0,0 (Configure io0 as pull-up input. After configuring this mode, the system variable pio0 can be used to read the current input level at any time, such as:
1,2,0 (Configure io1 as push-pull output. After configuring this mode, the system variable pio1 can be used to control the current output level at any time, such as: pio1=1)
(Configure io2 as the control event binding input, and the binding control is b0. After configuration in this mode, when io2 generates a falling edge, it will trigger the press
event of the b0 control, and when it generates a rising edge, it will trigger the pop-up event of the b0 control)
Example 4: cfgpio 4,3,0 (Configure io4 as PWM output mode. Before configuration, you need to set the duty cycle, that is, pwm4 in the system variable)
Remark:
1.Only io4-io7 of K0 series supports PWM output, and only io6-io7 of X5 series supports PWM output. Other IOs do not support it. Configuring other IOs to PWM mode will result in an error.
Machine Translated by Google
2. When using the control event binding input mode, the controls on the current page at the current configuration moment can be bound. Controls on other pages cannot be bound
(even controls that occupy global memory). After binding the controls on the current page, when you refresh the page or switch to another page, the binding event will no longer
be triggered. Therefore, you need to re-bind each time you refresh the page. It is recommended that the binding code be written in the pre-initialization event of the page.
crc check type (must be 1, Modbus crc16 check method) initval: initial
value (usually 0xffff) Example 1:
crcrest 1,0xffff (reset CRC initial value to 0xffff for subsequent data verification)
Remark:
1. After resetting, you can use crcputs or crcputh or crcputu to verify the specified data. After the verification, read the system variable crcval to obtain the verification result.
2. For the complete CRC check example code, please refer to: Using CRC check data in the program
Remark:
1. Use crcputs or crcputh or crcputu to verify the specified data. After the verification is completed, read the system variable crcval to obtain the verification result.
2. For the complete CRC check example code, please refer to: Using CRC check data in the program
crcputh Hex
Hex: hexadecimal string expression of the data to be verified (each byte is separated by a
Remark:
1. Use crcputs or crcputh or crcputu to verify the specified data. After the verification is completed, read the system variable crcval to obtain the verification result.
2. For the complete CRC check example code, please refer to: Using CRC check data in the program
Machine Translated by Google
35.crcputu crc checks a section of serial port buffer data (valid when recmod=1)
data to be verified Example 1: crcputu 0,22 (verify the first 22 bytes of the serial port buffer, valid when recmod=1)
Remark:
1. Use crcputs or crcputh or crcputu to verify the specified data. After the verification is completed, read the system variable crcval to obtain the verification result.
2. For the complete CRC check example code, please refer to: Using CRC check data in the program
changed obj1: control ID or control name (place obj0 control above this control, this parameter 0 means to place obj0 control below all controls,
or control ID starx:starting
coordinate X
stary:starting
coordinate Y
endx:ending
coordinate X endy:ending coordinate Y first:priority
the higher the priority) time:moving time (in ms) Example:move t0,0,0,200,200,0,300 (control t0 moves from (0,0) to (200,200), priority is 0, time is 300ms)
Remark:
You can write multiple move instructions of different priorities at the same time, and the system will move in order of priority. The one with the highest priority will move first, and after the move is completed, the
audio ID loop:
whether to loop Example: play 1,3,0 (play the audio file with ID 3 on audio channel 1, not looping)
Remark:
1.The play command is only used to configure and start audio playback. To pause and stop, please use the system variables audio0 and audio1.
2. The play command controls an audio channel that is independent of the video. It has nothing to do with the audio channel used in the video and will not cause any conflict.
3. The audio playback function is global and does not belong to a specific page. Therefore, after the play command starts the playback, the audio will continue to play even if the page is jumped. If you want to
stop playing after leaving the page, you can use the audio0/audio1 system variables in the page's leave event to close or pause the audio playback status of the specified channel.
twfile filepath,filesize
filepath: target file path (e.g. "ram/0.jpg" or "sd0/1.jpg") filesize:
file size Example: twfile "ram/0.jpg",10345 (transmit a file of size 10345 to the memory file system, the file name is "0.jpg")
Example:
twfile "sd0/a.jpg",10345 (transmit a file of size 10345 to the SD card root directory, the file name is "a.jpg")
Remark:
1. To use the memory file system, you must first configure the size of the memory file system in the project configuration options. The default memory file system size for a new project is 0, which means it cannot
be used.
2. For detailed file transmission logic, please refer to the "Advanced Application and Special Instructions Detailed Explanation" document. Click here to jump to the detailed description page.
delfile filepath
filepath: file path (e.g. "ram/0.jpg" or "sd0/1.jpg") Example
1: delfile "ram/0.jpg" (delete the "0.jpg" file in the memory file system)
Example 2: delfile "sd0/a.jpg" (delete the "a.jpg" file in the root directory of the SD card)
Remark:
To use the memory file system, you must first configure the size of the memory file system in the project configuration options. The default memory file system size for a new project is 0, which means it cannot be
used.
Machine Translated by Google
0.jpg","ram/1.jpg" (rename 0.jpg in the memory file system to 1.jpg) Example 2: refile "sd0/a.jpg","sd0/b.jpg"
Remark:
To use the memory file system, you must first configure the size of the memory file system in the project configuration options. The default memory file system size for a new project is 0, which means it cannot
be used.
search result to the variable, which must be a numeric variable (0-search failed; 1-search
successful) Example 1:findfile "ram/0.jpg",va0.val (search for 0.jpg in the memory file system and return the result to va0.val)
Example 2:findfile "sd0/a.jpg",sys0 (search for a.jpg in the root directory of the SD card and return the result to sys0)
Remark:
To use the memory file system, you must first configure the size of the memory file system in the project configuration options. The default memory file system size for a new project is 0, which means it cannot
be used.
transparent read data size**(if 0, a 4-byte integer in little endian mode is returned to represent the file size)** crc:
add CRC checksum to the end of the data (0-no crc; 1-crc16; 10-crc32) Example
1:rdfile "ram/0.jpg",0,10,1 (starting from data position 0 of the "0.jpg" file in the memory file system, read 10 bytes transparently transmitted to the serial
port, and add a crc16 checksum to the end of the data. The total is 10+2=12
bytes) Example 2:rdfile "sd0/a.jpg",0,10,10 (starting from data position 0 of the "a.jpg" file in the root directory of the SD card, read 10 bytes transparently
transmitted to the serial port, and add a crc32 checksum to the end of the data. The total is 10+4=14 bytes)
Remark:
1. To use the memory file system, you must first configure the size of the memory file system in the project configuration options. The default memory file system size for a new project is 0, which means it
cannot be used.
2. The CRC16 check algorithm is MODBUS CRC16. Click here to view the reference function code . The CRC32 check algorithm is standard CRC32.
Machine Translated by Google
(create a file named "0.txt" in the memory file system with a size of 4096 bytes) Example 2: newfile "sd0/1.txt",4096 (create a file named
"1.jpg" in the root directory of the SD card with a size of 4096 bytes)
Remark:
1. To use the memory file system, you must first configure the size of the memory file system in the project configuration options. The default memory file system size for a new project is 0, which means it
cannot be used.
new you
Example: newdir "sd0/a/" (create a subdirectory named a in the root directory of the SD card)
Remark:
1. The internal memory file system does not support subdirectories, but the SD card supports subdirectories. The directory path must end with "/".
deldir "sd0/a/" (delete the subdirectory named a in the root directory of the SD card)
Remark:
1. The internal memory file system does not support subdirectories, but the SD card supports subdirectories. The directory path must end with "/".
"sd0/a/", "sd0/b/" (change the subdirectory named a to b in the root directory of the SD card)
Remark:
1. The internal memory file system does not support subdirectories, but the SD card supports subdirectories. The directory path must end with "/".
Machine Translated by Google
result to the variable (0-search failed; 1-search successful. This variable must be a numeric type variable) Example: finddir
"sd0/a/",sys0 (find whether there is a subdirectory a in the root directory of the SD card, and return the result to sys0)
Remark:
1. The internal memory file system does not support subdirectories, but the SD card supports subdirectories. The directory path must end with "/".
Note: GUI drawing instructions are mainly used in the following situations:
When the upper interface editing software cannot meet your special display requirements, use GUI instructions to draw by yourself to achieve the display effect you want. In most cases, there is no need to
use these drawing instructions, and most applications can be achieved through the control operations of the interface editing software.
1024 (use the decimal color value 1024 to refresh the screen) Example 2:
cls RED (use the color code RED (RED represents red) to refresh the screen)
Remark:
1. For the color code table supported by the device, please refer to the "Serial Port HMI Color Code Table" after this table.
2. All color parameters in the instructions in this instruction table can use color codes supported by the device or decimal color values. Please be aware.
pic x,y,picid x: x
point; y: y coordinate of
picid: picture ID; Example 1: pic 10,20,0 (displays the picture with picture ID 0 in the resource file at the coordinate
position (10,20)) Example 2: pic 40,50,1 (displays the picture with picture ID 1 in the resource file at the coordinate position (40,50))
Machine Translated by Google
Example 1: picq 20,50,30,20,0 (cut the area of picture 0 starting coordinate (0,0) with width 30 and height 20 to the screen for display, and the starting coordinate of the screen is (20,50))
Remark:
This command requires that the image must be a full-screen image, otherwise the cut image is not what you want. The cut area on the image overlaps the display area on the screen.
xpic 20,50,30,20,40,15,0 (cut the area of picture 0 starting coordinate (40,15) width 30 height 20 to the screen for display, and the display starting coordinate on the screen is (20,50))
backcolor: background
the picture ID); xcenter: horizontal alignment (0 is left alignment, 1 is center alignment, 2 is right alignment); ycenter: vertical
alignment (0 is top alignment, 1 is center alignment, 2 is bottom alignment); sta: background fill mode (0 is
cut image, 1 is monochrome, 2 is picture, 3 is no background, when sta is set to a cut image or picture,
backcolor indicates the picture ID) string: character content; Example 1: xstr 0,0,100,30,1,RED,BLACK,1,1,1,"ÿÿ" Example explanation: Use font library 1 to write "ÿÿ" in the area with the starting
BLACK (if you don't want to write the background color (i.e. no background), you can set the sta parameter to 3), the horizontal alignment is centered, and the vertical alignment is also centered.
Remark:
1. When the characters written exceed the set w, the line will be automatically wrapped. If there are remaining characters after wrapping to h, they will be ignored.
2. For an explanation of the color value, see the remarks of the cls directive.
Machine Translated by Google
point coordinate x; y:
y; w: area width; h:
0,0,100,30,RED (fill the area with RED color at the starting coordinate (0,0) with a width of 100 and a height of 30)
Remark:
For an explanation of the color value, see the remarks of the cls directive.
point coordinate x; y:
line color; Example 1: line 0,0,100,100,RED (draw a RED line between coordinates (0,0) and (100,100))
Remark:
For an explanation of the color value, see the remarks of the cls directive.
point coordinate x; y:
line color; Example 1: draw 0,0,100,100,RED (draw a rectangle with the upper left corner at (0,0), the lower right corner at (100,100), and the color is RED)
Remark:
1.Draw draws a hollow rectangle. If you need to fill a solid rectangle, please use the fill area filling command directly.
2. For an explanation of the color value, see the remarks of the cls directive.
Machine Translated by Google
cir x,y,r,color x:
center coordinate
xy: center
color: line color; Example 1: cir 100,100,30,RED Draw a hollow circle with a radius of 30 and a color of RED with coordinates (100,100) as the center
Remark:
For an explanation of the color value, see the remarks of the cls directive.
cirs x,y,r,color x:
center coordinate
xy: center
color: fill color; Example 1: cirs 100,100,30,RED Draw a solid circle with a radius of 30 and a fill color of RED with the coordinates (100,100) as the center.
Remark:
For an explanation of the color value, see the remarks of the cls directive.
Tip: All color parameters in the instructions in this instruction table can use color codes supported by the device or decimal color values.
Machine Translated by Google
ÿTable of contentsÿ
1. Assignment Operation
2. Operation
1. [Assignment operation]
•All assignment operations can be written into the control event in the upper editing state, or transmitted through the serial port (remember to add three 0xff terminators for serial
port transmission)
t0.txt=t1.txt Assigns the txt property of the t1 control to the txt property of the t0 control
t0.txt=123 Cause of error: The txt attribute of the t0 control is of string type, and the attribute value constant of string type must be enclosed in double quotes
t0.txt=h0.val Error reason: The val attribute of the h0 control is a numeric type and cannot be assigned to a string type attribute
n0.val=h0.val Assign the val attribute of the h0 control to the val attribute of the n0 control
dim=80 Assign 80 to the system variable dim (the backlight brightness immediately changes to 80
brightness) baud=115200 Assign 115200 to the system variable baud (the screen baud rate immediately changes to
115200) n0.val=baud Assign the current baud rate system variable of the screen to the val attribute of the n0 control
n0.val="123" Error reason: The val attribute of the n0 control is a numeric type, and the attribute assignment constant of the numeric type should not have double quotes.
n0.val=t0.txt Error reason: The txt attribute of the t0 control is a string type and cannot be assigned to a numeric type attribute
Kind tips:
1. So far, only the txt attribute is of string type, and the other attributes are of numeric type.
2. String types and numeric types can be converted and assigned to each other through the covx instruction. For details, please refer to the covx instruction description in the instruction
set.
2. [Calculation Operation]
1All operations do not support multiplication and division priority, nor do they support bracket priority. The order is unified from left to right. Please pay special attention.
•All calculation operations can be written into the control event in the upper editing state, or transmitted through the serial port (remember to add three 0xff terminators for
Examples:
n0.val=n0.val+n1.val+2
n0.val++
n0.val+=2
n0.val=n1.val%3
n0.val=h0.val*10
n0.val*=10
n0.val=n1.val&3
n0.val=n1.val^5
.....
n0.val=t0.txt+1 Cause of error: Numeric variables must be operated on and assigned to numeric variables.
n0.val=1+"2" Error reason: Numeric variables must be operated on and assigned to numeric variables.
Operator "+"
Examples:
t0.txt="1"+"2"
t0.txt=t0.txt+t1.txt
t0.txt+="abc"+"xy"
t0.txt=1+2 Cause of error: 1 and 2 are both numeric constants. String type variables can only be added to string constants/variables, not to a numeric constant/variable.
Machine Translated by Google
t0.txt=t0.txt+h0.val Error reason: h0.val is a numeric variable and cannot be added to a string variable
Operator "-"
Examples:
In string variable operations, "-" means deletion, so when using "-", the string variable must be "-" a numerical constant/variable to indicate how many characters to delete. This is different
from using "+". When using "+", it must be string + string; when using "-", it must be string - numerical value.
In most cases, we are operating the control properties of the current page. If you need to operate the control properties of other pages, please write as follows:
[Page].[Control].[Property]=XXX
Example:
the main page main.t0.txt=set.t3.txt Assign the value of t3.txt of the set page to t0.txt of the
main page set.t4.txt="abc" Assign the value "abc" to t4.txt on the set page
Special note: When operating control properties across pages, whether reading or assigning values, the vscope property of the operated control must be set to global (private by default),
•Note: All logic statements can only be written into the control event in the upper editing state, and serial port transmission logic statements are not supported.
1. If statement
if(t0.txt=="123456") {
page 1
}
Example 2: (If t0.txt is not equal to "a" nor equal to "b", then switch to page 1)
Machine Translated by Google
if(t0.txt!="a"&&t0.txt!="b") {
page 1
}
Example 3: (If t0.txt is equal to "a" or equal to "b", then switch to page 1)
if(t0.txt=="a"||t0.txt=="b") {
page 1
}
Example 4: (The following statement written in the press event of button b0 will switch the txt content of b0 back and forth between start and stop)
if(b0.txt=="start") {
b0.txt="Stop" }
else {
b0.txt="Start"
}
Example 5: (The following statement written in the press event of button b0 will switch the txt content of b0 back and forth between 1, 2, and 3)
if(b0.txt=="1")
{ b0.txt="2"
}else if(b0.txt=="2") {
b0.txt="3"
}else
{ b0.txt="1"
}
Remark:
1. Numeric type variables support: >; <; ==; !=; >=; <=
3. If judgment does not support bracket priority, for example: if((t0.txt=="a"||t0.txt=="b")&&t1.txt=="1") is not supported! Also, do not have extra spaces.
4. Operations are not allowed during if judgment, for example: if(n0.val+2==3) is not supported.
2. While Statement
Example 1: (n0.val keeps increasing until it reaches 100. During the increase, the screen will not refresh until all statements in the whole process are completed)
Machine Translated by Google
while(n0.val<100) {
n0.val++
}
Example 2: (n0.val keeps increasing until it reaches 100. During the process of increasing, the screen will continuously refresh the display of n0 control)
while(n0.val<100) {
n0.val++
doevents
}
Remark:
1. In the execution of a process with more instructions, or in a long loop statement, all control rights of the system are occupied by this process. Before the end of the process,
although the corresponding memory data can be read and written normally, the screen will not refresh. After adding doevents, the control right can be transferred to the screen
refresh. After executing doevents, the screen will refresh all the changed controls. After the refresh is completed, the control right is returned to the current process to continue
execution. Prevent the screen from showing a false dead display state.
2. During the while statement loop, the device will not respond to touch events, and the serial port instructions will be received in the buffer but will not be executed until all
statements in the current process are executed. Please use it with caution to avoid entering an infinite loop.
3. for statement
Example 1: (n0.val keeps increasing until it reaches 100. During the increase, the screen will not refresh until all statements in the whole process are completed)
for(n0.val=0;n0.val<100;n0.val++) { }
Example 2: (n0.val keeps increasing until it reaches 100. During the process of increasing, the screen will continuously refresh the display of n0 control)
for(n0.val=0;n0.val<100;n0.val++)
{ doevents
}
Remark:
1. In the execution of a process with more instructions, or in a long loop statement, all control rights of the system are occupied by this process. Before the end of the process,
although the corresponding memory data can be read and written normally, the screen will not refresh. After adding doevents, the control right can be transferred to the screen
refresh. After executing doevents, the screen will refresh all the changed controls. After the refresh is completed, the control right is returned to the current process to continue
execution. Prevent the screen from showing a false dead display state.
2. During the for statement loop, the device will not respond to touch events, and the serial port instructions will be received in the buffer but will not be executed until all statements
in the current process are executed. Please use it with caution to avoid entering an infinite loop.
Machine Translated by Google
sequence
1
dp Current page ID 2.prints dp,0 (send the current page ID to the string
baud=9600 Note: The baud rates supported by the device are: 2400
Current baud rate value (this modification, drop
4 baud 4800 9600 19200 38400 57600
Lost after power on)
115200230400 256000 512000 921600
effect)
Automatic sleep])
thup=0 (touch will not automatically wake up after sleep) thup=1 (sleep
Touch to automatically wake up in sleep mode Touch to wake up automatically after sleep) Note: No matter thup is 0 or 1,
12 thup
Off (power-on default 0) When there is a touch operation in sleep mode, the device will send a touch
Serial
sleep) usup=1 (the serial port will wake up automatically after sleep)
Serial data automatic wake-up switch in sleep Note : The default setting is 0 when powered on, and it will not wake
13 usup
mode (power-on default 0) up automatically. You need to send sleep=0 to wake up the screen.
14 whoops Refresh page settings after waking up from sleep after waking up: 2) Note: When the device is in sleep state,
also be executed.
sleep mode.
Set the data returned when the serial command is executed the serial port command is executed successfully or failed.
16 bkcmd
successfully or failed (the default value is 2 when powered on) When the command written in the upper software editing
returned. This setting will not affect the data returned when
executing the delay command, the device CPU will not execute
18 delay Delay
any instructions, but will continue to accept serial port commands
Serial
19 rand Random Numbers and 2147483647 for the maximum. After setting the range, each
time you read the system variable rand, you will get a random
number. 2. Each time you set the range using the randset
20 tch0-tch3 Real-time touch coordinates when last pressed y Note: Touch coordinates can only be read,
is 0.
21 addr Device Address is 0, that is, there is no address. 2. When sending a command
data before the command, send it in hex mode, 2 bytes little end
when configuring, and the low bit is in front when sending the
configuration writing).
prints crcval,2 (the lower 2 bits of the current CRC check result
are printed to the serial port) Note: 1. Use crcrest to reset the
CRC verification result (can only be obtained but CRC value first. After resetting, you can use crcputs or
22 crcval not set. Please use crcrest command to reset the crcputh or crcputu to check the specified data. After the
initial value before use) check is completed, read the system variable crcval to obtain
code, please refer to: Using CRC Check Data in the Program
Machine Translated by Google
Serial
resistor is 50K).
hardware with extended IO) K0 series only After the PWM duty cycle is set, you need to use the cfgpio
25 pwm4-pwm7
supports io4-io7 PWM X5 series only supports io6-io7 command to configure the IO mode to PWM output mode, and
PWM the corresponding IO will start to output PWM. After the PWM
PWM output frequency ( supported only by t0.txt)Remarks: 1. The frequency unit is: HZ, the range
26 pwmf
hardware with extended IO) is minimum 1, maximum 65535HZ, and the
eql-Bass attenuation (31HZ- the greater the attenuation; 8-15 for boost, the larger the
hardware with audio) not supported by the and eqh separately, it is equivalent to modifying eq0-eq2,
sequence
Independent frequency attenuation (with audio hardware The setting range is 0-150-6 for attenuation. The smaller the number, the attenuation
Only supported) The upper simulator does not support The greater the reduction, 8-15 is an improvement, the larger the number, the greater the improvement
Note: 1. The play command is used to configure and start the audio
After starting playback, even if you jump to another page, the audio
BLUE 31 blue
BLACK 0 black
1. The command execution success or failure data will be returned only when the system variable bkcmd is non-zero. After each power-on, bmcmd defaults to 2, which means
2. The code written into the resource file when editing the upper software is not affected by bkcmd. If there is an error in the execution, error data will be returned, and no data will be
returned if it succeeds.
3: The end character of the data returned by the device is three bytes: "0XFF 0XFF 0XFF".
<<<<<<<<<<<<<< <<<<<<<
>>>>>>>>>> >>>>>>>
0X00 Invalid command 0X00 + end character (this data is returned when an invalid command is received from the user)
Invalid 0X02+terminator (this data is returned when the command sent by the user contains an invalid control
0X02
control ID ID or invalid control name)
Invalid 0X03+end character (this data is returned when the instruction sent by the user contains an invalid
0X03
Page ID page ID or invalid page name)
Invalid 0X04+end character (this data is returned when the command sent by the user contains an invalid
0X04
image ID image ID)
Invalid font 0X05+terminator (this data is returned when the command sent by the user contains an invalid font ID)
0X05
ID
File operation
0x06 0X06+end character (returned when the file operation fails)
failed
CRC check 0X09+end character (this data is returned when the command with verification fails, instruction verification
0x09
failed description
0X11+terminator (the baud rate configuration command sent by the user contains invalid baud rate
Invalid baud
0X11 parameters) The baud rates supported by the device are: 2400 4800 9600 19200 38400
rate setting
57600 115200
Machine Translated by Google
Curve Controls
0X12+terminator (When the user uses the add command to add data to the curve control, this data is returned when the curve control
0X12 Invalid ID or
ID number or channel number is invalid)
channel number
0X1A+terminator This data is returned when the variable name received by the serial port is an invalid name. Note: Control properties
Invalid variable
0X1A are also called variables. For example, when you set the properties of a control, if you enter a property name that it does not have,
name
this data will also be returned.
0X1B+terminator For example, the txt attribute of the text control t0 should be written as t0.txt=”abc”. If you write t0.txt=abc, it will be
Invalid variable
0X1B wrong. For example, the val attribute of the progress bar j0 should be a numeric value, so it should be written as j0.val=50. If you
operation
write j0.val=”50” or j0.val=abc, it will also be wrong.
The assignment
0X1C 0X1C+Terminator This data is returned when the attribute assignment fails
operation failed
EEPROM
0X1D 0X1D+end character returns this data when EEPROM operation fails
Operation failed
Invalid number of
0X1E 0X1E+terminator This data is returned when the number of parameters in the command entered by the user is incorrect
parameters
IO operation
0X1F 0X1F+terminator This data is returned when the IO operation fails
failed
Error using
0X20 0X20+ This data is returned when the end character escape character is used incorrectly
escape characters
Variable name is
0X23 0X23+terminator The maximum length of the variable name is 29 characters. If it exceeds this value, this data will be returned.
too long
0X24+terminator This data will be returned when the serial port buffer is full (after the buffer overflows, the instructions in the buffer
Serial port buffer
0X24 queue will be executed to make room for the buffer to continue receiving instructions. Before this, the data received by the serial port
overflow
will be discarded)
Machine Translated by Google
1. The end mark of the data returned by the device is three bytes "0XFF 0XFF 0XFF". 2. The return of the following data is not affected by bkcmd.
Return
<<<<<<<
the first
meaning Format
bit of
>>>>>>>
data
0X65+page ID+button ID+touch event+end character (this data is returned when the user-created control is pressed or popped
Touch hot zone up, provided that you have checked the "Send key value" checkbox of the control) (definition of touch event: press event 0x01 pop-
0X65
event return up event 0X00) Example: 0X65 0X00 0X02 0X01 0XFF 0XFF 0XFF Meaning: Page 0 Button 2 pressed
The ID number of
0X66+page ID+end character (the device will return this data when it receives the "sendme" command) Example:
0X66 the current
0X66 0X02 0XFF 0XFF 0XFF Meaning: The current page ID is 2
page is returned
0X67+coordinate X high bit+coordinate X low bit+coordinate Y high bit+coordinate Y low bit+touch event status+terminator (when
Touch coordinate the system variable "sendxy" is 1, this data is returned when there is a touch event) (definition of touch event: press event 0x01 pop-
0X67
data returned up event 0X00) Example: 0X67 0X00 0X7A 0X00 0X1E 0X01
0X68++Coordinate X high bit+Coordinate X low bit+Coordinate Y high bit+Coordinate Y low bit+Touch event status+Terminator
Sleep mode (When the device enters sleep mode, this data is returned when there is a touch event) (Definition of touch event: Press event
0X68
touch events 0x01 Pop-up event 0X00) Example: 0X68 0X00 0X7A 0X00 0X1E 0X01
String variable 0X70+ variable content ASCII code + terminator When the variable obtained by the get command is a string type, this data is
0X70 data return returned. Example: 0X70 0X61 0X62 0X63 0XFF 0XFF 0XFF Meaning: Return string data: "abc"
0X71+variable binary data (4-byte little-endian mode, low-order first)+terminator When the variable obtained by the get instruction is a
Numeric variable
0X71 numerical value, this data is returned. Example: 0X71 0X66 0X00 0X00 0X00 0XFF 0XFF 0XFF Meaning: Return numerical data:
data return
102
The device
0x86+end character This data is returned only when the device automatically enters sleep mode. This data is not returned if the serial
0X86 automatically
port command sleep=1 is executed to enter sleep mode.
enters sleep mode
Automatic device 0x87+end character This data is returned only when the device wakes up automatically. If the sleep state is awakened by executing
0X87
wake-up the serial port command sleep=0, this data will not be returned.
System startup
0X88 0x88+end character The device sends this data after power-on initialization is successful
successful
Start SD
0X89 0x89+end character After the device detects the SD card after power-on, it will send this data and then enter the upgrade interface
card upgrade
Transparent data
0XFD 0xFD+end character After the transparent transmission of data ends and the data processing is completed, this data is sent
transmission completed
Data transmission After receiving the data transparent transmission command, the device enters the transparent transmission data initialization. After the initialization is completed,
0XFE
ready this data is sent, indicating that it has entered the data transparent transmission mode and can start data transparent transmission.
Machine Translated by Google
In most cases, we operate control properties like this (this is also the recommended way to operate controls):
What if we don't know the name of the control but only know the control ID? This requires name groups to implement
example:
b[5].txt="123" //The txt attribute of the control with ID 5 on the current page is assigned to "123"
b[n0.val].txt="123" //The txt attribute of the control with ID n0.val on the current page is assigned to "123"
Note: You must ensure that this control on the current page has the txt attribute, otherwise the assignment will fail.
example:
p[2].b[4].txt="456" //In the page with ID 2, the txt attribute of the control with ID 4 is assigned the value "456"
p[n0.val].b[n1.val].txt="456" //In the page with ID n0.val, the txt attribute of the control with ID n1.val is assigned the value "456"
Note: You must ensure that this control in this page has the txt attribute, otherwise the assignment will fail.
ÿ Use the for statement to batch change the control properties (load the continuous values starting from eeprom address 100 to the numeric controls n0~n9 (ID: 5~14)):
for(sys0=5;sys0<=14;sys0++) //for loop reads eeprom and assigns value to numeric control {
repo b[sys0].val,sys1 //Read the eeprom data at the specified location sys1+=4 }
//The eeprom read address plus 4, because a numerical type occupies 4 bytes of space.
Note: You must ensure that controls with IDs from 5 to 14 have the val attribute, otherwise the assignment will fail.
•The ID numbers of all controls are automatically assigned by the software and cannot be set manually. When the user edits the UI interface, the software will assign IDs consecutively for controls
placed in sequence.
•Using the "Top" and "Bottom" functions on the shortcut bar will change the control ID, because the front and back relationships of the layers are related to the control ID. The one with the smallest ID
is at the bottom layer (so the page ID is 0), and the one with the largest ID is at the top layer. Each control has its own layer, and the front and back relationships are all distinguished by ID.
Machine Translated by Google
This document mainly describes some advanced applications and implements some special functions. Most projects do not use these functions. If your project does not use them, you can ignore this
document.
ÿChapter Indexÿ
1. Detailed explanation of the application of active analysis mode in serial port data analysis mode
1. Detailed explanation of the application of active analysis mode in serial port data analysis mode
The screen is in passive parsing mode by default when it is powered on. All serial port commands must be operated on the screen in the format of the instruction
set. If you need to customize the protocol and send serial port data to the screen in a format you customize instead of the instruction set format, you need to
configure the screen in active parsing mode. To use this function, please
make sure you have the following two basics: 1. Understand what HEX, String, and ASCII are, their
relationship, and how to convert them. 2. Understand the differences between single-byte values, double-byte values, and four-byte values, how they are stored in
memory, and understand what little-endian mode and big-endian mode are. Understand what low-order bits are in the front. If you understand the above two points,
please continue reading. Otherwise, it is strongly recommended not to continue reading, because most projects do not use this function. Use the default passive
parsing mode. There is no need to configure it to the following active parsing mode.
1. Serial port data analysis mode system variable: recmod 2. Serial port
buffer data size system variable: usize 3. Serial port buffer data group:
1. Serial port data parsing mode system variable recmod (0 is passive parsing mode, 1** is active parsing mode**)
When the screen is powered on, recmod is 0, that is, passive analysis mode. In this mode, the external device sends serial port commands to the screen for execution according to the command
format of the standard command set; if you set recmod to 1 (you can write recmod=1 in the initialization event of the power-on default page), the screen will enter the active analysis mode, and then
all serial port commands will not be executed (note: the serial port commands will not be executed, and the firmware commands written in the event when the upper software edits the interface will
not be affected and will still be executed normally), and all serial port data are stored in the serial port buffer, waiting for you to actively read. After reading the data each time, use the udelete command
to delete the number of bytes that have been read in the buffer, otherwise the buffer will overflow and new data cannot be received.
Note: When the screen is set to active analysis mode and the screen is connected to the host computer software simulator, the screen will be forced to exit the active analysis mode. At this time, the screen
needs to be powered on again before the simulator can be normally connected to debug the screen.
Machine Translated by Google
2. Serial port buffer data size system variable usize (can only be read, not set)
By reading this variable, you can know how much data is cached in the current serial port buffer.
The serial port buffer data group is written as u[index] (index is the sequence number)
Example 1: Get a 1-byte value from position 0 in the buffer and assign it to the digital control n0. The writing is as follows:
n0.val=u[0]
Example 2: Get a 2-byte value (little-endian mode, low-order first) from position 0 in the buffer and assign it to the digital control n0. The writing is as follows:
n0.val=u[1]
n0.val<<=8
n0.val+=u[0]
Example 3: Get a 4-byte value (little-endian mode, low-order first) from the buffer starting at position 0 and assign it to the digital control n0. The writing is as follows:
n0.val=u[3]
n0.val<<=8
n0.val+=u[2]
n0.val<<=8
n0.val+=u[1]
n0.val<<=8
n0.val+=u[0]
Is it true that the only way to assign the contents of a buffer to a 4-byte integer variable is to assign the values of the bytes four times and then shift them three times? Of course
This instruction can continuously copy a specified amount of data from the specified location of the serial port buffer to the target variable (the target variable can be a string
Example 1: Get a 4-byte value (little-endian mode, low-order first) from position 0 in the buffer and assign it to the digital control n0. The writing is as follows:
Delete the first 4 bytes in the buffer. If there is other data behind, it will be automatically pushed up.
Tips: Each numeric variable is allocated 4 bytes of memory. If you use ucopy to obtain a value less than 4 bytes from the buffer, you must pay attention to the
processing of the remaining byte data to avoid data anomalies. Please refer to the following example for the operation method:
Example 2: Get a 2-byte value (little-endian mode, low-order bits first) from position 0 in the buffer and assign it to the lower 16 bits of the digital control n0.val. The
writing is as follows:
n0.val=0
ucopy n0.val,0,2,0 //If you want to assign a value to the upper 16 bits, write ucopy n0.val,0,2,2 udelete 2 //Delete
the first 2 bytes in the buffer. If there is other data behind, it will be automatically pushed up
Explanation: n0.val is first assigned a value of 0 to ensure that all 4 bytes of n0.val are set to 0, and then 2 bytes are copied from the buffer. Otherwise, because you
only copy 2 bytes, the remaining 2 bytes of data in n0.val will still be there, and the final value of n0.val will not be what you want.
Example 3: Get a 10-byte string from position 0 in the buffer and assign it to the text control t0. The writing is as follows:
if(usize>=10) { ucopy // Make sure the buffer size is large enough for 10
t0.txt,0,10,0 udelete 10
//Delete the first 10 bytes in the buffer. If there is other data behind, it will be automatically pushed up
Important note: The code_c command will clear the buffer data, which may cause the data that has not been read to be deleted prematurely. Therefore, in active
parsing mode, it is recommended to use the udelete command to delete the content that has been read instead of using the code_c command.
All the statements and instructions used in the above cases are firmware instructions written into the event in the upper editing interface. Once the serial port is
configured in active parsing mode, serial port instructions can no longer be executed. Therefore, the serial port data must be read by firmware instructions, not by
The conventional method to exit the active parsing mode is to write the firmware instruction recmod=0 in the event. If you want to exit through serial port data,
sending recmod=0 through the serial port is definitely useless. You can exit the active parsing mode by sending a string of exit passwords. The exit password is a
24-byte string:
Total 27 bytes
Machine Translated by Google
The HMI download protocol described in this article is only suitable for users who want to make their own download programs or want the microcontroller to control the HMI to download
resource files . It belongs to the category of advanced applications, not the category of HMI interface design, so users with a certain foundation are required to operate it. Shenzhen Taojingchi
Electronics Co., Ltd. only makes a public statement on this protocol and does not provide any technical support related to the download protocol. If you are not familiar with serial port operations,
it is recommended to ignore this statement and directly use the USART HMI software to download without any understanding of this protocol.
Tips: The official has developed a dedicated download tool (TFTFileDownload) in accordance with this agreement, and the source code is open. You are welcome to download
This step is mainly used to search which serial port the HMI device is on and the current baud rate of the device. If these two conditions are known, you can skip this step and directly fix the serial port
number and the current baud rate of the device in your program and jump directly to step 2 to start downloading.
•Search method:
Send a connection command to each serial port of the computer at different baud rates: connect+terminator. After receiving the connection
command, the device will return the connection data. If the correct connection data is received, it means that the device is successfully connected. At this point, the serial port number of the current
Because the instructions are sent in a loop, when the screen receives data at the correct baud rate, there will definitely be some erroneous data at the last wrong baud rate at the front of the data, so
the first instruction will definitely be regarded as an erroneous instruction. Therefore, two instructions need to be sent each time. The first one is a 4-byte HEX empty instruction (00 ff ff ff), and the
second one is the connect+terminator. Delay description: After each attempt to connect, the shortest time to wait for data to return is (unit: ms):
(1000000/attempted baud rate) + 30. If you try to connect at 9600 baud rate, the shortest time to wait for return is: 1000000/9600+30=134ms. The same applies to other baud rates.
Data explanation:
Taking the TJC4024T032_011R device as an example, the device returns the following 8 groups of data (each group of data is separated
Now we know which serial port the device is on and its current baud rate, and we can send the download command.
tft file to be downloaded is 10000 bytes, it needs to be downloaded at 115200 baud rate, then send the command: whmi-wri
command, you need to change the baud rate of the computer to the forced baud rate just set (if the current baud rate is inconsistent with the forced
After receiving the whmi-wri command, the device will return a 0x05 data in about 250ms (only one byte, without the three 0XFF terminators, and the baud rate is the
forced download baud rate just set). After receiving this data, you can start sending the binary data of the tft file. The sending format is 4096 bytes per package, and
the number of remaining bytes in the last package is the same. After each package is sent, you need to wait for the screen to return a response signal. The response
3. Serial port commands add CRC check (supported by 0.56 and above host computer versions)>
Under normal circumstances, the command can be sent directly without verification. If your project has strict requirements on command transmission and verification must be enabled, please follow the instructions
Please note: The CRC instruction is only supported from version 0.56 onwards, and earlier versions do not support it.
No configuration is required for verification or non-verification. You only need to modify the command. You can run the previous command with verification and the next command without
The terminator of a normal instruction is 0xff 0xff 0xff, and the terminator of an instruction with checksum is 0xfe 0xfe 0xfe.
The instruction CRC16 check algorithm uses the MODBUS CRC16 check algorithm, and the calculation function is as follows:
The data that needs to be verified are all instruction data. If it is an instruction with an address, it starts from the address. If it is an instruction without an address, it starts from the first byte of
int i;
U8 newtemp8 = 0; for (i =
0; i < 8; i++) {
} return newtemp8;
int i;
U16 newtemp16 = 0; for
(i = 0; i < 16; i++) {
} return newtemp16;
}
int i;
U16 wCRCin = 0xFFFF;
U16 wCPoly = 0x8005;
U16 wChar = 0;
while (lenth > 0) {
wChar = *data;
data++;
wChar = InvertUint8( (U8)wChar);
wCRCin ^= (U16)(wChar << 8); for (i
= 0; i < 8; i++) {
} length=length-1;
} wCRCin = InvertUint16(wCRCin);
return (wCRCin);
}
After the instruction and before the terminator, add a 2-byte CRC16 checksum (HEX) + a 1-byte constant: 0x01 (HEX), which is equivalent to inserting 3 bytes
between the instruction and the terminator. The CRC checksum is stored in little-endian mode, with the low bit first.
If the screen receives a command with verification and finds that the verification fails, it will return an error: 0x09 0xff 0xff 0xff
Machine Translated by Google
4. Use CRC check data in the program (supported by 1.60.1 and above host computer versions)
1. The following code will enable the screen to send 2 sets of constant data to the external device, and add the Modbus CRC16 check result at the end:
crcputs "hex date is:",0 CRC check string: hex date is:
"hex date is:",0 The serial port sends a string: hex date is:
2. The following code will enable the screen to send 2 sets of variable data to the external device, and add the Modbus CRC16 check result at the end:
n0.val,4 prints The serial port sends the string variable t0.txt
3. The following code will implement CRC check on the data in the serial port buffer in active parsing mode, and display the success or failure result to t0.txt
if(usize>=24)
crcputu 0,22 sys0=0 Verify the first 22 bytes of the serial port buffer
sys0 is a 4-byte integer data, and the CRC result is only 2 bytes, so clear the extra bytes first
ucopy sys0,22,2,0 Assign the CRC result received in the receive buffer to sys0
t0.txt="Verification passed"
}else
t0.txt="Verification failed"
5. Transferring images from the serial port to the memory or SD card during operation (supported by host computer versions 0.56 and above)
If you want to transfer image files to memory, please configure the memory file system space size in the project settings. The default is 0, which means there is no space.
If you are transferring image files to an SD card, please make sure that the SD card disk format is FAT32, and the maximum supported card capacity is 32G.
Tips: The official has developed a dedicated serial port transparent file transmission tool (SerialFileUp) according to this protocol, and the source code is open. Welcome to
Use the "External Picture" control and set the path property to the file path, such as: ram/0.jpg
Use the "External Picture" control and set the path property to the file path, such as: sd0/0.jpg
Jpg format: If you use jpg format images, make sure that the image is encoded as baseline DCT, otherwise it will not be displayed. If the screen direction is set to 0 degrees, you can
directly use the original jpg image. If the screen direction is set to 90 degrees, you need to rotate the image 90 degrees clockwise before using it on the screen, otherwise the displayed
image will be in the wrong direction. Other directions are 180 degrees, 270 degrees, and so on. You need to rotate the image clockwise in advance according to the screen direction.
xi format: This format is a special image format for HMI, supports transparent background, and is recommended. To obtain images in xi format, you can use the image conversion tool
Currently, only the above two formats of image files are supported.
Step 1: Send serial port file transfer command: twfile filepath, filesize
filepath: file storage path such as: ram/a.jpg or sd0/a.jpg filesize: actual file size If you
the name is a.jpg, the size is 3282, the command is: twfile "ram/a.jpg", 3282 If you want to transfer a file to the SD card, the name is a.jpg, the size is 3282,
the command is: twfile "sd0/a.jpg", 3282 After receiving this command, the screen will immediately create a file of the specified size on the target path. If the
creation is successful, it will return: 0xfe + terminator, indicating that it has entered the transparent transmission state and can start to sub-packet transparent transmission data. If the file creation
fails, it will return: 0x06 + terminator, and continue to work in the command receiving state.
After receiving 0xfe+terminator, you can start to sub-packet transparent transmission of data; a complete data packet consists of 2 parts: header + data
Packet header: 3a a1 bb 44 7f ff fe + check type (1-byte integer data) + packet ID (2-byte integer data) + data size (2-byte integer data), a total of 12 bytes
Check type: 0x00 is no check, 0x01 is CRC16 (CRC16 check algorithm of MODBUS, there is a calculation function reference in the instruction check section), 0x0A is standard CRC32 Package
ID of the file transparent transmission is 0, and the ID increases by 1 for each successful transparent
transmission. Data size: The data size can be specified by the user, with a minimum of 1 byte and a maximum of 4096 bytes (this data size does not include the 12-byte packet header, but includes
Data: file data + CRC checksum data (little endian mode, low bit first). If it is a non-checked packet, there is no CRC checksum. If it is CRC16, it is a 2-byte checksum. If it is CRC32, it
is a 4-byte checksum. Remember to record the checksum data in the data size parameter of the packet header.
The CRC16 check algorithm is MODBUS CRC16, click here to view the reference function code) The CRC32 check algorithm is standard CRC32.
After the screen receives a complete packet of data, if the processing is successful, it will return 0x05 (single byte, no end mark), and then the next packet can be sent.
Machine Translated by Google
If the packet ID is not accumulated according to the rules or the packet data is wrong, the screen will return the error of the packet processing failure: 0x04 (single byte, no end character).
After all packets are sent, the screen will return 0xfd + terminator, and automatically exit the transparent transmission mode and switch to the command mode.
If the transparent transmission of this packet fails (no screen response is received for more than 500ms or the screen returns an error message indicating that the verification of this packet has failed), resend the data of this
packet. The packet ID does not need to be increased by 1 when resending the data of this packet.
If you regret sending a data packet halfway through, just pause for more than 20ms and resend the data packet.
If you want to stop transparent transmission in the middle of the file transmission, please send a data packet with a packet ID of 65535, no checksum, and a data size of 0, that is: 3a a1 bb 44 7f ff fe 00
ff ff 00 00. After receiving such a packet data, the screen will immediately force the transparent transmission to end and return the data indicating the end of the transparent transmission: 0xfd + end
character.
If your file data contains exit packet data, don't worry, because if there is no pause of more than 20ms before the data, the screen will only store it as data and will not process it as an end packet.
ÿChapter Indexÿ
By default, the screen receiving device sends data in the complete format of a string instruction plus three hexadecimal ffs. If the screen receives an incomplete or
ÿ1c ff ff ff, etc.; you can use the ckcmd command to turn on and off the return data. (Under normal circumstances, it is recommended to find and solve the cause of the screen error first, and then turn
How to control the screen with a single chip microcomputer (text control)
1. Create a text control in the host computer project, assuming it is t0, and download the program to the serial screen. 2. The serial port of the
serial screen is connected to the serial port of the microcontroller. The baud rate of the two should be the same. The MCU RX is connected to the serial screen TX, and the MCU TX is
connected to the serial screen RX. 3. Send command: The microcontroller serial port sends t0.txt="ÿÿÿ" through string mode
4. Send end character: The microcontroller sends 0xff 0xff 0xff through HEX mode 5. At this time, the text in
How to control the screen with a single chip microcomputer (digital control)
Machine Translated by Google
1. Create a new digital control in the host computer project, assuming it is n0, and download the program to the serial port screen. 2. Connect the serial port of the serial
port screen to the serial port of the microcontroller. The baud rate of the two should be the same. The microcontroller RX is connected to the serial port screen TX, and the microcontroller TX is connected to the serial port screen.
RX.
3. Send command: The MCU serial port sends n0.val=666 in string mode 4. Send end character: The MCU
5. At this time, the text in the n0 control on the screen changes to "666"
In general, the MCU rarely sends a constant to the screen. In most cases, the MCU assigns a variable to the screen. The following code is in C language.
terminator at one time printf("t0.txt="%d"\xff\xff\xff",MyTxt); Send command and terminator at one time
Note: Here, \xff is used to send hexadecimal. If you don’t understand how to use “\”, search “C language escape character” on Baidu.
By default, the screen receiving device sends data in the complete format of a string instruction plus three hexadecimal ffs. If the screen is set to
recmod=1, the screen will enter active parsing mode, that is, custom communication protocol.
Note: 1. In active parsing mode, only the timer control can parse data, and the fastest parsing time of the timer is 50ms.
2. In active parsing mode, all serial port commands will not be executed, but will be stored in the serial port buffer, waiting for you to actively read them.
3. Under normal circumstances, it is recommended to use the default communication protocol of the screen. If the device does not follow the screen communication protocol format,
The serial port screen sends data using the get prints printh command.
Note: 1. In the same event, if you write the send command in separate lines, they are actually sent in the same line.
2. To send variables, you can only use the prints and get commands. To send hexadecimal data, you can only use the printh command.
3. The screen can use the printh command and the prints command to implement any communication protocol.