EN

STONE Display Screen Describe of the Button State Return

 

Intelligent TFT LCD Module 4.3 includes "Button," "Button Key Value Return" and "Button State Return" three basic button controls, all of which can implement the function of page switching. but "Button" cannot return key value to users. "Button Key Value Return" can return the key value to users, and "Button State Return" can send all three press states (press, long press, and lift) of the button to users. The case interface is shown in Figure 1, which includes a "Button State Return" button and a data variable display screen control.

 

display screen

Figure 1 Case Interface

 

The attributes of  the "Button State Return" button are set as shown in Figure 2. The pressing modes under the three pressing states are all 0x02. Then set the variable length, the storage address of the S variable, and the under the three pressing states respectively.

 

display screen

 

Figure 2  The Attribute Settings of Button State Return

 

After pressing the "Button State Return" button, the data sent by the serial port is the initial value of the S variable. The data sent by the serial port under the three pressing states are respectively:

First press: A5 5A 04 80 AA 98

Press continuously: A5 5A 04 81 BB CC (Note: When pressed continuously, the data will be sent continuously, and the interval is the Intelligent TFT LCD Module refresh cycle).

Lift: AA 98 03 82 BC AA 

 

 

The simulation results of virtual HMI are shown in Figure 3.

 

display screen

Figure 3 Simulation Results of Virtual HMI

 

Under the three press states in the above example, the data sent by the serial port is initial value of the S variable which is fixed.

 

In some applications, the serial port may be required to send different data according to different operating conditions. Firstly, find the storage location of the data needed to be modified through the storage address of the S variable. Then define a data variable at that location and modify the value of the variable by the command 0x82, or by variable entry. Thus, the value of the S variable changes along with it, and so do the data sent by the serial port.

 

For example, under the first pressing state in the above example, the data sent by the serial port is the initial value "A5 5A 04 80 AA 98" of the corresponding S variable. Under certain conditions, the data sent by serial port is required to be "A5 5A 04 80 55 99 ," with the last 2 bytes of data  modified. The storage address of the last 2 bytes can be found as "0x0052" through the S variable storage address "0x0050." 

  

In Figure 1, we defined a data variable display control and a data variable entry control at the location of the text box with the same variable address of "0x0052". When we click on the text box, the data entry is initiated and the value of the variable is modified to 21913 (decimal number, or 0x55 99 under hexadecimal system), and the value of the S variable changes along with it.

In this case, after pressing the "Button State Return" button again, the data sent by the serial port in the three pressed states are respectively:

First press: A5 5A 04 80 55 99

Press continuously: A5 5A 04 81 BB CC

Lift: AA 98 03 82 BC AA 

 

The simulation results of virtual HMI are shown in Figure 4.

 

display screen

Figure. 4 Simulation Results of Virtual HMI

 

Note: Please check the option "Enable initial values for variable attribute settings" on the screen parameter configuration option page as shown in Figure 5. If not, the returned data will be 00.

 

display screen

Figure 5 Enable Initial Values for Variable Attribute Settings