Patent Description:
This application relates to the field of terminal technologies, and in particular, to a method for calculating position information in a touchscreen and an electronic device.

Currently, electronic devices have become a part of people's work and life. An electronic device usually includes a touchscreen. The electronic device can receive a trigger operation performed on the touchscreen by a user, and perform a corresponding function based on a triggered position.

The electronic device can usually collect source data of the touchscreen by using a touch chip. When the touchscreen is triggered, a micro control unit MCU on the touch chip can calculate, based on the collected source data, coordinates of a position at which the user triggers the touchscreen. Then, a central processing unit CPU can read the calculated coordinates by using an I2C bus. In this way, the CPU performs a function corresponding to the coordinates.

It can be learned that the coordinates of the position at which the user triggers the touchscreen are calculated in the MCU in the touch chip, but a computing speed is low because a clock rate of the MCU is <NUM>~<NUM>. As a result, there is a high delay when the electronic device performs the function corresponding to the trigger operation based on the trigger operation performed by the user.

<CIT> describes variable rate display interfaces. A high-speed reverse data transfer is enabled over plural lanes of a display serial interface (DSI) bus during blanking periods. Further increases in bandwidth of each high-speed reverse data transfer may be achieved by increasing DSI clock speed during the blanking periods. By increasing the reverse bandwidth over existing pins in the DSI bus, more data may be transferred to the host, including raw touch/stylus data rather than processed data. The raw data may then be processed by the host's relatively powerful processors.

<CIT> describes a display host controller to control a display device coupled to the processor; a touch host controller to control a touch device coupled to the processor; a traffic controller to multiplex first information from the display host controller and second information from the touch host controller; and a physical unit circuit to communicate the first information and the second information via a plurality of first data lanes of an interconnect to couple to at least one device controller.

The present invention is described by the features disclosed in the independent claims. Additional embodiments are defined in the dependent claims. This application provides a method for calculating position information in a touchscreen and an electronic device, to shorten a delay of the electronic device in performing a function corresponding to a trigger operation based on the trigger operation performed by a user.

A method for calculating position information in a touchscreen, which is applied to an electronic device, is provided in accordance with claim <NUM>. The electronic device includes a touchscreen, a touch chip, and a central processing unit CPU. The method according to this application includes: The touch chip samples source data generated by a trigger operation in the touchscreen, when the touchscreen receives the trigger operation. The touch chip transmits the source data to the CPU by using a high-speed serial bus, where the source data is used to indicate capacitance of the touch chip. The CPU calculates position information of the trigger operation in the touchscreen based on the source data.

In the method for calculating position information in a touchscreen according to this embodiment of this application, because the touch chip transmits, by using the high-speed serial bus, the source data generated by the trigger operation, and the high-speed serial bus has a higher transfer rate, first duration t1 for the touch chip to transmit the source data generated by the trigger operation can be shorter. Further, because the position information of the trigger operation in the touchscreen is calculated in the CPU, and a computing speed of the CPU is also higher due to a higher clock rate of the CPU, second duration t2 for the CPU to calculate coordinates of a position at which the user triggers the touchscreen can also be shorter. In this way, a sum of the first duration t1 and the second duration t2 can be smaller.

In this way, a delay t3 from a time when the touchscreen of the electronic device receives the trigger operation to a time when a third-party application performs a function corresponding to a control at the position information includes the first duration t1 for the touch chip to transmit the source data to the CPU and the second duration t2 for the CPU to calculate the position information of the trigger operation in the touchscreen. In this way, when the sum of the first duration t1 and the second duration t2 is smaller, the delay t3 from the time when the touchscreen of the electronic device receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information is shortened. In this way, user experience can be improved.

The electronic device further includes a bus controller and a direct memory access DMA, and that the touch chip transmits the source data to the CPU by using a high-speed serial bus includes: The touch chip controls the CPU to wake up a data transfer thread. The CPU controls the bus controller to add a DMA flag. The flag is used to indicate that the DMA is occupied by the bus controller. The bus controller copies the source data from the touch chip to the DMA by using the high-speed serial bus. The bus controller controls the CPU to extract the source data from the DMA.

In a possible implementation, a priority of instructing to wake up the preset data transfer thread preset in the CPU is higher than that of another to-be-processed thread in the CPU, and a priority of a thread that is preset in the bus controller and that is used to instruct to occupy the DMA is higher than that of another to-be-processed thread in the bus controller.

In this way, the first duration t1 for the touch chip to transmit the source data generated by the trigger operation can be further shortened. The delay t3 from the time when the touchscreen of the electronic device receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information is shortened.

After the CPU controls the bus controller to add a DMA flag, the method according to this application further includes: controlling the data transfer thread to start sleeping.

That the bus controller controls the CPU to extract the source data from the DMA includes: The bus controller controls the CPU to wake up the data transfer thread; and extracts the source data from the DMA after the CPU wakes up the data transfer thread.

In this way, the CPU may also process another to-be-processed thread during sleep of the data transfer thread.

In a possible implementation, that the touch chip samples source data generated by a trigger operation in the touchscreen includes: The touch chip transmits a sampling pulse sequence to the touchscreen based on a preset sampling period, to sample the source data generated by the trigger operation in the touchscreen. Transmission, by the touch chip, of the source data sampled by an Nth group of sampling pulse sequence and transmission of a (N+<NUM>)th group of sampling pulse sequence by the touch chip are simultaneously performed, where N is an integer greater than <NUM>, and the sampling period is less than a preset duration threshold.

It is assumed that fourth duration for which the pulse sequence lasts is t4, and fifth duration between every two groups of sampling pulse sequences is t5. The fifth duration t5 is equal to a difference between a sampling period T1 and the fourth duration t4 for which the pulse sequence lasts. It can be understood that the fifth duration t5 can be shorter when the preset sampling period is less than the preset duration threshold and the fourth duration t4 for which the pulse sequence lasts is unchanged. In this way, even if a time when the user performs the trigger operation on the touchscreen is between two groups of sampling pulse sequences, the delay from the sampling of the Nth group of sampling pulse sequence to the trigger operation on the touchscreen by the user is still shortened. Because the fifth duration t5 is a part of the foregoing duration t3, when the fifth duration t5 is shorter, the delay t3 from the time when the touchscreen receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information can be further shortened.

In a possible implementation, the preset duration threshold is less than or equal to <NUM>.

In a possible implementation, that the touch chip samples source data generated by a trigger operation in the touchscreen includes: The touch chip transmits a sampling pulse sequence to the touchscreen based on a preset sampling period, to sample the source data generated by the trigger operation in the touchscreen. A quantity of sampling pulses in the sampling pulse sequence is less than <NUM>.

