Serial port single-point touch processing method
By creating a serial port class object corresponding to a preset single-point touch class object, parsing serial port data to obtain the target touch position and event, and generating touch events, the problem of incompatibility between touch screen serial ports under the Kylin system is solved, and the touch function of QT development application software is realized.
Patent Information
- Application Number
- CN202210829779.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-15
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2042-07-15
AI Technical Summary
The incompatibility issue of the touch screen serial port under the NeoKylin system prevents the touch function from being implemented, affecting the compatibility of QT development application software.
A serial port single-point touch processing method is provided, which involves creating a serial port class object corresponding to a preset single-point touch class object, parsing serial port data to obtain the target touch position and event, generating touch events, and sending them to the event handling object.
This provides serial port single-point touch functionality for QT development application software under the NeoKylin system, solving the problem of incompatibility of touch devices under the NeoKylin system.
Smart Images

Figure CN115202511B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of touch screen driving, in particular to a serial port single-point touch processing method. BACKGROUND
[0002] The existing Meikua Kirin operating system adopts a reinforced Linux kernel to meet the requirements of different customers and has been widely used in the fields of energy, finance, transportation, government, central enterprises, etc. Meikua Kirin supports the implementation of security policies in a modular manner and provides a unified platform for multiple access control policies. However, although the domestic operating system has been widely used in the fields of communication, industrial control, consumer electronics, aviation, aerospace, and navigation, the short research cycle of the ecological environment leads to poor compatibility with other development tools. QT, as a cross-platform C++ graphical user interface application development framework, can provide all the functions required for the graphical interface development of the Meikua Kirin system, but the incompatibility of the touch screen serial port leads to the failure of the touch function under the Meikua Kirin system.
[0003] To solve the above problems, the present application designs a single-point touch processing method based on QT touch events under the Meikua Kirin system. SUMMARY
[0004] In view of the defects in the prior art, the present application provides a single-point touch processing method.
[0005] In one aspect, the present application provides a single-point touch processing method, comprising:
[0006] S1, obtaining serial port data read by a pre-created serial port class object; wherein the serial port class object corresponds to a preset single-point touch class object; the serial port data includes touch position information and touch state information;
[0007] S2, analyzing the serial port data to obtain a target touch position and a target touch event;
[0008] S3, generating a touch event according to the target touch position and the target touch event;
[0009] S4, sending the touch event to an event processing object to make the event processing object execute the touch event.
[0010] Further, before step S2 is executed, the method further comprises:
[0011] S1', judging whether the data length of the serial port data is greater than a first preset data length, if yes, executing step S2; otherwise, returning to execute step S1.
[0012] On the basis of the above-mentioned embodiments, further, the parsing the serial port data comprises:
[0013] storing the serial port data into a static circular array;
[0014] acquiring a target static array according to the serial port data and the static circular array.
[0015] On the basis of the above-mentioned embodiments, further, the acquiring a target static array according to the serial port data and the static circular array comprises:
[0016] calculating a first receiving length according to L1=(L0+1) / L m , wherein L1 is the first receiving length, L0 is the data length of the serial port data, and L m is the maximum data length of the static circular array;
[0017] if it is judged that the first receiving length is not less than a second preset data length, acquiring frame header position information of the serial port data in the static circular array, and acquiring a first static array according to the frame header position information;
[0018] calculating a second receiving length according to L2=L1-N, wherein L2 is the second receiving length, L1 is the first receiving length, and N is a byte number corresponding to the frame header position of the serial port data in the static circular array;
[0019] if it is judged that the second receiving length is still not less than the second preset data length, and frame tail information and a check sum of the first static array are correct, taking the first static array as the target static array.
[0020] On the basis of the above-mentioned embodiments, further, the acquiring a first static array according to the frame header position information comprises:
[0021] sequentially shifting the frame header position and data after the frame header position of the serial port data in the static circular array to corresponding byte positions of the static circular array starting from the first byte.
[0022] On the basis of the above-mentioned embodiments, further, the method further comprises:
[0023] if it is judged that the first receiving length is not less than a second preset data length, but the frame header position information of the serial port data in the static circular array cannot be acquired, storing content of the last byte in the static circular array into the first byte of the static circular array, and letting L1=1, and returning to step S1.
[0024] On the basis of the above-mentioned embodiments, further, the obtaining the target touch position and the target touch event comprises:
[0025] According to the storage protocol of the serial port data, determining a first target byte and a second target byte; wherein the first target byte stores the touch position information, and the second target byte stores the touch state information;
[0026] According to the first target byte and the target static array, determining a target touch position;
[0027] According to the second target byte and the target static array, determining a target touch event.
[0028] On the basis of the above-mentioned embodiments, further, according to the first target byte and the target static array, determining a target touch position, comprises:
[0029] According to the formula:
[0030] X = (TS_HOR_PIXELS * x0) / MAX_PIX_WIDTH;
[0031] Y = (TS_VER_PIXELS * ts_info.y0) / MAX_PIX_HEIGHT
[0032] Calculating the target touch position, wherein (x0, y0) is the touch position read from the first target byte of the target static array, (X, Y) is the target touch position, TS_HOR_PIXELS * TS_VER_PIXELS is the pixel ratio specified by the serial port device protocol, and MAX_PIX_WIDTH * MAX_PIX_HEIGHT is the maximum pixel ratio of the serial port device.
[0033] On the basis of the above-mentioned embodiments, further, according to the second target byte and the target static array, determining a target touch event, comprises:
[0034] Obtaining historical touch state information;
[0035] Reading current touch state information from the second target byte of the target static array;
[0036] Comparing the historical touch state information and the current touch state information to determine the target touch event.
[0037] On the basis of the above-mentioned embodiments, further, according to the touch position information and the touch state information, generating a touch event, comprises:
[0038] create a touch event object, the touch event object comprising a touch position object and a touch event object;
[0039] set the touch position object as the target touch position;
[0040] set the touch event object as the target touch event.
[0041] The application has the beneficial effect that the serial port single-point touch processing method provided by the application first creates a serial port object corresponding to a preset single-point touch object, and reads serial port data comprising touch position information and touch state information by using the serial port object. Then, the serial port data is parsed to obtain a target touch position and a target touch event. The target touch position and the target touch event are used to generate a touch event, and the touch event is sent to an event processing object to execute the touch event.
[0042] In summary, the method can create a serial port object corresponding to a preset single-point touch object, and adaptively generate a touch event corresponding to the preset single-point touch object based on the serial port object, thereby providing a serial port single-point touch function for QT development application software under the Kylin system of China Star, to solve the problem that a touch device is not compatible with the Kylin system of China Star. BRIEF DESCRIPTION OF DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0044] Figure 1 A flowchart of a serial port single-point touch processing method provided by an embodiment of the application;
[0045] Figure 2 A flowchart of a serial port single-point touch processing method provided by another embodiment of the application.
[0046] Figure 3 A computer device hardware structure schematic diagram provided by an embodiment of the application. DETAILED DESCRIPTION
[0047] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0048] Figure 1 A flowchart of a serial port single-point touch processing method provided by the present application is shown in Figure 1 The serial port single-point touch processing method provided by the present application comprises the following steps.
[0049] S1, obtaining serial port data read by a pre-created serial port class object; wherein the serial port class object corresponds to a preset single-point touch class object; the serial port data comprises touch position information and touch state information;
[0050] Specifically, before performing step S1 of the present application, a QT development environment under the KingKong system needs to be configured. First, install the KingKong system on a PC, and the adaptive version is 5.0; install a development kit QT; deploy a compilation environment for running QT under the KingKong system, including installing gmake and a g++ compiler. Then, establish a QT project based on a widget, and the project type can be adjusted according to development requirements. Next, add a single-point touch class object, which is a window for implementing a single-point touch class, and can inherit a control class or be adjusted to other classes according to development requirements. Refer to the QT version to install a serial port class component. The serial port class object below the Qt5.0 version can refer to the serial port source code above the Qt5.0 version, and the source code is installed in the qtcreator compiler in a component manner. Then, create a serial port class object in a constructor of the preset single-point touch class object, bind a serial port data receiving signal quantity readyRead and a receiving serial port data slot function recvTsData, and initialize the serial port class object serialObj in the constructor of the preset single-point touch class object. The specific steps are as follows: (1) set a serial port name; (2) use an open function to open a serial port device, and set the serial port device to be readable and writable; (3) set a baud rate, a data bit, a parity bit, a stop bit, flow control, etc.; (4) set a data receiving buffer size, and initialize.
[0051] Then, the serial port class object receives serial port data recvTsData input by the serial port device, a read function of the serial port class object serialObj reads the serial port data, each time a fixed length specified by a protocol is read, and the read data is stored in a data receiving buffer buffer, and the preset single-point touch class object obtains the serial port data from the data receiving buffer buffer. The serial port device can be a touch screen device or other touch class device, and can be set and adjusted according to actual conditions, which is not limited here. In addition, the serial port data includes touch position information and touch state information, wherein the touch position information can include a position in a preset coordinate system, and the touch state information can include "press down" (PEN_DOWN) and "pop up" (PEN_UP).
[0052] S2, analyze the serial port data to obtain a target touch position and a target touch event;
[0053] Specifically, the preset single-point touch class stores the serial port data in a static circular array; according to the serial port data and the static circular array, a target static array is obtained; according to the storage protocol of the serial port data and the target static array, the target touch position and the target touch event are obtained. It should be noted that before the serial port data is analyzed, it is necessary to determine whether the current serial port device (for example, a touch screen) type meets the protocol specification, if it meets, the serial port data is analyzed, otherwise an error is reported and the program is exited.
[0054] S3, generating a touch event according to the target touch position and the target touch event;
[0055] Specifically, the preset single-point touch class object creates a touch event object, the touch event object includes a touch position object and a touch event object; the touch position object is set as the target touch position; and the touch event object is set as the target touch event.
[0056] S4, sending the touch event to an event processing object, so that the event processing object executes the touch event.
[0057] Specifically, the touch event is sent to the event processing object, so that the event processing object executes the touch event. The event processing object can be a Qt event processing center or other event processing object, and can be set and adjusted according to actual conditions, which is not limited here.
[0058] The serial port single-point touch processing method provided by the application first creates a serial port class object corresponding to a preset single-point touch class object, and reads serial port data including touch position information and touch state information by using the serial port class object. Then, the serial port data is parsed to obtain a target touch position and a target touch event; the target touch position and the target touch event are used to generate a touch event, and the touch event is sent to an event processing object to execute the touch event. The method can create a serial port class object corresponding to a preset single-point touch class object, and adaptively generate a touch event corresponding to the preset single-point touch class object based on the serial port object, to provide a serial port single-point touch function for QT development application software under the Kylin system of Neusoft, and solve the problem that a touch device is not adapted to the Kylin system of Neusoft.
[0059] Further, before step S2 is performed, the method further includes:
[0060] S1', determining whether the data length of the serial port data is greater than a first preset data length, if yes, step S2 is performed; otherwise, step S1 is returned to be executed.
[0061] Specifically, under normal circumstances, the preset single-point touch class object continuously obtains serial port data read by the serial port class object, if it is determined that the data length of the serial port data is greater than the first preset data length, the next step S2 is performed, that is, the serial port data is parsed, otherwise, it is considered that the serial port data is incomplete or incorrect, and step S1 is returned to be executed to continue to obtain serial port data. It can be understood that the first preset data length can be set to 0, and correspondingly, the data length of the serial port data is greater than 0, it is determined that the serial port data is not empty, otherwise, it is considered that the serial port data is empty. Of course, the first preset data length can also be set and adjusted according to actual conditions, which is not limited here.
[0062] Further, on the basis of the above embodiment, the parsing of the serial port data includes: storing the serial port data in a static circular array; and obtaining a target static array according to the serial port data and the static circular array.
[0063] Specifically, the single-point touch class object stores the serial port data in a static circular array; and then obtains a target static array according to the data length of the serial port data and the maximum data length of the static circular array. It can be understood that the target static array is a static array that stores complete serial port data including the target touch position and information corresponding to the target touch position, and the target static array can also store other information, which can be set and adjusted according to actual conditions, which is not limited here.
[0064] On the basis of the above embodiment, further, the obtaining the target static array according to the serial port data and the static cyclic array comprises:
[0065] According to the data length of the serial port data and the maximum data length of the static cyclic array, L1=(L0+1) / L m calculating a first receiving length; wherein, L1 is the first receiving length, L0 is the data length of the serial port data, and L m is the maximum data length of the static cyclic array;
[0066] Specifically, the single-point touch object calculates a first receiving length according to the data length of the serial port data and the maximum data length of the static cyclic array, L1=(L0+1) / L m calculating a first receiving length; wherein, L1 is the first receiving length, L0 is the data length of the serial port data, and L m is the maximum data length of the static cyclic array. That is, the single-point touch object performs a remainder operation on the data length of the serial port data to obtain the first receiving length.
[0067] If it is judged that the first receiving length is not less than a second preset data length, the frame header position information of the serial port data in the static cyclic array is obtained, and a first static array is obtained according to the frame header position information;
[0068] Specifically, if the single-point touch object judges that the first receiving length is not less than a second preset data length, the frame header position information of the serial port data in the static cyclic array is obtained, and the error data located in front of the frame header is filtered according to the frame header position information to obtain a first static array. The second preset data length is the storage protocol length of the serial port device (for example, a touch screen). It can be understood that if the single-point touch object judges that the first receiving length is less than the second preset data length, it is determined that the serial port data is incomplete, and then step S1 is returned to continue to obtain serial port data. In addition, if the single-point touch object judges that the first receiving length is not less than the second preset data length, but the frame header position information cannot be obtained, the last byte content of the static cyclic array is assigned to the first byte of the static cyclic array, and step S1 is returned to continue to obtain serial port data.
[0069] calculating a second receiving length according to L2=L1-N; wherein, L2 is the second receiving length, L1 is the first receiving length, and N is the byte number corresponding to the frame header position of the serial port data in the static cyclic array;
[0070] If it is judged that the second receiving length is still not less than the second preset data length, and the frame tail information and the checksum of the first static array are correct, the first static array is taken as the target static array.
[0071] Specifically, if the single-point touch object judges that the second receiving length L2 is still not less than the second preset data length, it judges whether the frame tail information and the checksum of the first static array are correct. If the frame tail information of the first static array can be obtained and the checksum calculated according to the frame header information and the frame tail information is correct, it is determined that the first static array includes complete serial port data conforming to the storage protocol of the serial port device, and the first static array is taken as the target static array. If the frame tail information of the first static array cannot be obtained, it is determined that the first static array includes incomplete serial port data. Or, after the frame tail information of the first static array is obtained, the checksum calculated according to the frame header information and the frame tail information is incorrect, it is determined that the serial port data included in the first static array does not conform to the storage protocol of the serial port device, the identifier corresponding to "reacquire frame header" is set to 1, and serial port data is continuously acquired. The frame header information is reacquired in the subsequent acquired serial port data, until complete serial port data conforming to the storage protocol of the serial port device is acquired. It can be understood that if the single-point touch object judges that the second receiving length L2 is less than the second preset data length, it is determined that the serial port data with the second receiving length L2 obtained after error data filtering is incomplete, and the method returns to step S1 to continue to acquire the serial port data.
[0072] Further, the method further comprises:
[0073] The data before the frame header position of the serial port data in the static circular array is cleared, and the data after the frame header position of the serial port data in the static circular array is sequentially shifted to the corresponding byte position of the static circular array starting from the first byte.
[0074] Specifically, the single-point touch object clears the data before the frame header position of the serial port data in the static circular array, and sequentially shifts the data after the frame header position of the serial port data in the static circular array to the corresponding byte position of the static circular array starting from the first byte, that is, the error data located in front of the frame header is filtered, and the obtained array is taken as the first static array.
[0075] Further, the method further comprises:
[0076] If it is judged that the first receiving length is not less than the second preset data length, but the frame header position information of the serial port data in the static circular array cannot be obtained, the content of the last byte in which the serial port data is stored in the static circular array is stored in the first byte of the static circular array, L1 is set to 1, and the step S1 is returned to continue to acquire serial port data.
[0077] Specifically, if it is judged that the first receiving length is not less than the second preset data length, but the frame header position information of the serial port data in the static circular array cannot be obtained, it is determined that the serial port data does not include complete serial port data conforming to the storage protocol of the serial port device, the content of the last byte in which the serial port data is stored in the static circular array is stored in the first byte of the static circular array, L1 is set to 1, and the step S1 is returned to continue to acquire serial port data, and the serial port data stored in the first byte of the static circular array is taken as new serial port data together with the subsequently acquired serial port data.
[0078] Further, the obtaining of the target touch position and the target touch event includes:
[0079] According to the storage protocol of the serial port data, a first target byte and a second target byte are determined, wherein the first target byte stores the touch position information, and the second target byte stores the touch state information;
[0080] According to the first target byte and the target static array, a target touch position is determined.
[0081] According to the second target byte and the target static array, a target touch event is determined.
[0082] Specifically, according to the storage protocol of the serial port data, it is specified that in a complete serial port data, a touch position information frame and a touch state information frame are included, for example, the m1th frame from the frame header position stores touch position information, that is, the m1th frame is a touch position information frame; the m2th frame from the frame header position stores touch state information, that is, the m2th frame is a touch state information frame, then, the touch position information frame and the touch state information frame in the target static array are found from the target static array, that is, the first target byte and the second target byte, respectively, then the touch position (x0, y0) is read from the first target byte of the target static array, the current touch state information is read from the second target byte of the target static array, the historical touch state information and the current touch state information are compared, and the target touch event is determined. The touch state information includes “pressing” and “lifting”.
[0083] On the basis of the above-mentioned embodiments, further, the target touch position is determined according to the first target byte and the target static array, comprising:
[0084] According to the formula:
[0085] X=(TS_HOR_PIXELS*x0) / MAX_PIX_WIDTH;
[0086] Y=(TS_VER_PIXELS*ts_info.y0) / MAX_PIX_HEIGHT
[0087] The target touch position is calculated, wherein (x0, y0) is the touch position read from the first target byte of the target static array, (X, Y) is the target touch position, TS_HOR_PIXELS*TS_VER_PIXELS is the pixel ratio specified by the serial device protocol, and MAX_PIX_WIDTH*MAX_PIX_HEIGHT is the maximum pixel ratio of the serial device.
[0088] Specifically, the touch position (x0, y0) read from the first target byte of the target static array is converted into the actual touch position (X, Y) according to the actual pixel ratio according to the above-mentioned formula, and the actual touch position (X, Y) is the target touch position. Wherein, the serial device can be a touch screen.
[0089] On the basis of the above-mentioned embodiments, further, the target touch position is determined according to the first target byte and the target static array, comprising:
[0090] Obtaining historical touch state information;
[0091] Reading the current touch state information from the second target byte of the target static array;
[0092] Comparing the historical touch state information and the current touch state information to determine the target touch event.
[0093] Specifically, the preset single-point touch object acquires historical touch state information, and reads current touch state information from a second target byte of the target static array. Then, it is firstly judged whether the historical touch state information is empty. If it is empty, it is determined that the serial port device has not input touch action before, and the current touch state information is stored as the historical touch state information, and serial port data is continuously acquired to determine the next touch state information. If the historical touch state information is not empty, the historical touch state information and the current touch state information are compared to determine the target touch event: (1) if the current touch state is "press down" (PEN_DOWN) and the historical touch state is "click", it is determined that the target touch event is "pressed" (pressed); (2) if the current touch state is "press down" (PEN_DOWN) and the historical touch state is "press down" (PEN_DOWN), it is determined that the target touch event is "move" (move); (3) if the current touch state is "pop up" (PEN_UP) and the historical touch state is "press down" (PEN_DOWN), it is determined that the target touch event is "released" (released).
[0094] On the basis of the above-mentioned embodiments, the generating touch event according to the touch position information and the touch state information comprises:
[0095] Creating a touch event object, the touch event object comprising a touch position object and a touch event object;
[0096] Setting the touch position object as the target touch position;
[0097] Setting the touch event object as the target touch event.
[0098] Specifically, a Qt touch position object is created, and a pixel point of the touch position object is set as (X, Y). A touch event class is created in a constructor of the single-point touch class, and a signal amount and a slot function of the touch event are bound. A corresponding touch event object of the touch event class is set as the target touch event, such as "pressed", "move" or "released". A touch event object comprising the target touch position and the target touch event is sent to a Qt event processing object, and the Qt event processing object executes the touch event.
[0099] The serial port single-point touch processing method provided by the application first creates a serial port object corresponding to a preset single-point touch object, and reads serial port data including touch position information and touch state information through the serial port object. Then, the serial port data is parsed to obtain a target touch position and a target touch event. The target touch position and the target touch event are used to generate a touch event, and the touch event is sent to an event processing object to execute the touch event. The method can create a serial port object corresponding to a preset single-point touch object, and adaptively generate a touch event corresponding to the preset single-point touch object based on the serial port object, to provide a serial port single-point touch function for QT development application software under the Kylin system of Neusoft, and solve the problem that a touch device is not compatible with the Kylin system of Neusoft.
[0100] Figure 2 A flowchart of a serial port single-point touch processing method provided by another embodiment of the application is shown in the following figure, and the serial port single-point touch processing method provided by the application is described in detail as follows. Figure 2 The serial port single-point touch processing method provided by the application is described in detail as follows. Figure 2 The serial port single-point touch processing method provided by the application includes the following steps:
[0101] S1, obtaining serial port data read by a pre-created serial port object; wherein the serial port object corresponds to a preset single-point touch object; and then executing step S1';
[0102] S1', judging whether the data length of the serial port data is greater than a first preset data length; if yes, executing step S201, otherwise returning to execute step S1;
[0103] The first preset data length can be set to 0, or can be set and adjusted according to actual conditions, which is not limited here.
[0104] S201, storing the serial port data in a static circular array according to L1=(L0+1) / L m calculating a first receiving length; wherein L1 is the first receiving length, L0 is the data length of the serial port data, and L m is the maximum data length of the static circular array; and then executing step S202;
[0105] S202, judging whether the first receiving length is not less than a second preset data length; if yes, executing step S203; otherwise returning to execute step S1;
[0106] The second preset data length is the storage protocol length of the serial port device (for example, a touch screen).
[0107] S203, judging whether the frame header position information can be acquired; if yes, executing step S204; otherwise, executing step S205;
[0108] S204, acquiring the first static array according to the frame header position information; then executing step S206;
[0109] Specifically, the preset single-point touch object clears the data of the serial port data before the frame header position in the static circular array, and sequentially shifts the data of the serial port data at the frame header position and after the frame header position in the static circular array to the corresponding byte positions of the static circular array starting from the first byte, i.e., the error data located in front of the frame header is filtered, and then the obtained array is taken as the first static array.
[0110] S205, assigning the last byte content of the static circular array to the first byte of the static circular array, and then returning to execute step S1;
[0111] S206, calculating the second receiving length according to L2=L1-N; wherein L2 is the second receiving length, L1 is the first receiving length, and N is the byte number corresponding to the frame header position of the serial port data in the static circular array; then executing step S207;
[0112] S207, judging whether the second receiving length is still not less than the second preset data length; if yes, executing step S208; otherwise, returning to execute step S1;
[0113] The second preset data length is the storage protocol length of the serial port device (for example, a touch screen).
[0114] S208, judging whether the frame tail information and the checksum of the first static array are both correct; if yes, executing step S209; otherwise, executing step S210;
[0115] S209, taking the first static array as the target static array; then executing step S211;
[0116] S210, setting the identification corresponding to "reacquiring the frame header" to 1, and then returning to execute step S1;
[0117] S211, determining the first target byte and the second target byte according to the storage protocol of the serial port data, determining the target touch position according to the first target byte and the target static array, and determining the target touch event according to the second target byte and the target static array; then executing step S301;
[0118] Specifically, the touch position information frame and the touch state information frame whose stored serial port data are searched from the target static array correspond to the bytes in the target static array, that is, the first target byte and the second target byte, respectively, then the touch position (x0, y0) is read from the first target byte of the target static array, and the target touch position (X, Y) is calculated according to the formula:
[0119] X = (TS_HOR_PIXELS * x0) / MAX_PIX_WIDTH;
[0120] Y = (TS_VER_PIXELS * ts_info.y0) / MAX_PIX_HEIGHT
[0121] wherein (x0, y0) is the touch position read from the first target byte of the target static array, (X, Y) is the target touch position, TS_HOR_PIXELS * TS_VER_PIXELS is the pixel ratio specified by the serial port device protocol, and MAX_PIX_WIDTH * MAX_PIX_HEIGHT is the maximum pixel ratio of the serial port device. Moreover, the current touch state information is read from the second target byte of the target static array, the historical touch state information is compared with the current touch state information, and the target touch event is determined.
[0122] S301, a touch event object is created, the touch event object including a touch position object and a touch event object; then step S302 is executed;
[0123] S302, the touch position object is set as the target touch position, and the touch event object is set as the target touch event; then step S4 is executed;
[0124] S4, the touch event is sent to an event processing object, and the event processing object executes the touch event.
[0125] The serial port single-point touch processing method provided in the application first creates a serial port object corresponding to a preset single-point touch class object, and reads serial port data including touch position information and touch state information by using the serial port object. Then, the serial port data is parsed to obtain a target touch position and a target touch event, and a touch event is generated by using the target touch position and the target touch event, and the touch event is sent to an event processing object to execute the touch event. The method can create a serial port object corresponding to a preset single-point touch class object, and adaptively generate a touch event corresponding to the preset single-point touch class object based on the serial port object, thereby providing a serial port single-point touch function for QT development application software under the Kylin system of China Star, to solve the problem that a touch device is not adapted to the Kylin system of China Star.
[0126] The application also provides a computer device, comprising: a memory for storing executable program codes; one or more processors for reading the executable program codes stored in the memory to execute the serial single-point touch processing method as described above. Please refer to Figure 3 The computer device hardware structure diagram is given.
[0127] The computer system comprises a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 302 or programs loaded from a storage section into a random access memory (RAM) 303. In the RAM 303, various programs and data required for system operation are also stored. The CPU 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0128] The following components are connected to the I / O interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface 305 as necessary. A removable medium 311 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 310 as necessary, so that a computer program read therefrom is installed in the storage section 308 as necessary.
[0129] In particular, the processes described above in the serial single-point touch processing method can be implemented as a computer software program according to embodiments of the present application. For example, the embodiments of the present application relating to the serial single-point touch processing method include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program codes for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication section, and / or installed from a removable medium. When the computer program is executed by the central processing unit (CPU) 301, the above-mentioned functions defined in the system of the present application are performed.
[0130] It should be noted that the computer-readable medium shown in the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or component. The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0131] The flowcharts and block diagrams in the drawings illustrate the possible implementation architecture, function and operation of the serial port single-point touch processing method, device and computer program product according to the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment, or a part of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different order than that shown in the drawings. For example, two blocks represented in succession can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the function involved. It should also be noted that each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0132] The units described in the embodiments of the present application can be implemented by software, or by hardware, or by a combination of software and hardware. The units described can be located in a single processor, or distributed over several processors. In some cases, the names of the units described are not intended to limit the scope of the units themselves. The units described can be located in a processor, for example, a processor can be described as including a first generating module, an obtaining module, a searching module, a second generating module, and a merging module. In some cases, the names of the units described are not intended to limit the scope of the units themselves.
[0133] As another aspect, the present application also provides a computer readable medium, which can be included in the electronic device described in the above embodiments, or can exist independently without being assembled into the electronic device. The computer readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to implement the serial port single-point touch processing method described in the above embodiments.
[0134] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, such division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into several modules or units.
[0135] In addition, although the steps of the method of the present disclosure are described in a particular order in the accompanying drawings, this does not require or imply that the steps must be performed in this particular order, or that all of the steps shown must be performed to achieve the desired result. Additionally or alternatively, some steps can be omitted, several steps can be combined into one step, one step can be divided into several steps, etc.
[0136] From the above description of the embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware.
[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A serial single-point touch processing method, characterized in that, The method comprises the following steps: S1, obtaining serial port data read by a pre-created serial port class object, wherein the serial port class object corresponds to a preset single-point touch class object, and the serial port data comprises touch position information and touch state information; S2, analyzing the serial port data to obtain a target touch position and a target touch event; S3, generating a touch event according to the target touch position and the target touch event; S4, sending the touch event to an event processing object, so that the event processing object executes the touch event; The analyzing the serial port data comprises the following steps: storing the serial port data in a static circular array; obtaining a target static array according to the serial port data and the static circular array; obtaining a target static array according to the serial port data and the static circular array, comprising the following steps: According to the data length of the serial port data and the maximum data length of the static circular array, L1=(L0+1) / L m Calculate a first receiving length; wherein, L1 is the first receiving length, L0 is the data length of the serial port data, L m is the maximum data length of the static circular array; if it is judged that the first receiving length is not less than a second preset data length, obtaining frame header position information of the serial port data in the static circular array, and obtaining a first static array according to the frame header position information; calculating a second receiving length according to L2=L1-N, wherein L2 is the second receiving length, L1 is the first receiving length, and N is a byte number corresponding to the frame header position of the serial port data in the static circular array; if it is judged that the second receiving length is still not less than the second preset data length, and frame tail information and a checksum of the first static array are correct, taking the first static array as the target static array.
2. The method of claim 1, wherein, Before step S2 is performed, the method further comprises the following step: S1', judging whether a data length of the serial port data is greater than a first preset data length, if yes, performing step S2; otherwise, returning to perform step S1.
3. The method of claim 1, wherein, The obtaining a first static array according to the frame header position information comprises the following steps: sequentially shifting the frame header position of the serial port data in the static circular array and data after the frame header position to corresponding byte positions of the static circular array starting from a first byte.
4. The method of claim 1, wherein, The method further comprises the following steps: if it is judged that the first receiving length is not less than the second preset data length, but the frame header position information of the serial port data in the static circular array cannot be obtained, storing content of a last byte in the static circular array in a first byte of the static circular array, and setting L1=1, and returning to step S1.
5. The method of claim 1, wherein, The obtaining a target touch position and a target touch event comprises the following steps: determining a first target byte and a second target byte according to a storage protocol of the serial port data, wherein the first target byte stores the touch position information, and the second target byte stores the touch state information; determining a target touch position according to the first target byte and the target static array; determining a target touch event according to the second target byte and the target static array. The determining a target touch position according to the first target byte and the target static array comprises the following steps:
6. The method of claim 5, wherein, according to a formula: X= (TS_HOR_PIXELS*x0) / MAX_PIX_WIDTH; Y = (TS_VER_PIXELS * ts_info.y0) / MAX_PIX_HEIGHT calculating the target touch position, wherein (x0, y0) is a touch position read from a first target byte of the target static array, (X, Y) is the target touch position, TS_HOR_PIXELS * TS_VER_PIXELS is a pixel ratio specified by a serial device protocol, and MAX_PIX_WIDTH * MAX_PIX_HEIGHT is a maximum pixel ratio of an actual pixel of the serial device.
7. The method of claim 6, wherein, determining a target touch event according to the second target byte and the target static array, comprising: obtaining historical touch state information; reading current touch state information from a second target byte of the target static array; comparing the historical touch state information and the current touch state information to determine the target touch event.
8. The method of claim 7, wherein, generating a touch event according to the touch position information and the touch state information, comprising: creating a touch event object, the touch event object including a touch position object and a touch event object; setting the touch position object as the target touch position; setting the touch event object as the target touch event.
Citation Information
Patent Citations
Touch screen control system and touch screen control method
CN102226884A
Implementation method for multipoint touch under "channel" system
CN106896956A