When the quantity of sampling pulses in the sampling pulse sequence is less than <NUM>, the fourth duration t4 for which the pulse sequence lasts can be shorter (that is, the sampling duration is further shortened). When the fourth duration t4 is shorter, the delay t3 from the time when the touchscreen receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information can be further shortened (that is, the sampling delay is shortened).

In a possible implementation, a sampling voltage of the sampling pulses is greater than <NUM> V.

In this way, reliability of the sampled source data can be improved.

In a possible implementation, the method according to this application further includes: The CPU filters the obtained source data by using a filtering algorithm.

In this way, reliability of the source data can be improved.

In a possible implementation, the high-speed serial bus is a serial peripheral interface SPI bus.

When the SPI bus is in a high-speed mode, the data transfer rate can reach <NUM> Mbps. It can be learned that SPI bus has a higher data transfer rate. Then, the first duration t1 for the CPU to read the source data from the touch chip or the touch chip to write the source data to the CPU can be shorter.

In a possible implementation, after the CPU calculates position information of the trigger operation in the touchscreen based on the source data, the method according to this application further includes: The CPU transparently transmits the position information to a third-party application, so that the third-party application performs a function corresponding to a control at the position information.

Further, an electronic device is provided in accordance with claim <NUM>. The device includes a touchscreen, a touch chip, and a central processing unit CPU, where when the touchscreen receives a trigger operation, the electronic device performs the method for calculating position information in a touchscreen according to the first aspect of this application.

It should be understood that the technical solution of the second aspect of this application correspond to the technical solution of the first aspect of this application, and beneficial effects achieved by the aspects and corresponding feasible implementations are similar. Details are not described again.

To clearly describe the technical solutions in embodiments of this application, in embodiments of this application, words such as "first" and "second" are used to distinguish between same items or similar items with basically the same functions and effects. For example, a first value and a second value are merely used to distinguish between different values, but not limit a sequence thereof. A person skilled in the art may understand that words such as "first" and "second" do not limit a quantity or an execution order, and the words such as "first" and "second" do not necessarily indicate a difference.

It should be noted that, in this application, words such as "for example" or "such as" are used to indicate an example, illustration, or description. Any embodiment or design solution described as "for example" or "such as" in this application should not be construed as being preferred or advantageous over other embodiments or design solutions. To be precise, the use of the words such as "example" or "for example" is intended to present a related concept in a specific manner.

In this application, "at least one" means one or more, and "a plurality of" means two or more. "And/or" describes an association relationship between associated objects, and indicates that three relationships may exist. For example, A and/or B may indicate the following: Only A exists, both A and B exist, and only B exists, where A and/or B may indicate a singular or plural form. The character "/" generally indicates an "or" relationship between associated objects. "At least one of the following" or a similar expression thereof indicates any combination of these items, including a single item or any combination of a plurality of items. For example, at least one of a, b, or c may represent a, b, c, a and b, a and c, b and c, or a, b, and c, where a, b, and c may be singular or plural.

Currently, electronic devices have become a part of people's work and life. An electronic device usually includes a touchscreen. The electronic device can receive a trigger operation performed on the touchscreen by a user, and perform a corresponding function based on a triggered position. It can be understood that a delay of the electronic device in performing the function corresponding to the trigger operation based on the trigger operation performed by the user includes first duration t1 for a touch chip to transmit data to a CPU and second duration t2 for calculating position information.

For example, when the touchscreen of the electronic device receives a touch operation of sliding up by the user on a WeChat® interface shown in a in <FIG>, content displayed on the interface of the touchscreen changes to an interface shown in b in <FIG>. When the user triggers a video control <NUM> on the interface shown in b in <FIG>, as shown in <FIG>, the touch chip of the electronic device samples, by using a <NUM> V sampling pulse sequence, source data generated by a trigger operation in the touchscreen. Then, an MCU of the touch chip of the electronic device calculates position information of the trigger operation in the touchscreen based on the source data. Because a computing speed is slow because a clock rate of the MCU of the touch chip is lower, the second duration t2 for calculating the position information of the trigger operation in the touchscreen may be longer. For example, the second duration t2 is <NUM>. In this way, the touch chip transmits the position information to the CPU of the electronic device by using an I2C bus, where the first duration for the touch chip to transmit the position information is t1 (for example, the first duration t1 may be <NUM>). Then, based on the position information, the CPU controls the touchscreen to switch to an interface shown in c in <FIG> to play a video.

Because the second duration t2 for calculating the position information of the trigger operation in the touchscreen is longer, the sum of the second duration t2 and the first duration t1 may be larger. For example, the sum of the second duration t2 and the first duration t1 may be <NUM>. In this way, finally, the delay for the CPU to control, based on the position information, the touchscreen to switch to an interface shown in c in <FIG> is longer.

In view of this problem, this application provides a method for calculating position information in a touchscreen, where a touch chip of an electronic device samples source data generated by a trigger operation in the touchscreen; and the touch chip of the electronic device transmits the source data to a CPU by using a serial peripheral interface high-speed serial bus. The source data is used to indicate capacitance of the touch chip. The CPU of the electronic device calculates position information of the trigger operation in the touchscreen based on the source data. Because the touch chip transmits, by using the high-speed serial bus, the source data generated by the trigger operation, and a transfer rate of the high-speed serial bus in a high-speed mode is greater than a preset rate threshold, first duration t1 for the touch chip to transmit the source data generated by the trigger operation can be shorter. Further, because the position information of the trigger operation in the touchscreen is calculated in the CPU, and a computing speed of the CPU is also higher due to a higher clock rate of the CPU, second duration t2 for the CPU to calculate a position at which the user triggers the touchscreen can also be shorter. Then, a sum of the first duration t1 and the second duration t2 is also smaller. In this way, a delay of the electronic device in performing the function corresponding to the trigger operation based on the trigger operation performed by the user is shortened.

It can be understood that the foregoing electronic device may be a terminal (terminal), user equipment (user equipment, UE), a mobile station (mobile station, MS), a mobile terminal (mobile terminal, MT), and the like. The terminal device may be a mobile phone (mobile phone), a smart TV, a wearable device, a tablet computer (pad), a computer having a wireless transmission and reception function, a virtual reality (virtual reality, VR) terminal device, an augmented reality (augmented reality, AR) terminal device, a wireless terminal in industrial control (industrial control), a wireless terminal in self-driving (self-driving), a wireless terminal in remote medical surgery (remote medical surgery), a wireless terminal in smart grid (smart grid), a wireless terminal in transportation safety (transportation safety), a wireless terminal in smart city (smart city), a wireless terminal in smart home (smart home), or the like. Embodiments of this application do not limit a specific technology and a specific device form used for the electronic device.

To help better understand embodiments of this application, the following describes a structure of an electronic device in the embodiments of this application. For example, <FIG> is a schematic diagram of a structure of an electronic device according to an embodiment of this application.

To help better understand embodiments of this application, the following describes a structure of an electronic device in the embodiments of this application. <FIG> is a schematic diagram of a structure of an applicable electronic device according to an embodiment of this application. As shown in <FIG>, the electronic device may include a central processing unit (central processing unit, CPU) <NUM>, an external memory interface <NUM>, an internal memory <NUM>, a universal serial bus (universal serial bus, USB) interface <NUM>, a serial peripheral interface (serial peripheral interface, SPI) bus <NUM>, a charging management module <NUM>, a power management module <NUM>, a battery <NUM>, an antenna <NUM>, an antenna <NUM>, a mobile communication module <NUM>, a wireless communication module <NUM>, an audio module <NUM>, a speaker 170A, a receiver 170B, a microphone 170C, a headset jack 170D, a sensor <NUM>, a key <NUM>, a motor <NUM>, a camera <NUM>, a touchscreen <NUM>, a subscriber identification module (subscriber identification module, SIM) card interface <NUM>, a touch chip <NUM>, and the like. It can be understood that the structure shown in this embodiment does not constitute a specific limitation on the electronic device. In some other embodiments of this application, the electronic device may further include more or fewer components than those shown in the figure, or may combine some components, or may split some components, or may have different component arrangements.

The central processing unit <NUM> may be a nerve center and a command center of the electronic device. The processor may generate an operation control signal based on an instruction operation code and a timing signal, to complete control of instruction fetch and instruction execution. A memory may be disposed in the central processing unit <NUM>, and is configured to store instructions and data. In some embodiments, the memory in the central processing unit <NUM> is a cache. The memory may store instructions or data that is used or repeatedly used by the central processing unit <NUM>. If the central processing unit <NUM> needs to reuse the instruction or the data, the instruction or the data may be directly invoked from the memory. In this case, repeated access is avoided, a waiting time of the central processing unit <NUM> is reduced, and efficiency of the electronic device is improved.

In some embodiments, the central processing unit <NUM> may include one or more interfaces. The interface may include an inter-integrated circuit sound (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver/transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general purpose input/output (general-purpose input/output, GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, and/or a universal serial bus (universal serial bus, USB) interface, an SPI interface, and the like. It can be understood that the interface connection relationship between the modules illustrated in the embodiments of this application is merely an example for description, and does not constitute a limitation on the structure of the electronic device. In some other embodiments of this application, the electronic device may alternatively use an interface connection mode that is different from those in the foregoing embodiments, or use a combination of a plurality of interface connection modes.

A wireless communication function of the electronic device may be implemented by using the antenna <NUM>, the antenna <NUM>, the mobile communication module <NUM>, the wireless communication module <NUM>, a modem processor, a baseband processor, and the like. The antenna <NUM> and the antenna <NUM> are configured to transmit and receive electromagnetic wave signals. Each antenna in the electronic device may be configured to cover one or more communication frequency bands. Different antennas may be further multiplexed to improve antenna utilization. For example, the antenna <NUM> may be multiplexed into a diversity antenna of a wireless local area network. In some other embodiments, the antenna may be used in combination with a tuning switch.

The wireless communication module <NUM> may provide wireless communication solutions applied to the electronic device, including a wireless local area network (wireless local area networks, WLAN), Bluetooth, a global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), NFC, an infrared (infrared, IR) technology, and the like. The wireless communication module <NUM> receives an electromagnetic wave by using the antenna <NUM>, modulates and filters an electromagnetic wave signal, and sends a processed signal to the central processing unit <NUM>. The wireless communication module <NUM> may further receive a to-be-sent signal from the central processing unit <NUM>, perform frequency modulation and amplification on the signal, and convert, by using the antenna <NUM>, the signal into an electromagnetic wave for radiation.

A display function of the electronic device may be implemented by using a GPU, the touchscreen <NUM>, an application processor, and the like. The application processor may include an NPU and a DPU. The GPU is a microprocessor used for image processing, and is connected to the touchscreen <NUM> and the application processor. The GPU is configured to perform mathematical and geometric computation, and is configured to perform graphics rendering. The central processing unit <NUM> may include one or more GPUs, and the one or more GPUs execute instructions to generate or change display information. The NPU is a neural-network (neural-network, NN) computing processor, by referring to a biological neural-network structure. The DPU is also referred to as a display sub-system (Display Sub-System, DSS). The DPU is configured to adjust the color of the touchscreen <NUM>, and the DPU may adjust the color of the touchscreen by using a 3D lookup table (3D look up table, 3D LUT).

The touchscreen <NUM> is configured to display an image, a video, or the like. The touchscreen <NUM> includes a display panel. The display panel may use a liquid crystal touchscreen (liquid crystal display, LCD), an organic light-emitting diode (organic light-emitting diode, OLED), an active-matrix organic light-emitting diode (active-matrix organic light emitting diode, AMOLED), a flex light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (quantum dot light emitting diodes, QLED), and the like. In some embodiments, the electronic device may include one or N touchscreens <NUM>, where N is a positive integer greater than <NUM>. When the touchscreen <NUM> is triggered, capacitance of the touchscreen <NUM> changes, and when the touchscreen <NUM> is triggered at different positions, the capacitance of the touchscreen <NUM> changes differently.

The touch chip <NUM> may periodically transmit a sampling pulse sequence to the touchscreen <NUM>, to collect source data generated in the touchscreen <NUM>. The source data includes voltage signal data or current signal data of the touchscreen <NUM>. The touch chip <NUM> may transmit the voltage signal data or the current signal data to the central processing unit <NUM> by using the SPI bus <NUM>. In addition, an MCU is further integrated in the touch chip <NUM>, where the clock rate of the MCU is <NUM>~<NUM>, and the MCU may be configured to perform processing such as analog-to-digital conversion on signals.

The touch chip <NUM> may transmit the voltage signal data or the current signal data to the central processing unit <NUM> by using the SPI bus. The SPI <NUM> is a high-speed, full-duplex, and synchronous communication bus, and only four wires are occupied on pins of the chip, thereby saving the pins of the chip and space.

The electronic device can implement a photographing function by using an ISP, one or more cameras <NUM>, a video codec, the GPU, one or more touchscreens <NUM>, the application processor, and the like.

The external memory interface <NUM> may be configured to connect to an external memory card, for example, a micro SD card, to expand a storage capacity of the electronic device. The external memory card communicates with the central processing unit <NUM> by using the external memory interface <NUM>, so as to implement a data storage function.

The internal memory <NUM> can be configured to store one or more computer programs, and the one or more computer programs include instructions. The central processing unit <NUM> enables, by running the foregoing instructions stored in the internal memory <NUM>, the electronic device to execute various function applications, data processing, and the like. The internal memory <NUM> may include a program storage area and a data storage area. The program storage area can store an operating system. The program storage area can further store one or more applications (such as a gallery and contacts), and the like. The data storage area can store data (such as photos and contacts) and the like created during use of the electronic device.

The electronic device may implement an audio function by using the audio module <NUM>, the speaker 170A, the receiver 170B, the microphone 170C, an application central processing unit, and the like. The audio function is, for example, music playback and sound recording.

The audio module <NUM> is configured to convert digital audio information into an analog audio signal for outputting, and is further configured to convert an analog audio input into a digital audio signal. The speaker 170A, also referred to as a "loudspeaker", is configured to convert an audio electrical signal into a sound signal. The electronic device may be configured to listen to music or a hands-free call by using the speaker 170A. The receiver 170B is configured to convert an audio electrical signal into a sound signal. When the electronic device receives a call or a voice message, the receiver 170B can be placed near a person's ear to answer the voice. The microphone 170C is configured to convert a sound signal into an electrical signal.

The pressure sensor 180A is configured to sense a pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the touchscreen <NUM>. A gyro sensor 180B may be configured to determine a motion posture of the electronic device. A barometric pressure sensor 180C is used to measure a barometric pressure. A magnetic sensor 180D includes a Hall sensor. An acceleration sensor 180E may detect magnitudes of acceleration rates of the electronic device in various directions (usually on three axes). A distance sensor 180F is configured to measure a distance. An optical proximity sensor <NUM> may include, for example, a light-emitting diode (LED) and an optical detector, for example, a photodiode. An ambient light sensor <NUM> is configured to sense luminance of ambient light. A fingerprint sensor <NUM> is configured to collect a fingerprint. A temperature sensor 180J is configured to detect a temperature. A touch sensor <NUM> is also referred to as a "touch device". The touch sensor <NUM> may be disposed on the touchscreen <NUM>, and the touch sensor <NUM> and the touchscreen <NUM> constitute a touchscreen. A bone conduction sensor <NUM> may obtain a vibration signal.

The key <NUM> includes a start key, a volume key, and the like. The key <NUM> may be a mechanical key, or may be a touch key. The electronic device can receive a key input, and generate a key signal input related to user setting and function control of the electronic device. An indicator <NUM> may be an indicator light, and may be configured to indicate a charging state, a power change, and the like.

A software system of the electronic device may use a hierarchical architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In this embodiment of this application, an Android system with a hierarchical architecture is used as an example to describe a software architecture of an electronic device. <FIG> is a block diagram of a software architecture of an applicable electronic device according to an embodiment of this application. The hierarchical architecture divides a software system of the electronic device into several layers, and each layer has a clear role and division of labor. The layers communicate with each other by using a software interface. In some embodiments, the Android system may be divided into five layers: an application (applications) layer, an application framework (application framework) layer, an Android runtime (Android runtime) and a system library, a hardware abstraction layer (hardware abstract layer, HAL), and a kernel (kernel) layer.

The application layer runs an application by invoking an application programming interface (application programming interface, API) provided by the application framework layer. As shown in <FIG>, the application packages may include applications such as WeChat, camera, gallery, calendar, phone, maps, navigation, WLAN, Bluetooth, music, videos, and SMS.

The application framework layer provides an API and a programming framework for the applications at the application layer.

The Android runtime includes a core library and a virtual machine. The core library includes two parts: One part is a function that needs to be invoked by a java language, and the other part is a core library of Android. The application layer and the application framework layer run on the virtual machine. The virtual machine executes Java files at the application layer and the application framework layer as binary files. The virtual machine is configured to perform functions such as object lifecycle management, stack management, thread management, security and abnormality management, and garbage collection. The system library may include a plurality of functional modules.

The hardware abstraction layer may include a plurality of library modules. The library modules may be a camera library module, a motor library module, and the like. The Android system may load a corresponding library module for device hardware, to implement accessing of the device hardware by the application framework layer.

The kernel layer is used to drive hardware, so that the hardware operates. The kernel layer includes at least a display driver, a camera driver, an audio driver, a sensor driver, a motor driver, and the like. This is not limited in this embodiment of this application.

The following describes, by using specific embodiments, in detail the technical solutions of this application and how the technical solutions of this application resolve the foregoing technical problems. The following several specific embodiments may be implemented independently, or may be combined with each other. For same or similar concepts or processes, details may not be described in some embodiments again.

An example in which the electronic device is a mobile phone <NUM> and the high-speed serial bus is an SPI bus <NUM> is used as an example below to describe the method for calculating position information in a touchscreen according to this embodiment of this application, and this example does not constitute a limitation on this embodiment of this application. The following embodiments may be combined with each other, and the same or similar concepts or processes are not described again. As shown in <FIG>, the mobile phone <NUM> includes a touchscreen <NUM>, a touch chip <NUM>, an SPI bus <NUM>, and a CPU <NUM>. The touchscreen <NUM> is electrically connected to the touch chip <NUM>, and the CPU <NUM> is in communication connection with the touch chip <NUM> by using the SPI bus <NUM>. <FIG> is a schematic flowchart of a method for calculating position information in a touchscreen according to an embodiment of this application. As shown in <FIG>, the method for calculating position information in a touchscreen according to this embodiment of this application includes the following steps.

S601: A touchscreen <NUM> of a mobile phone <NUM> displays a first interface.

For example, still as shown in (b) in <FIG>, in this embodiment of this application, the first interface may be a Moments interface of WeChat®. The WeChat® Moments interface includes a video control <NUM>.

In addition, the first interface can alternatively be a photo preview interface of a camera application, an interface of a game application, a system desktop, or the like. This is not limited herein.

It should be noted that the touchscreen <NUM> may alternatively be an off state. It can be understood that step S601 can be ignored when the touchscreen <NUM> is in the off state.

S602: A touch chip <NUM> of the mobile phone <NUM> samples source data generated by a trigger operation in the touchscreen <NUM>, when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation.

The touch chip <NUM> may periodically transmit a sampling pulse sequence to the touchscreen <NUM>, to collect the source data generated in the touchscreen <NUM>. The source data is a voltage signal or a current signal of the touchscreen <NUM>. It can be understood that the source data may be used to indicate capacitance of the touch chip.

For example, based on the foregoing embodiment corresponding to <FIG>, when the touchscreen <NUM> of the mobile phone <NUM> displays the Moments interface of WeChat®, the sampling pulse sequence transmitted by the touch chip <NUM> can sample the source data generated when the touchscreen <NUM> displays the Moments interface of WeChat®. When the video control <NUM> in the Moments interface of WeChat® is triggered by a finger of the user, the sampling pulse sequence transmitted by the touch chip <NUM> can sample the source data generated by the trigger operation in the touchscreen <NUM>. It can be understood that when the touchscreen <NUM> is triggered, the source data sampled by the touch chip <NUM> is different from source data sampled when the touchscreen <NUM> is not triggered.

S603: The touch chip <NUM> of the mobile phone <NUM> transmits the source data to the CPU <NUM> by using a serial peripheral interface SPI bus <NUM>.

The specific implementation of step S603 includes, but is not limited to, the following two manners.

Manner <NUM>: The CPU <NUM> reads the sampled source data from the touch chip <NUM> by using the SPI bus <NUM>. Specifically, the sampling pulse sequence in step S602 includes a plurality of sampling pulses, and each sampling pulse samples a piece of subdata generated in the touchscreen <NUM>. After the sampling is completed, the touch chip <NUM> processes and packs a plurality of pieces of sampled subdata into source data. The CPU <NUM> reads the source data by using the SPI bus <NUM>.

Manner <NUM>: The touch chip <NUM> writes the sampled source data to the CPU <NUM> by using the SPI bus <NUM>. Specifically, the sampling pulse sequence in step S602 includes a plurality of sampling pulses, and each sampling pulse samples a piece of subdata generated in the touchscreen <NUM>. After the sampling is completed, the touch chip <NUM> processes and packs a plurality of pieces of sampled subdata into source data. The touch chip <NUM> writes the source data into the CPU <NUM> by using the SPI bus <NUM>.

When the SPI bus <NUM> is in a high-speed mode, the data transfer rate can usually reach <NUM> Mbps. It can be learned that SPI bus <NUM> has a higher data transfer rate. Then, the first duration t1 for the CPU <NUM> to read the source data from the touch chip <NUM> or the touch chip <NUM> to write the source data to the CPU <NUM> can be shorter. The first duration t1 is usually less than <NUM>.

It can be understood that the source data sampled by the touch chip <NUM> is an analog signal. Before transmitting the source data to the CPU <NUM>, the touch chip <NUM> needs to convert the analog signal into a digital signal and format the digital signal, so that the CPU <NUM> can recognize the digital signal.

S604: The CPU <NUM> of the mobile phone <NUM> calculates position information of the trigger operation in the touchscreen based on the source data.

For example, as shown in <FIG>, the mobile phone <NUM> detects a variation of source data in a data form of a digital signal (such as a change amount of a current signal or a change amount of a voltage signal), to preliminarily determine signals generated through triggering by a finger of the user. The mobile phone <NUM> performs region segmentation on the preliminarily determined signals generated through triggering by the user, to obtain sub-signals corresponding to each region. The mobile phone <NUM> further checks whether the sub-signals corresponding to each region are signals generated through triggering by the finger of the user; and if yes, the mobile phone <NUM> determines, based on signal distribution in each sub-region, center-of-mass coordinates (that is, coordinates when the video control <NUM> of the Moments interface of the WeChat® in the embodiment corresponding to <FIG> is triggered) when the sub-regions are triggered by the finger of the user. It can be understood that the center-of-mass coordinates are the calculated position information. In addition, the mobile phone <NUM> can further track the position of the finger on the touchscreen <NUM>, so as to determine a moving track of the finger on the touchscreen <NUM>.

It can be learned that the foregoing process of calculating the position information of the trigger operation in the touchscreen is relatively complicated, and the clock rate of the CPU <NUM> is usually greater than <NUM> GZ. It can be understood that a higher clock rate of the CPU <NUM> indicates a higher clock frequency of the CPU <NUM>, that is, a stronger computing capability of the CPU <NUM>, and a higher rate of calculating the position information of the trigger operation in the touchscreen. Then, the second duration t2 for the CPU <NUM> to calculate the position information of the trigger operation in the touchscreen is also shorter. The second duration t2 is usually less than <NUM>.

S605: The CPU <NUM> of the mobile phone <NUM> transparently transmits the position information to a third-party application corresponding to a first interface <NUM>, so that the third-party application performs a function corresponding to a control at the position information.

For example, based on the embodiment corresponding to <FIG>, it can be understood that the third-party application corresponding to the first interface <NUM> is WeChat®, and the CPU <NUM> of the mobile phone <NUM> controls WeChat® to switch to an interface of c in <FIG> to play a video. Controlling WeChat® to switch to the interface of c in <FIG> to play a video is the function corresponding to the control (that is, the video control <NUM>) at the position information. It should be noted that step S605 may be omitted in the method for calculating position information in a touchscreen.

Based on steps S601-S605, it can be understood that a delay t3 from a time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to a time when the third-party application performs the function corresponding to the control at the position information includes the first duration t1 for the touch chip <NUM> to transmit the source data to the CPU <NUM> and the second duration t2 for the CPU <NUM> to calculate the position information of the trigger operation in the touchscreen.

Based on the foregoing description, in the method for calculating position information in a touchscreen according to this embodiment of this application, because the touch chip <NUM> transmits, by using the SPI bus <NUM>, and the source data generated by the trigger operation, and the SPI bus <NUM> has a higher transfer rate, the first duration t1 for the touch chip <NUM> to transmit the source data generated by the trigger operation can be shorter. Further, because the position information of the trigger operation in the touchscreen is calculated in the CPU, and a computing speed of the CPU <NUM> is also higher due to a higher clock rate of the CPU <NUM>, the second duration t2 for the CPU <NUM> to calculate coordinates of a position at which the user triggers the touchscreen <NUM> can also be shorter. In this way, a sum of the first duration t1 and the second duration t2 can be smaller.

In this way, the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information includes the first duration t1 for the touch chip <NUM> to transmit the source data to the CPU <NUM> and the second duration t2 for the CPU <NUM> to calculate the position information of the trigger operation in the touchscreen. In this way, when the sum of the first duration t1 and the second duration t2 is smaller, the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information is shortened. In this way, user experience can be improved.

It can be understood that, in the foregoing embodiment, how to shorten the sum of the first duration t1 and the second duration t2 is used as an example to describe how to shorten the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information. With reference to <FIG>, how to shorten a sampling period T1 based on the shortening of the sum of the first duration t1 and the second duration t2 is described below, to further shorten the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information.

As shown in <FIG>, the touch chip <NUM> may transmit a sampling pulse sequence <NUM> to the touchscreen <NUM> every preset sampling period T1. A start time S1 preset by the touch chip <NUM> for transmitting, to the CPU <NUM>, the source data sampled by an Nth group of sampling pulse sequence <NUM> may be a start time for the touch chip <NUM> to transmit a (N+<NUM>)th group of sampling pulse sequence <NUM> to the touchscreen <NUM>, where N is an integer greater than <NUM>. In this way, still as shown in <FIG>, when the preset sampling period T1 is greater than the sum of the first duration t1 and the second duration t2, the transmission of the (N+<NUM>)th group of sampling pulse sequence <NUM> by the touch chip <NUM> to the touchscreen <NUM> can be performed in parallel with the transmission of the source data by the touch chip <NUM> to the CPU <NUM> by using the SPI bus <NUM> and the calculation of the position information by the CPU <NUM>, as a prerequisite for shortening the sampling period T1.

Based on the foregoing description, because the sum of the first duration t1 and the second duration t2 is smaller, the preset sampling period T1 of the mobile phone <NUM> may be less than a preset duration threshold. For example, as shown in <FIG>, because the sum of the first duration t1 (less than <NUM>) and the second duration t2 (less than <NUM>) is smaller, the preset sampling period T1 may also be smaller. If the sum of the first duration t1 and the second duration t2 is less than <NUM>, the sampling period T1 may also be preset to be less than <NUM> (that is, a sampling rate of the touch chip <NUM> is greater than <NUM>). In addition, the sampling period T1 may alternatively be preset to <NUM>.

It can be learned from <FIG> that fourth duration for which the pulse sequence lasts is t4, and fifth duration between every two groups of sampling pulse sequences <NUM> is t5. The fifth duration t5 is equal to a difference between a sampling period T1 and the fourth duration t4 for which the pulse sequence lasts. It can be understood that the fifth duration t5 can be shorter when the preset sampling period T1 of the mobile phone <NUM> is less than the preset duration threshold and the fourth duration t4 for which the pulse sequence lasts is unchanged. In this way, even if a time when the user performs the trigger operation on the touchscreen <NUM> is between two groups of sampling pulse sequences <NUM>, the delay from the sampling of the Nth group of sampling pulse sequence <NUM> to the trigger operation on the touchscreen <NUM> by the user is still shortened. In addition, it can be learned from <FIG> that because the fifth duration t5 is a part of the foregoing duration t3, when the fifth duration t5 is shorter, the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information can be shortened, thereby further improving user experience.

In conclusion, in the embodiment corresponding to <FIG>, when the sum of the first duration t1 and the second duration t2 (less than <NUM>) is smaller, the preset sampling period T1 of the mobile phone <NUM> can also be smaller, so that the fifth duration t5 between every two groups of sampling pulse sequences can be smaller. Then, the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information can also be smaller.

In addition, in step S602, the shortening of the first duration t1 for the touch chip <NUM> to transmit the source data to the CPU <NUM> depends on performance of SPI bus <NUM>. In some other embodiments, the first duration t1 for the touch chip <NUM> to transmit the source data to the CPU <NUM> can be further shortened based on a data transfer scheduling mode.

For example, as shown in <FIG>, the mobile phone <NUM> may further include an SPI controller <NUM>, where an SPI bus <NUM>, the SPI controller <NUM>, and a CPU <NUM> are sequentially in communication connection with each other. The SPI controller <NUM> and the CPU <NUM> may be integrated into a system on a chip (system on a Chip, SOC) <NUM> in the mobile phone <NUM>. In addition, the SPI controller <NUM> is further connected to a DMA (Direct Memory Access, direct memory access) <NUM>, and the DMA <NUM> can transmit data between the SPI controller <NUM> and the touch chip <NUM>, without the participation of the CPU <NUM> during the transmission. In addition, a priority of instructing to wake up the data transfer thread preset in the CPU <NUM> is higher than that of another to-be-processed thread in the CPU <NUM>, and a priority of a thread that is preset in the SPI controller <NUM> and that is used to instruct to occupy the DMA <NUM> is higher than that of another to-be-processed thread in the SPI controller <NUM>.

Specifically, the data transfer scheduling mode includes the following steps. Step <NUM>: The touch chip <NUM> transmits a sampling pulse sequence to the touchscreen <NUM> to sample the source data. Step <NUM>: Before transmitting data, the touch chip <NUM> may convert sampled analog signals into digital signals and pack the digital signals to obtain source data. The size of the source data is usually between <NUM> KB-<NUM> KB. Step <NUM>: The touch chip <NUM> sends a first notification (the first notification is an interrupt signal in <FIG>) to the CPU <NUM> after packing, and the first notification is used to instruct the CPU <NUM> to wake up a data transfer thread. Because the priority of instructing the preset data transfer thread in the CPU <NUM> is higher than that of another to-be-processed thread in the CPU <NUM>, the CPU <NUM> determines that the priority of the data transfer thread is higher than that of another to-be-processed thread in the CPU <NUM>, and the CPU <NUM> can wake up the data transfer thread without waiting for completion of processing of the another to-be-processed thread, so that the duration for the touch chip <NUM> to wake up the data transfer thread of the CPU <NUM> is smaller. Step <NUM>: After waking up the data transfer thread, the CPU <NUM> sends a second notification to the SPI controller <NUM>, where the second notification is used to indicate that the SPI controller <NUM> occupies the DMA <NUM>. Step <NUM>: After sending the second notification to the SPI controller <NUM>, the CPU <NUM> controls the data transfer thread to start sleeping. In this way, the CPU <NUM> may also process another to-be-processed thread during sleep of the data transfer thread.

After receiving the second notification, the SPI controller <NUM> adds a DMA flag, where the flag is used to indicate that the DMA is occupied by the SPI controller <NUM>. Because the priority of the thread that is preset in the SPI controller <NUM> and that is used to instruct to occupy the DMA1003 is higher than a priority threshold, it is determined that the priority of the thread of occupying the DMA <NUM> is higher than that of another to-be-processed thread in the SPI controller <NUM>, and the SPI controller <NUM> occupies the DMA1003 without waiting for completion of processing of the another to-be-processed thread, so that the duration for occupying the DMA <NUM> is also smaller. Then, step <NUM>: The SPI controller <NUM> copies the source data from the touch chip <NUM> by using the SPI bus <NUM>, and temporarily stores the copied source data in the DMA <NUM>. Step <NUM>: After the copying is completed, the SPI controller <NUM> sends a third notification to the CPU <NUM>, where the third notification is used to instruct the CPU <NUM> to extract the source data. Because the priority of instructing the preset data transfer thread in the CPU <NUM> is higher than that of another to-be-processed thread in the SPI controller <NUM>, the CPU <NUM> determines that the priority of the data transfer thread is higher than that of another to-be-processed thread in the CPU <NUM>, and the CPU <NUM> can wake up the data transfer thread without waiting for completion of processing of the another to-be-processed thread, so that the duration for waking up the data transfer thread is smaller. Step <NUM>: After the data transfer thread of the CPU <NUM> is waked up, the copied source data is extracted from the DMA <NUM>. Then, the touch chip <NUM> transmits the source data to the CPU <NUM> by using the SPI bus <NUM>.

It can be learned that, in the embodiment corresponding to <FIG>, because the duration for waking up the data transfer thread of the CPU <NUM> is shorter, and the duration for occupying the DMA <NUM> is also shorter, the rate at which the touch chip <NUM> transmits the source data to the CPU <NUM> can be increased, and the first duration t1 for the touch chip <NUM> to transmit the source data to the CPU <NUM> is shortened. In this way, the sum of the first duration t1 and the second duration t2 can be further shortened. It can be understood that based on the same principle as the embodiment corresponding to <FIG>, when the sum of the first duration t1 and the second duration t2 is further smaller, the sampling period T1 can also be further smaller, so that the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information can be further shortened.

It should be noted that, in the foregoing embodiment, an example in which the touchscreen <NUM> is triggered by a single finger of the user is used as an example to describe how to make the sampling period T1 smaller. With reference to <FIG>, it is described how to make the sampling period T1 smaller when the touchscreen <NUM> is triggered by multiple fingers of the user.

As shown in (a) in <FIG>, a first interface displayed on the touchscreen <NUM> is an interface of a game application. The interface of the game application includes a control A, a control B, a control C, and a control D. The game interface further includes a game character P1 and a game character P2. When the user needs to control the game character P1 to attack the game character P2 with a heavy hand, as shown in (b) in <FIG>, the control A, the control B, and the control C can be triggered simultaneously. Then, the touch chip <NUM> samples source data of the touchscreen <NUM> when the control A, the control B, and the control C are triggered. It can be understood that when the touchscreen <NUM> is triggered by more fingers of the user, the touch chip <NUM> samples more source data. The touch chip <NUM> transmits the sampled source data to the CPU <NUM> by using the SPI bus <NUM>. The CPU <NUM> of the mobile phone <NUM> calculates position information of a trigger operation in the touchscreen based on the source data. It can be understood that the position information calculated by the CPU <NUM> based on the source data includes coordinates of the control A triggered by a finger of the user, coordinates of the control B triggered by a finger of the user, and coordinates of the control C triggered by a finger of the user. Then, the CPU <NUM> controls the game character P1 to attack the game character P2 with a heavy hand based on the coordinates of the control A, the coordinates of the control B, and the coordinates of the control C.

According to the inventor's test, in a solution in a conventional technology, as shown in (a) in <FIG>, because the clock rate of the MCU of the touch chip <NUM> is lower, the second duration t2 for the MCU to calculate position information of a trigger operation in the touchscreen is longer when more source data needs to be processed. Then, when the second duration t2 is longer, the sum of the first duration t1 and the second duration t2 is also longer. As a result, the sampling period T1 is also longer. In this way, the delay t3 from a time when the user triggers the control A, the control B, and the control C to a time when the user controls the game character P1 to attack the game character P2 with a heavy hand is longer.

In this embodiment of this application, as shown in (b) in <FIG>, because the position information of the trigger operation in the touchscreen is calculated in the CPU <NUM>, and the clock rate of the CPU <NUM> is larger, the second duration t2 for the CPU <NUM> to calculate the position information of the trigger operation in the touchscreen does not change when more source data needs to be processed. In this way, in this embodiment of this application, the sum of the first duration t1 and the second duration t2 is not prolonged when the touchscreen <NUM> is triggered by more fingers of the user. In this way, when the touchscreen <NUM> is triggered by more fingers of the user, the sampling period T1 can still be kept smaller. In this way, the delay t3 from the time when the user triggers the control A, the control B, and the control C to the time when the user controls the game character P1 to attack the game character P2 with a heavy hand may remain smaller.

In some other embodiments, the touchscreen <NUM> may alternatively be triggered by four fingers, five fingers, six fingers, or a different quantities of fingers of the user. As shown in <FIG>, in a solution in a conventional technology, when the touchscreen <NUM> is triggered by one finger to ten fingers separately, the sampling period T1 needs to be gradually increased from <NUM> to <NUM>. In this embodiment of this application, when the touchscreen <NUM> is triggered by one finger to ten fingers, the sampling period T1 may remain unchanged at <NUM>. Based on the foregoing description, when the sampling period T1 is smaller, the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information can also be smaller. It can be understood that, it can be learned from <FIG> that when the touchscreen <NUM> is triggered by less than six fingers of the user, more fingers of the user used to trigger the touchscreen <NUM> indicates a more obvious effect of shortening the delay t3 in this embodiment of this application compared with the solution in the conventional technology.

It can be understood that, in the foregoing embodiment, an example in which the sampling period T1 is shortened based on the shortening of the sum of the first duration t1 and the second duration t2 is used to describe how to further shorten the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information. An example in which the quantity of sampling pulses in the sampling pulse sequence is further reduced based on the shortening of the sum of the first duration t1 and the second duration t2 is used below to describe how to shorten the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information.

In another embodiment, as shown in <FIG>, a quantity of sampling pulses in a sampling pulse sequence <NUM> transmitted by the touch chip <NUM> of the mobile phone <NUM> may be less than a preset quantity threshold. For example, the quantity of sampling pulses may be less than <NUM>. Further, the quantity of sampling pulses may be <NUM>, <NUM>, <NUM>, or the like. This is not limited herein. When the quantity of sampling pulses in the sampling pulse sequence <NUM> is less than the preset quantity threshold, the fourth duration t4 for which the pulse sequence lasts can be shorter (that is, the sampling duration is further shortened). In addition, it can be learned from <FIG> that the fourth duration t4 is a part of the foregoing delay t3. When the fourth duration t4 is shorter, the delay t3 from the time when the touchscreen <NUM> of the mobile phone <NUM> receives the trigger operation to the time when the third-party application performs the function corresponding to the control at the position information can be further shortened (that is, the sampling delay is shortened), thereby further improving user experience.

Further, based on the embodiment corresponding to <FIG>, to improve reliability of the source data collected by the sampling pulse sequence <NUM>, a sampling voltage of sampling pulses in the sampling pulse sequence <NUM> transmitted by the touch chip <NUM> of the mobile phone <NUM> may be greater than a preset voltage threshold. For example, the voltage of the sampling pulses may be greater than <NUM> V. For example, the voltage of the sampling pulses may be <NUM> V, <NUM> V, <NUM> V, <NUM> V, or the like. This is not limited herein. It can be understood that a greater voltage of the sampling pulses indicates higher reliability of the source data collected by the sampling pulse sequence <NUM>.

In addition, to improve the reliability of the position information calculated by the CPU <NUM>, as shown in <FIG>, after obtaining the source data sampled by the touch chip <NUM>, the CPU <NUM> needs to filter the obtained source data by using a filtering algorithm, to reduce noise in the collected source data. Then, the position information calculated by the CPU <NUM> based on the filtered source data has higher reliability.

In addition, in the foregoing method for calculating position information in a touchscreen according to this embodiment of this application, the mentioned trigger operation may include a click operation, a touch and hold operation, a gesture trigger operation, and the like. This is not limited herein.

For example, <FIG> is a schematic diagram of a hardware structure of an electronic device according to an embodiment of this application. As shown in <FIG>, the electronic device includes a central processing unit <NUM>, a high-speed serial bus <NUM>, at least one communication interface (for example, in <FIG>, a communication interface <NUM> is used as an example for description), a touch chip <NUM>, and a touchscreen <NUM>.

The central processing unit <NUM> may be a general-purpose central processing unit (central processing unit, CPU), a micro central processing unit, an application-specific integrated circuit (application-specific integrated circuit, ASIC), or one or more integrated circuits for controlling program execution in the solutions of this application.

The high-speed serial bus <NUM> may include a circuit for transmitting information between the foregoing components. When the high-speed serial bus <NUM> is in a high-speed mode, the data transfer rate can usually reach <NUM> Mbps. It can be learned that high-speed serial bus <NUM> has a higher data transfer rate. The high-speed serial bus <NUM> may be an SPI bus.

The communication interface <NUM> uses any apparatus such as a transceiver to communicate with another device or a communication network, such as an Ethernet or a wireless local area network (wireless local area networks, WLAN).

Possibly, the electronic device may further include a memory <NUM>.

The memory <NUM> may be a read-only memory (read-only memory, ROM) or another type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM) or another type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), a compact disc read-only memory (compact disc read-only memory, CD-ROM) or another optical disk storage, an optical disc storage (including a compact disc, a laser disc, an optical disc, a digital versatile disc, a Blu-ray disc, or the like), a magnetic disk storage medium or another magnetic storage device, or any other medium that can be used to carry or store expected program code in a form of an instruction or a data structure and that can be accessed by a computer, but is not limited thereto. The memory may be stand-alone and connected to the central processing unit by using the high-speed serial bus <NUM>. The memory may alternatively be integrated with the central processing unit.

The memory <NUM> is configured to store computer-executable instructions for executing the solutions in this application under control of the central processing unit <NUM>. The central processing unit <NUM> is configured to execute computer-executable instructions stored in the memory <NUM> to implement the method for calculating position information in a touchscreen according to the embodiments of this application.

Possibly, the computer-executable instructions in this embodiment of this application may alternatively be referred to as application code, which is not specifically limited in this embodiment of this application.

During specific implementation, in an embodiment, the central processing unit <NUM> may include one or more CPUs, such as a CPU <NUM> and a CPU <NUM> in <FIG>.

During specific implementation, in an embodiment, the electronic device may include a plurality of central processing units, such as the central processing unit <NUM> and the central processing unit <NUM> in <FIG>. Each of these central processing units may be a single-core central processing unit (single-CPU) or a multi-core central processing unit (multi-CPU). The central processing unit herein may refer to one or more devices, circuits, and/or processing cores for processing data (such as computer program instructions).

The touch chip <NUM> may periodically transmit a sampling pulse sequence to the touchscreen <NUM>, to collect, when the touchscreen <NUM> receives a trigger operation, source data generated by the trigger operation. The source data includes voltage signal data or current signal data of the touchscreen <NUM>. The touch chip <NUM> may transmit the voltage signal data or the current signal data to the central processing unit <NUM> by using the high-speed serial bus <NUM>. In addition, an MCU is further integrated in the touch chip <NUM>, where the clock rate of the MCU is <NUM>~<NUM>, and the MCU may be configured to perform processing such as analog-to-digital conversion on signals.

The touch chip <NUM> may transmit the voltage signal data or the current signal data to the central processing unit <NUM> and the central processing unit <NUM> by using the high-speed serial bus <NUM>.

The central processing unit <NUM> or the central processing unit <NUM> calculates position information of the trigger operation in the touchscreen based on the source data.

Claim 1:
A method for calculating position information in a touchscreen (<NUM>), wherein the method is applied to an electronic device (<NUM>), the electronic device (<NUM>) comprises a touchscreen (<NUM>), a touch chip (<NUM>), and a central processing unit CPU (<NUM>), and the method comprises:
sampling, by the touch chip (<NUM>), source data generated by a trigger operation in the touchscreen (<NUM>), when the touchscreen (<NUM>) receives the trigger operation;
transmitting, by the touch chip (<NUM>), the source data to the CPU (<NUM>) by using a high-speed serial bus (<NUM>), wherein the source data is used to indicate capacitance of the touchscreen (<NUM>); and
calculating, by the CPU (<NUM>), position information of the trigger operation in the touchscreen (<NUM>) based on the source data,
wherein the electronic device further comprises a bus controller (<NUM>) and a direct memory access DMA, (<NUM>) and the transmitting, by the touch chip (<NUM>), the source data to the CPU (<NUM>) by using a high-speed serial bus (<NUM>) comprises:
controlling, by the touch chip (<NUM>), the CPU (<NUM>) to wake up a data transfer thread;
controlling, by the CPU (<NUM>), the bus controller to add a DMA flag, wherein the flag is used to indicate that the DMA (<NUM>) is occupied by the bus controller (<NUM>), wherein after the controlling, by the CPU (<NUM>), the bus controller to add a DMA flag, the method further comprises:
controlling the data transfer thread to start sleeping;
copying, by the bus controller (<NUM>), the source data from the touch chip (<NUM>) to the DMA (<NUM>) by using the high-speed serial bus (<NUM>); and
controlling, by the bus controller (<NUM>), the CPU (<NUM>) to extract the source data from the DMA (<NUM>), wherein the controlling, by the bus controller (<NUM>), the CPU (<NUM>) to extract the source data from the DMA (<NUM>) comprises: controlling, by the bus controller (<NUM>), the CPU (<NUM>) to wake up the data transfer thread; and extracting the source data from the DMA (<NUM>) after the CPU (<NUM>) wakes up the data transfer thread.