Method for detecting stylus pen and electronic device
By combining the data of the Hall sensor and the acceleration sensor, and using the wireless charging connection results to confirm the status of the stylus, the detection accuracy problem of the Hall sensor under magnetic field interference is solved, and high-accuracy and low-cost detection results are achieved.
Patent Information
- Application Number
- CN202410634828.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-05-22
AI Technical Summary
In the existing technology, when Hall sensors are used to detect the adsorption state of a stylus, the detection results are easily inaccurate due to magnetic field interference, and increasing the number of sensors to improve accuracy will increase costs and complexity.
By combining the data from the Hall sensor and the acceleration sensor, the adsorption status of the stylus is determined, and the wireless charging connection results are used to confirm the status, reducing errors and improving detection accuracy, avoiding increasing the number of Hall sensors.
It improves the accuracy and reliability of stylus detection, reduces hardware cost and design complexity, and avoids false detection caused by magnetic field interference.
Smart Images

Figure CN118245308B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of terminal devices, and in particular to a method for detecting a stylus pen and an electronic device. Background Art
[0002] During the pairing process between the tablet device and the stylus, the stylus can be attached to the side of the tablet device. When the stylus is attached to the side of the tablet device, the tablet device can wirelessly charge the stylus. Therefore, the tablet device needs to detect whether the stylus is in an adsorbed state or a non-adsorbed state. The tablet device can detect whether the stylus is adsorbed on the tablet through a Hall sensor. However, since the Hall sensor detects the magnetic field size of the accessory through voltage, in addition to the stylus, other objects with magnetic field interference approaching the tablet device may cause inaccurate detection results. For example, when a magnet is used to approach the side of the tablet device, the tablet device detects that the stylus is in an adsorbed state, and an incorrect detection result occurs. Summary of the invention
[0003] The embodiments of the present application provide a method for detecting a stylus and an electronic device, which can be used to improve the focusing effect.
[0004] In a first aspect, an embodiment of the present application provides a method for detecting a stylus, which is applied to an electronic device, and includes: when both a Hall HALL state and an acceleration ACC state change, and the HALL state change is consistent with the stylus state represented by the ACC state change, determining the stylus state based on the HALL state change or the ACC state change; when both the HALL state and the ACC state change, and the stylus state represented by the HALL state change is inconsistent with the ACC state change; or when only one of the HALL state and the ACC state changes, attempting to establish a wireless charging connection with the stylus, and determining the stylus state based on the connection result of the wireless charging connection.
[0005] Among them, the determined stylus state is Figure 4 and Figure 5A and Figure 5B The first position state in .
[0006] In the implementation manner of the present application, the electronic device can further measure the ACC state based on the HALL data by using the relative parallelism of the electronic device stylus. The consistency of the stylus state changes represented by the HALL state and the ACC state can directly determine the stylus state. The dual data can improve the accuracy of stylus detection and reduce detection errors. In the case of inconsistent changes, stylus detection is performed with the help of a wireless charging connection. The reliability of the communication of the wireless charging module ensures the reliability of the detection, and can also prevent the different changes of HALL and ACC from causing errors in the detection results, thereby improving the detection accuracy. Furthermore, in the above implementation manner, the electronic device can reduce the increase in the number of HALL sensors, can directly improve the detection accuracy through software logic, reduce the increase in the number of hardware, save device costs, and save electronic device design space.
[0007] In a possible implementation manner, the HALL state includes a strong magnetic field state and a weak magnetic field state; the ACC state includes a parallel state and a non-parallel state; the stylus state includes an adsorption state and a non-adsorption state; the HALL state change is consistent with the stylus state represented by the ACC state change, including: the HALL state changes from a strong magnetic field state to a weak magnetic field state, and the ACC state changes from a parallel state to a non-parallel state; or the HALL state changes from a weak magnetic field state to a strong magnetic field state, and the ACC state changes from a non-parallel state to a parallel state; determining the stylus state based on the HALL state change or the ACC state change includes: when the HALL state changes from a strong magnetic field state to a weak magnetic field state, and the ACC state changes from a parallel state to a non-parallel state, determining that the stylus state is a non-adsorption state; when the HALL state changes from a weak magnetic field state to a strong magnetic field state, and the ACC state changes from a non-parallel state to a parallel state, determining that the stylus state is an adsorption state. In this way, the electronic device can measure the ACC state by the relative parallelism of the stylus of the electronic device. The consistency of the stylus state changes represented by the HALL state and the ACC state can directly determine the stylus state. The double data can improve the accuracy of stylus detection and reduce detection errors.
[0008] In a possible implementation, the method further includes: if a trigger judgment condition is met, judging whether the stylus state represented by the HALL state change and the ACC state change is consistent; the trigger judgment condition includes satisfying at least one of the following: judging that the HALL state has changed; judging that the ACC state has changed based on the acquired first ACC data and second ACC data; wherein the first ACC data is the ACC data of the electronic device; and the second ACC data is the ACC data of the stylus. In this way, when it is judged that the HALL state has changed or the ACC state has changed, it is judged whether the two changes are consistent, thereby ensuring the effectiveness of the judgment execution, reducing the occupation of processing resources by the above execution, and improving the efficiency of the device.
[0009] In a possible implementation, the method further includes: if the HALL data is acquired, determining that the HALL state has changed. In this way, the HALL state change can be accurately and efficiently determined, ensuring detection accuracy.
[0010] In a possible implementation, the method further includes: determining the first ACC state based on the first ACC data and the second ACC data; when the first ACC state is different from the second ACC state, judging that the ACC state has changed; when the first ACC state is the same as the second ACC state, judging that the ACC state has not changed; wherein the second ACC state is the last ACC state stored by the electronic device. In this way, the change of the ACC state can be accurately judged based on the current first ACC state and the previous second ACC state, thereby ensuring the detection accuracy.
[0011] In a possible implementation, the method further includes: when the HALL data is acquired, the electronic device determines that the HALL state has changed; and the electronic device determines whether the ACC state is consistent with the change in the HALL state. In this way, when the HALL state changes, the judgment of the ACC state can be triggered, and then the judgment results can be compared to ensure the simplicity and efficiency of the processing logic.
[0012] In a possible implementation, the method further includes: acquiring first ACC data and second ACC data, and determining the first ACC state based on the first ACC data and the second ACC data; when the first ACC state is different from the second ACC state, the electronic device determines that the ACC state has changed; the second ACC state is the last ACC state stored by the electronic device; the first ACC data is the ACC data of the electronic device; the second ACC data is the ACC data of the stylus; when the ACC state changes, the electronic device determines whether the HALL state is consistent with the change in the ACC state. In this way, when the ACC state changes, the judgment of the HALL state can be triggered, and then the judgment results can be compared to ensure the simplicity and efficiency of the processing logic.
[0013] In a possible implementation, the determination of the first ACC state based on the first ACC data and the second ACC data includes: when K consecutive pairs of the first ACC data and the second ACC data both meet the preset condition, the first ACC state is a parallel state; when K consecutive pairs of the first ACC data and the second ACC data do not meet the preset condition, the first ACC state is a non-parallel state; wherein the preset condition is that the sum of the absolute values of the acceleration differences of the first ACC data and the second ACC data on each axis is less than or equal to the threshold acceleration; and K is a positive integer. In this way, it is possible to accurately determine whether the two devices are parallel with the help of the acceleration data on different axes of the two devices, and whether the two devices are parallel or not can determine whether the stylus is adsorbed, and the reliability of the judgment basis ensures the accuracy of the detection result. Making judgments by K consecutive frames can prevent the ACC state judgment errors caused by jitter of the electronic device and the second device, improve the accuracy of ACC state judgment, and ensure the accuracy of the detection result.
[0014] In a possible implementation, after determining the stylus state based on the change of the HALL state or the change of the ACC state or determining the stylus state based on the connection result of the wireless charging connection, the method further includes: judging whether the currently determined stylus state is consistent with the last stored stylus state; and adjusting the stored stylus state when the currently determined stylus state is consistent with the last stored stylus state. In this way, the above judgment of whether the position states are consistent can ensure that the second device state is adjusted only when it needs to be adjusted, thereby ensuring the accuracy of the adjustment and the reliability of the judgment.
[0015] Among them, the last stylus state determined is Figure 4 and Figure 5A and Figure 5B The second position state in .
[0016] In a possible implementation, after determining the stylus state based on the change of the HALL state or the ACC state, the method further includes: adjusting the stored stylus state; after determining the stylus state based on the connection result of the wireless charging connection, the method further includes: judging whether the currently determined stylus state is consistent with the last stored stylus state; and if the currently determined stylus state is consistent with the last stored stylus state, adjusting the stored stylus state. In this way, it is necessary to compare the currently determined stylus state with the last stored stylus state to see if the state of the second device has changed, and only adjust it if it has changed, thereby reducing the detection error rate and improving the detection effect.
[0017] Among them, the last stylus state determined is Figure 4 and Figure 5A and Figure 5B The second position state in .
[0018] In a possible implementation, the determination of the stylus state based on the connection result of the wireless charging connection includes: when the connection result of the wireless charging connection is a successful connection, the stylus state is an adsorption state; when the connection result of the wireless charging connection is a connection failure, the stylus state is a non-adsorption state. In this way, by means of the wireless charging connection to perform stylus detection, the reliability of the wireless charging module communication ensures the reliability of the detection, and can also prevent the different changes of HALL and ACC from causing errors in the detection results, thereby improving the detection accuracy.
[0019] In a second aspect, an embodiment of the present application provides an electronic device, comprising one or more processors and one or more memories; the one or more processors are coupled to the one or more memories, the one or more memories are used to store computer program code, the computer program code comprises computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes a method for detecting a stylus as described in the first aspect or any possible implementation method of the first aspect.
[0020] In a third aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute a method for detecting a stylus as described in the first aspect or any possible implementation of the first aspect.
[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on an electronic device, enable the electronic device to execute a method for detecting a stylus as described in the first aspect or any possible implementation of the first aspect.
[0022] In a fifth aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, which are used to call computer instructions to enable the electronic device to execute a method for detecting a stylus as described in the first aspect or any possible implementation method of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0024] Figure 2 It is a schematic diagram of the software and hardware structure of an electronic device proposed in an embodiment of the present application;
[0025] Figure 3A~Figure 3B is a set of user interface schematic diagrams proposed in the embodiments of the present application;
[0026] Figure 4 It is a schematic flow chart of a method for detecting a stylus pen proposed in an embodiment of the present application;
[0027] Figure 5A and Figure 5B It is a schematic flow chart of a method for detecting a stylus pen proposed in an embodiment of the present application;
[0028] Figure 6A to Figure 6E This is a schematic diagram of a set of stylus adsorption detection processes proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.
[0030] The present application proposes a method and an electronic device, which can detect the HALL state and the ACC state. When the HALL state or the ACC state changes, it is determined whether the HALL state and the ACC state change in a consistent manner. When the HALL state and the ACC state change in a consistent manner, the tablet device can set a target adsorption state according to the last adsorption state; when the HALL state and the ACC state change in an inconsistent manner, the tablet device can determine the target adsorption state based on the pin result of the tablet device and the stylus.
[0031] The following first introduces the terms involved in the embodiments of the present application.
[0032] 1. Hall sensor (HALL sensor):
[0033] A Hall sensor, also known as a Hall effect sensor, is a transducer that can convert a changing magnetic field into a change in output voltage. The Hall voltage changes with the strength of the magnetic field. The stronger the magnetic field, the higher the voltage, and the weaker the magnetic field, the weaker the voltage. The Hall voltage value is very small, usually only a few millivolts, but it can be amplified by the amplifier method in the integrated circuit.
[0034] The electronic device in the embodiments of the present application can be a tablet computer, a mobile phone, a desktop, a laptop computer, a handheld computer, a smart bracelet, a super mobile personal computer, a netbook, a personal phone, a personal data assistant, an augmented reality (AR) / virtual reality (VR) and other touch screen devices. The present application does not limit the specific form of the electronic device.
[0035] The following is an introduction to the device involved in the embodiments of the present application.
[0036] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0037] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0038] It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0039] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0040] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0041] It is understandable that the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0042] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0043] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0044] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor.
[0045] The electronic device implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0046] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0047] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case, the adsorption and removal of the stylus pen, the adsorption and removal of the keyboard, etc. In the embodiment of the present application, the stylus pen can rely on the strong adsorption function of the magnetic adsorption module to be adsorbed at a fixed position on the side frame of the electronic device 100 (combined with the magnetic module). Figure 3A and Figure 3B As can be seen). Optionally, the magnetic attraction module between the stylus and the electronic device 100 can be a group of magnets, which is not limited in the embodiment of the present application. In the embodiment of the present application, the electronic device 100 is equipped with a Hall sensor, which can be composed of a Hall element and an auxiliary circuit. On the one hand, the Hall sensor on the electronic device 100 can monitor the changes in the magnetic field, and the magnetic device on the stylus can be adsorbed with the electronic device 100; on the other hand, the Hall sensor of the electronic device 100 can also be used as a switch, which can control the information interaction between the electronic device 100 and the stylus (start sending handshake data, etc.) and other processes.
[0048] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes, for example, the XYZ axis directions). The acceleration sensor 180E can identify the posture of the electronic device. Exemplarily, in an embodiment of the present application, both the stylus and the electronic device 100 are equipped with acceleration sensors, which can be used to determine the acceleration of the stylus on each axis, as well as the acceleration of the electronic device 100 on each axis, so that the electronic device 100 can determine whether the relative position of the stylus and the electronic device remains stationary based on the relative value between the accelerations on each axis, which will not be described one by one here. Among them, the gyroscope sensor 180B and the acceleration sensor 180E can cooperate with each other so that the tablet device 10 and the stylus 20 can accurately obtain information on the acceleration value on each coordinate axis, etc.
[0049] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it.
[0050] Figure 2 A schematic diagram of the software and hardware structure of an electronic device provided in an embodiment of the present application.
[0051] like Figure 2 As shown, the electronic device may include a first processor and a second processor. The first processor may be an application processor (AP) or may also be called a main processor. The second processor may be an audio digital signal processor (ADSP) or a sensor control processor (SCP).
[0052] The second processor may include a sensor hub. The sensor hub can collect data from various sensors in the electronic device and process the sensor data. The processed sensor data can be used by the application of the first software structure system to implement the corresponding functions of the application. Figure 2 As shown in the figure, the sensor hub can run the HALL driver and ACC driver. The sensor hub can connect to the Hall sensor and the accelerometer. The HALL driver can enable the Hall sensor and obtain the HALL data; the ACC driver can enable the accelerometer and obtain the ACC data. For details about the Hall sensor and the accelerometer, please refer to Figure 1 The corresponding description of the magnetic sensor 180D and the acceleration sensor 180E is omitted here.
[0053] The first processor may run a first software framework system, which is described in detail below.
[0054] The first software framework system of the electronic device involved in the present application may include an application layer (application, APP), an application framework layer (framework, FWK), a hardware abstract layer (hardware abstract layer, HAL) and a kernel layer (kernel).
[0055] The application layer may include a series of application packages, such as Bluetooth, floating applications (floatmenu) and other applications (also referred to as applications, some of which are not shown). In the embodiment of the present application, the application may be any application in the application layer, and the user may open or close the application, or perform operations in the application.
[0056] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0057] In an embodiment of the present application, the application framework layer may include a sensor management service (sensorservice). The sensor management service may manage sensors. For example, based on a request from an upper-layer application to enable a sensor, the sensor management service may obtain sensor data from a sensor hub and report it to the application. Exemplarily, the sensor management service receives ACC registration information of a suspended application, starts to enable ACC, and sends an ACC enablement request to the sensor hub. The sensor hub may start the ACC sensor based on the ACC enablement request and start to obtain ACC data.
[0058] The application framework layer may further include an APK interface. The floating application may send a request to the wireless charging driver to attempt to establish a connection with the stylus through the APK interface, and the wireless charging driver may report the connection result to the floating application through the APK interface.
[0059] The hardware abstraction layer is an interface layer between the application framework layer and the driver layer, and provides a virtual hardware platform for the operating system. In the embodiment of the present application, the hardware abstraction layer may include the following types of algorithms, which are not limited in the present application.
[0060] The kernel layer is the foundation of the Android operating system, and the final functions of the Android operating system are completed through the kernel layer. The kernel layer contains at least a wireless communication module, a wireless charging driver, and a display driver. The wireless communication module can communicate through the Bluetooth frequency band. For example, the wireless communication module requests ACC data from the stylus pen and receives ACC data from the stylus pen. That is, when the electronic device can charge the stylus pen (the stylus pen is attached to the device and the stylus pen needs to be charged), the wireless charging driver can start charging the stylus pen. When the stylus pen is attached to the device, the wireless charging driver can connect to the stylus pen (pin is connected). When the stylus pen is not attached to the device, the wireless charging driver cannot connect to the stylus pen (pin is not connected).
[0061] It should be noted that the application provides Figure 2 The first software framework schematic diagram shown is only used as an example and is not limiting. The first software framework can be a specific module division in different layers of the Android operating system. For details, reference can be made to the introduction of the Android operating system software structure in conventional technology. In addition, the present application can also be implemented based on other operating systems, and the present application will not cite examples one by one.
[0062] In addition, as a detection object of the electronic device, the stylus needs to have the ability to communicate with the electronic device. The stylus may include a Bluetooth driver. ACC sensor driver, ACC sensor, HALL sensor and wireless charging driver. Among them, the electronic device can interact with the Bluetooth driver of the stylus through the wireless communication module, that is, the electronic device can request ACC data from the stylus through the wireless communication module, and after the stylus obtains the ACC data request through the Bluetooth driver, it can obtain the second ACC data through the ACC sensor driver, and then send the second ACC data to the wireless communication module of the electronic device through the Bluetooth driver. When the electronic device wirelessly charges the stylus, the electronic device and the wireless charging driver of the stylus need to interact to complete the charging. The electronic device can only be wirelessly charged when the stylus is adsorbed. The wireless charging driver of the electronic device can try to establish a connection with the wireless charging driver of the stylus.
[0063] The tablet device can detect the in-position state of the stylus pen, which can include adsorption and non-adsorption. The electronic device can detect the change between the adsorption state and the non-adsorption state of the stylus pen. Figure 3A and Figure 3B Describes the process of the stylus pen moving from being away (non-adsorbed) to being adsorbed on the tablet device, and from being adsorbed to being away (non-adsorbed).
[0064] Figure 3A~Figure 3B It is a set of user interface schematic diagrams exemplarily disclosed in the embodiments of the present application.
[0065] The stylus state detected by the tablet device includes an adsorption state and a non-adsorption state. When the stylus is in an adsorption state relative to the tablet device, the tablet device can wirelessly charge the stylus, that is, the tablet device can be pinned to the stylus. When the stylus is in a non-adsorption state relative to the tablet device, the tablet device cannot wirelessly charge the stylus, that is, the tablet device cannot be pinned to the stylus.
[0066] Figure 3A Describes the process of the stylus pen moving away from and then adsorbing to the tablet device. Figure 3B The process of the stylus pen from adsorption to separation is shown.
[0067] like Figure 3A As shown in (a) in the figure, there is a distance between the stylus pen and the tablet device, and the stylus pen is not adsorbed on the side frame of the tablet device. Therefore, the stylus pen is in a non-adsorbed state in the tablet device. Figure 3A In (b), the stylus is adsorbed on the side frame of the tablet device, and the stylus is in the adsorbed state in the tablet device. After the stylus is adsorbed on the side frame of the tablet device, a floating pop-up window 310 may be displayed. The floating pop-up window 310 may include a picture of the stylus and / or prompt information. The prompt window may remind the user that the stylus is detected to be in the adsorbed state, or the stylus requests to establish a Bluetooth connection with the tablet device. The floating pop-up window 310 may also display the battery level of the stylus, for example Figure 3A When the tablet device detects that the stylus pen is attached, if the stylus pen needs to be charged, the tablet device can start charging the stylus pen.
[0068] like Figure 3B As shown in (a) in FIG. 1 , the stylus is adsorbed on the side frame of the tablet device. At this time, the stylus is in the adsorption state in the tablet device. Figure 3B In (b), the user takes the stylus away from the side frame of the tablet device, and the stylus is in a non-adsorbed state in the tablet device.
[0069] The above scenario is merely an exemplary description of the correspondence between a tablet device and a stylus, and may also be a tablet and a keyboard, a tablet and a leather case, etc., without limiting the specific scenario and device.
[0070] exist Figure 3A and Figure 3BIn the scenario, the tablet device needs to detect the presence of the stylus. During the process of the tablet device performing the presence detection, the electronic device can detect it through the HALL sensor. The tablet device is provided with a HALL sensor, and the stylus is provided with a magnet device. As the stylus continues to approach the HALL sensor in the tablet device, the magnetic field strength of the HALL sensor in the tablet device increases, and the detection voltage also continues to increase. When the detection voltage is greater than (greater than or equal to) the threshold voltage, the tablet device can determine that the current stylus is in the adsorption state; when the detection voltage is less than or equal to (less than) the threshold voltage, the tablet device can determine that the current stylus is in the adsorption state.
[0071] In the actual detection process, when a magnetic object (not a stylus, but a magnet, etc.) is close to the tablet device, the detection voltage of the tablet device's HALL sensor will also be greater than the threshold voltage, and the tablet device will also detect that the stylus is in an adsorbed state, resulting in an error in the detection result. Therefore, when there is magnetic field interference around the tablet device, there will be false detection or non-detection, resulting in abnormalities in the basic functions of the stylus.
[0072] In order to avoid the situation where the detection result is wrong in the above situation, the tablet device can use multiple HALL sensors to detect the stylus in place state. For example, when the detection voltages of multiple HALL sensors in the tablet device are greater than (greater than or equal to) the threshold voltage, it can be determined that the stylus is in the adsorption state; and when the detection voltages of multiple HALL sensors are less than (less than or equal to) the threshold voltage, it can be determined that the stylus is in the non-adsorption state. However, the use of multiple HALL sensors will lead to an increase in device costs.
[0073] Regarding the above Figure 3A and Figure 3BIn order to solve the technical problems of inaccurate detection using a single HALL sensor and high cost of using multiple HALL sensors in the detection of the stylus in place, the present application proposes a method and electronic device for detecting a stylus. The method is applied to electronic devices. The electronic device can obtain HALL data and ACC data. When the HALL state or ACC state changes, it can start to determine whether the changes in the HALL state and the ACC state are consistent. When the changes both indicate that the stylus has changed from adsorption to distance, or when the changes both indicate that the stylus has changed from distance to adsorption, the electronic device can directly determine the state of the stylus. When the changes in the HALL state and the ACC state are inconsistent, the electronic device can try to establish a wireless charging connection with the stylus. If the wireless charging connection is successfully established, the electronic device can determine that the stylus state is in the adsorption state; if the connection fails, the stylus state is in the non-adsorption state. In this way, the electronic device can further measure the ACC state based on the HALL data by using the relative parallelism of the electronic device stylus. The consistency of the stylus state changes represented by the HALL state and the ACC state can directly determine the state of the stylus. The double data can improve the accuracy of stylus detection and reduce detection errors. In the case of inconsistent changes, the stylus detection is performed with the help of wireless charging connection, and the reliability of the wireless charging module communication ensures the reliability of the detection, and can also prevent the different changes of HALL and ACC from causing errors in the detection results, thereby improving the detection accuracy. Furthermore, in the above-mentioned implementation, the electronic device can reduce the increase in the number of HALL sensors, can directly improve the detection accuracy through software logic, reduce the increase in the number of hardware, save device costs, and save electronic equipment design space.
[0074] Combination Figure 3A and Figure 3B In view of the above technical problems, this application proposes a Figure 4 The method of stylus pen detection shown in the figure. The electronic device can determine whether the changes of the HALL state and the ACC state are consistent based on the HALL data and the ACC data. If the changes are consistent, the adsorption status of the stylus pen can be directly determined; if the changes are inconsistent, the electronic device also needs to try to communicate with the stylus pen, and if the communication can be connected, it is determined that the stylus pen is in the adsorption state; if the communication cannot be connected, it is determined that the stylus pen is in the non-adsorption state. In this way, the detection method of the stylus pen can be accurately determined without increasing the cost of the HALL sensor.
[0075] Figure 4 FIG. 1 is a flow chart of a method for detecting a stylus pen disclosed in an exemplary embodiment of the present application. Figure 4 As shown, the method for detecting a stylus may include but is not limited to the following steps:
[0076] In the embodiments of the present application, the electronic device can be understood as the first device, and the second device can be understood as other devices different from the first device. The detection object of the electronic device is the second device, which can be a stylus, a keyboard, a leather case, etc., and the present application does not limit this. Figure 4 The stylus pen is used as an example for illustration.
[0077] S401: When the electronic device is turned on, the electronic device subscribes to HALL data and ACC data.
[0078] Among them, the HALL data is the identification information of the magnetic state detected by the HALL sensor. It can be understood that the HALL sensor converts the detected magnetic field strength into voltage, and the identification information represents the identification information corresponding to the voltage after crossing the threshold voltage. For example, when the stylus is close to the tablet, the magnetic field strength becomes stronger, the conversion voltage of the HALL sensor becomes larger, the conversion voltage changes from less than the threshold voltage to greater than the threshold voltage, and the identification information changes from "0" to "1". Every time the electronic device obtains HALL data, it means that the identification information of the HALL data changes. The ACC data includes the acceleration data of the electronic device itself (the first ACC data) and the acceleration data of the second device (the second ACC data). The acceleration data is the acceleration of an object in different directions. For example, three mutually perpendicular uniaxial accelerations on the XYZ axis.
[0079] When the electronic device is turned on, the electronic device can enable the HALL sensor and the ACC sensor, and subscribe to the HALL data and the ACC data. After subscribing to the HALL data, the electronic device can obtain the HALL data when the HALL sensor detects that the voltage crosses the threshold. The electronic device can determine the detection object of the HALL data (the specific second device) through the different status bits of the HALL data. For example, the HALL data includes 23 bits of binary data, wherein the 0th bit represents that the second device is a leather case, the 2nd bit represents that the second device is a keyboard; and the 4th bit represents that the second device is a stylus. Each bit can represent the identification information of the corresponding second device. The above description is only exemplary and not limiting. After subscribing to the ACC data, the electronic device can periodically obtain the ACC data. It should be noted that the electronic device can only obtain the second ACC data (of the second device) when the electronic device is connected to the second device (for example, a stylus, a wireless keyboard, a leather case, etc.) via Bluetooth; otherwise, the second ACC data cannot be obtained.
[0080] S402: The electronic device acquires a first HALL state based on the HALL data; and acquires a first ACC state based on the ACC data.
[0081] The HALL state and the ACC state are standards for measuring the state of the second device in two ways. The state of the second device (i.e., the position state) includes an adsorption state and a non-adsorption state. The HALL state is the state of the second device relative to the electronic device measured by the HALL data. When the HALL data indicates that the magnetic field strength is large, the corresponding second device is adsorbed on the electronic device (close distance); when the HALL data indicates that the magnetic field strength is small, the second device is not adsorbed on the electronic device (far distance). The HALL state includes a strong magnetic field state and a weak magnetic field state. The strong magnetic field state corresponds to the second device being in an adsorption state; the weak magnetic field state corresponds to the second device being in a non-adsorption state. The ACC state is the state of the second device relative to the electronic device measured by the ACC data. The ACC state includes a parallel state and a non-parallel state. When the second device is measured to be relatively parallel to the electronic device by the ACC data, the corresponding second device is adsorbed on the electronic device; when the second device is measured to be relatively non-parallel to the electronic device by the ACC data, the corresponding second device is not adsorbed on the electronic device. The changes in the above-mentioned HALL state and ACC state can correspond to the characterization of the state of the second device.
[0082] After the electronic device acquires the HALL data, a first HALL state may be acquired based on the HALL data, wherein the first HALL state is the current HALL state of the electronic device.
[0083] Specifically, after subscribing to the HALL data, if the identification information of the HALL data changes, the electronic device can obtain the changed HALL data. The electronic device can determine the HALL state based on the identification information of the HALL data. For example, the HALL data may include two identification information of "1" and "0". When the HALL data is "1", the HALL state is a strong magnetic field state, indicating that the second device is in an adsorption state; when the HALL data is "0", the HALL state is a weak magnetic field state, indicating that the second device is in a non-adsorption state. Among them, when the HALL sensor of the electronic device detects that the HALL voltage crosses the threshold voltage, that is, the HALL voltage changes from a high voltage state to a low voltage state or from a low voltage state to a high voltage state, the electronic device can obtain HALL data once.
[0084] The electronic device can determine whether the HALL state has changed based on the HALL data.
[0085] Optionally, when the electronic device acquires HALL data, the electronic device can determine that the HALL state has changed.
[0086] Optionally, the electronic device may store the last second HALL state, and when the electronic device obtains HALL data, the first HALL state obtained based on the HALL data may be compared with the second HALL state. If the first HALL state is consistent with the second HALL state, the HALL state does not change; if the first HALL state is inconsistent with the second HALL state, the HALL state changes.
[0087] After the electronic device acquires the ACC data, a first ACC state may be acquired based on the ACC data, where the first ACC state is the current ACC state of the electronic device.
[0088] The ACC data includes first ACC data of the electronic device and second ACC data of the second device.
[0089] The following takes the acceleration on three axes XYZ as an example to explain the process of determining the first ACC state based on the first ACC data and the second ACC data.
[0090] The electronic device may periodically acquire first ACC data (x1, y1, z1) and second ACC data (x2, y2, z2), and the electronic device may determine the ACC state based on the acquired K consecutive first ACC data (x1, y1, z1) and K consecutive second ACC data (x2, y2, z2).
[0091] The electronic device can determine whether the first ACC data and the second ACC data obtained K times in succession meet the preset conditions. If the preset conditions are met in the K times of determination, the electronic device can determine that the ACC state is a parallel state. If there is at least one frame that does not meet the preset conditions, the electronic device can determine that the ACC state is a non-parallel state.
[0092] The process of judging whether the i-th ACC data among the K ACC data meets the preset condition is: when the sum of the absolute values of the acceleration differences between the first ACC data and the second ACC data on the three axes is less than or equal to (less than) the threshold acceleration, it is determined that the i-th ACC data meets the preset condition; when it is greater than (greater than or equal to) the first threshold, it is determined that the i-th ACC data does not meet the preset condition. Specifically, the judgment process of the i-th ACC data among the K ACC data is: when |x1i-x2i|+|y1i-y2i|+|z1i-z2i|<threshold value acc, it is determined that the i-th ACC data meets the preset condition; when |x1i- x2i|+|y1i-y2i|+|z1i-z2i|>or equal to the threshold value acc, it is determined that the i-th ACC data does not meet the preset condition. Wherein, i is an integer from 1 to K, K is a positive integer, and the range of K can be an integer from 3 to 5. The range of the threshold value acc can be 0.05-0.3m / s 2 For example, 0.1m / s 2 , 0.2m / s 2 The first ACC data and the second ACC data are judged in pairs, and the time when the paired first ACC data and the second ACC data are acquired is in the same acquisition time period.
[0093] When the preset condition is satisfied for K consecutive judgments, the electronic device may determine that the ACC state is a parallel state; when the preset condition is not satisfied for K consecutive judgments, the electronic device may determine that the ACC state is a non-parallel state.
[0094] The above-mentioned continuous K frames are used for judgment, which can prevent the electronic device and the second device from making an ACC state judgment error due to jitter, thereby improving the accuracy of the ACC state judgment and ensuring the accuracy of the detection result.
[0095] In the above calculation process, the ACC data of the two devices can be used to determine whether the acceleration of the electronic device and the second device is parallel. If the motion acceleration is parallel, it can be determined that the state of the ACC data corresponds to the adsorption state of the second device; if the motion acceleration is not parallel, it can be determined that the ACC state indicates that the second device is in a non-adsorption state.
[0096] It should be understood that when the second device is adsorbed on the first device, the position change of the second device relative to the first device is stationary, so it is possible to indirectly determine whether the device is in an adsorption state through the acceleration data of the two devices.
[0097] The electronic device may store a second HALL state and a second ACC state. The second HALL state is the HALL state after the last HALL state changes, that is, the second HALL state and the second ACC state are both the previous HALL state and the ACC state. When the electronic device stores the second HALL state and the second ACC state, it may determine whether the HALL state changes based on the first HALL state and the second HALL state; and it may determine whether the ACC state changes based on the first ACC state and the second ACC state.
[0098] When the HALL state changes (the first HALL state is different from the second HALL state), the electronic device can modify the second HALL state, that is, modify the HALL state in the second HALL state to the HALL state in the changed first HALL state.
[0099] Similarly, when the ACC state changes (the first ACC state is different from the second ACC state), the electronic device can modify the second ACC state, that is, modify the second ACC state to the ACC state in the changed first ACC state.
[0100] S403: When the HALL state or the ACC state changes, the electronic device determines whether the stylus state changes represented by the HALL state and the ACC state changes are consistent. If the changes are consistent, execute S404: If the changes are inconsistent, execute S405.
[0101] The triggering condition for determining whether the stylus state represented by the HALL state change and the ACC state change is consistent includes at least one of the following: determining that the HALL state has changed; determining that the ACC state has changed.
[0102] In one possible case, when the HALL state changes, the electronic device detects the ACC state within a first time period, and when the ACC state changes within the first time period and is consistent with the stylus state change represented by the ACC state and HALL state changes, the electronic device can determine that the HALL state is consistent with the ACC state change; when the ACC state does not change within the first time period or is inconsistent with the stylus state change represented by the ACC state and HALL state changes, it can be determined that the HALL state is inconsistent with the ACC state change.
[0103] In another possible situation, when the ACC state changes, the electronic device detects the HALL state within the second time period, and when the HALL state changes within the second time period and the HALL state is consistent with the stylus state change represented by the ACC state change, the electronic device can determine that the HALL state is consistent with the ACC state change; when the HALL state does not change within the second time period or the HALL state is inconsistent with the stylus state change represented by the ACC state change, it can be determined that the HALL state is inconsistent with the ACC state change.
[0104] The ACC state change may include: changing from a strong magnetic field state to a weak magnetic field state, and from a weak magnetic field state to a strong magnetic field state. The HALL state change may include: changing from a parallel state to a non-parallel state, and from a non-parallel state to a parallel state. In the above-mentioned changes in the ACC state and the HALL state, it can be specifically determined whether the ACC state and the HALL state are consistent.
[0105] The ACC state change and the HALL state change are consistent, including two situations: 1. The ACC state changes from a strong magnetic field state (the second ACC state) to a weak magnetic field state (the first ACC state), and the HALL state changes from a parallel state (the second HALL state) to a non-parallel state (the first HALL state). The changes in the ACC state and the HALL state both indicate that the second device changes from an adsorbed state to a non-adsorbed state. 2. The ACC state changes from a weak magnetic field state to a strong magnetic field state, and the HALL state changes from a non-parallel state to a parallel state. The changes in the ACC state and the HALL state both indicate that the second device changes from a non-adsorbed state to an adsorbed state.
[0106] Except for the above-mentioned cases where the ACC state change and the HALL state change are consistent, all other cases are cases where the ACC state change and the HALL state change are inconsistent. Specifically, the inconsistency between the ACC state change and the HALL state change includes four cases: 1. The ACC state changes from a weak magnetic field state to a strong magnetic field state, and the HALL state changes from a parallel state to a non-parallel state. The ACC state indicates that the second device changes from a non-adsorbed state to an adsorbed state, and the change in the HALL state indicates that the second device changes from an adsorbed state to a non-adsorbed state. 2. The ACC state changes from a strong magnetic field state to a weak magnetic field state, and the HALL state changes from a non-parallel state to a parallel state. The ACC state indicates that the second device changes from an adsorbed state to a non-adsorbed state, and the change in the HALL state indicates that the second device changes from a non-adsorbed state to an adsorbed state. 3. The HALL state changes but the ACC state does not change. 4. The ACC state does not change but the HALL state changes.
[0107] In the above-mentioned situations, there are two judgment results: 1. If the HALL state changes in accordance with the ACC state, S404 is executed; 2. If the HALL state changes in accordance with the ACC state, S405 is executed.
[0108] S404: The electronic device determines a first position state based on changes in the HALL state and the ACC state.
[0109] When the HALL state and the ACC state change in the same way, the first position state of the second device (i.e., the current second device state) is determined based on the HALL state and the ACC state change, wherein the first position state includes two situations where the second device is in an adsorption state or a non-adsorption state.
[0110] In one possible case, the ACC state changes from a strong magnetic field state (second ACC state) to a weak magnetic field state (first ACC state), and the HALL state changes from a parallel state (second HALL state) to a non-parallel state (first HALL state), and the electronic device can determine that the first position state is a non-adsorption state.
[0111] In another possible case, the ACC state changes from a weak magnetic field state (second ACC state) to a strong magnetic field state (first ACC state), and the HALL state (second HALL state) changes from a non-parallel state to a parallel state (first HALL state), and the electronic device can determine that the first position state is an adsorption state.
[0112] S405: The electronic device attempts to establish a connection with the second device and obtains a connection result.
[0113] The connection result may include connected and unconnected. Connected means that the electronic device successfully establishes a connection with the second device (connection success), that is, the electronic device can pin to the second device and is capable of charging the second device. Unconnected means that the electronic device cannot establish a connection with the second device (connection failure), that is, the electronic device cannot pin to the second device and is not capable of charging the second device.
[0114] In the case where it is determined in S402 that the change result is inconsistent, the electronic device may attempt to establish a connection with the second device through the wireless charging driver. The electronic device may send a connection request to the wireless charging driver of the second device through the wireless charging driver. In the case where the wireless charging driver of the second device obtains the connection request, the wireless charging driver of the second device may send connection information to the wireless charging driver of the electronic device (that is, it can be understood that the electronic device attempts to pin with the second device), and in the case where the electronic device obtains the connection information, it can be determined that the connection result is connected. In the case where the electronic device does not receive the connection information within the first time period after sending the connection request, the electronic device may determine that the connection result is not connected.
[0115] After executing S405, the connection result is obtained and S406 is executed.
[0116] S406: The electronic device determines the first position state of the second device based on the connection result.
[0117] After the electronic device obtains the connection result, the first position state is determined based on the connection result. If the connection result is connected, the first position state of the second device is determined to be an adsorption state; if the connection result is not connected, the first position state of the second device is determined to be a non-adsorption state.
[0118] In the above S405 and S406, since the electronic device can wirelessly charge the second device, it means that the second device is adsorbed on the electronic device; if wireless charging is not possible, the second device is not adsorbed on the electronic device. In this way, when errors occur in the HALL state and the ACC state, the electronic device can accurately determine the first position state of the second device with the help of the charging condition (connection result) to ensure the accuracy of the first position state.
[0119] S407: The electronic device determines whether the first position state is the same as the second position state.
[0120] After executing S404 or S406, the electronic device needs to determine whether the first position state is the same as the second position state.
[0121] Among them, the second position state is the position state after the last position state stored by the electronic device changes. The electronic device can determine whether the first position state is the same as the second position state. In the case where the second position state is different from the first position state (that is, the second position state and the first position state are one adsorption state and the other non-adsorption state), S408 can be executed, that is, it can be determined that the stored position state needs to be adjusted; in the case where the second position state is the same as the first position state (that is, the second position state and the first position state are both adsorption states or both non-adsorption states), S409 can be executed, that is, the current relative position state of the second device and the electronic device has not changed, and the electronic device does not need to change the stored second position state, that is, it does not process. In this way, the above judgment of whether the position states are consistent can ensure that the state of the second device is adjusted only when it needs to be adjusted, ensuring the accuracy of the adjustment and the reliability of the judgment.
[0122] Optionally, after executing S404, S408 is executed directly without executing S407; after executing S406, S407 is executed. In the above process, if the HALL state changes in accordance with the ACC state, it can be almost determined that the state of the second device has changed, and adjustments can be made, thereby reducing the judgment logic of S407 and improving processing efficiency. After executing S406, S407 needs to be executed to compare whether the state of the second device has changed. If it has changed, adjustments are made to reduce the detection error rate and improve the detection effect.
[0123] S408: The electronic device adjusts to the second position state.
[0124] When the first position state is different from the second position state, the electronic device can adjust the second position state. In an optional manner, the electronic device can adjust the second position state to the same state as the first position state. In another optional manner, the electronic device can adjust the second position state to another state different from the current position state, for example, when the second position state is an adsorption state, the second position state is adjusted to a non-adsorption state; when the second position state is a non-adsorption state, the second position state is adjusted to an adsorption state.
[0125] Optionally, when the second position state is adjusted from the non-adsorbed state to the adsorbed state, the floating application of the electronic device may display a floating window. For details, please refer to Figure 3A The relevant description in is not repeated here.
[0126] Optionally, when the second position state is adjusted from the adsorption state to the non-adsorption state, the floating window displayed by the electronic device can be displayed from a virtual window to a real window (that is, the window color can be changed from light to dark).
[0127] S409: Electronic equipment is not processed.
[0128] When the first position state is different from the second position state, the electronic device does not process it, that is, keeps the second position state unchanged.
[0129] Above Figure 4 In the embodiment of the method, the electronic device can determine whether the current position state of the second device has changed by using the HALL data of a single HALL sensor and the two ACC data of the ACC sensors of the electronic device and the second device. If the changes are consistent, the result of the position state can be directly determined. If the changes are inconsistent, a connection can be established with the help of a wireless charging module to ensure the accuracy of the determined position state.
[0130] Combination Figure 3A and Figure 3B This application aims at the above technical problems, combined with Figure 4 Propose a Figure 5A and Figure 5B An embodiment of a method for detecting a stylus is shown. Figure 5A and Figure 5B The process of acquiring and processing HALL data and ACC data is described in detail. Figure 5A and Figure 5B The software and hardware modules included in the electronic equipment can be referred to Figure 1 and Figure 2 Related description in .
[0131] Figure 5A and Figure 5B FIG. 1 is a flow chart of a method for detecting a stylus pen disclosed in an exemplary embodiment of the present application. Figure 5A and Figure 5B As shown, the focusing method may include but is not limited to the following steps:
[0132] The second device may include a Bluetooth driver, an ACC sensor driver, and a wireless charging driver. The second device may obtain ACC data of the second device through the ACC sensor driver. When the second device is connected to the electronic device through Bluetooth, the second device may send the ACC data of the second device to the electronic device through the Bluetooth driver. The electronic device may wirelessly charge the second device through its own wireless charging driver and the wireless charging driver of the second device.
[0133] The Bluetooth (application), floating application, sensor management service, sensor hub and wireless communication module included in the electronic device can be referred to Figure 2 The relevant description in is not repeated here.
[0134] Figure 5A In the following, the process of obtaining the HALL data, the first ACC data and the second ACC data is mainly described.
[0135] S501: When the electronic device is turned on, the floating application obtains a sensor list and registers a first ACC.
[0136] After the electronic device is turned on, the floating application can execute getsensorlist, that is, obtain the sensor list. After executing getsensorlist, it is determined whether the electronic device includes an ACC sensor based on the sensor list. If the sensor list includes an ACC sensor, the floating application can execute register1, that is, register its own acceleration sensor.
[0137] S502: The floating application sends first registration information to the sensor management service.
[0138] Among them, the first registration information is used to register the first ACC. After registering the ACC, the floating application can obtain the first ACC data. The first registration information includes the first frequency information, the first sensor reporting type (sensor type) and the package name of the floating application. Among them, the frequency information is used to indicate the frequency of reporting ACC data. The sensor reporting type includes two types: continuous reporting continue and change reporting onchange. Continuous reporting refers to the type of continuously reporting sensor information at a certain frequency; change reporting is the type of reporting sensor information when the sensor information changes. The first sensor reporting type is continue, that is, after registration, the first ACC data is reported at the first frequency. The registration information may include the application package name (the package name of the above-mentioned floating application). The application package name indicates the application requesting ACC data and can indicate the target application for reporting data. The first registration information includes the package name of the floating application, that is, after registration, the first ACC data needs to be sent to the floating application.
[0139] The first ACC data is ACC data acquired by the electronic device through its own ACC sensor, that is, acceleration information of the electronic device itself.
[0140] S503: The sensor management service executes and enables the first ACC process.
[0141] After the sensor management service obtains the first registration information (after executing S502 ), it may perform active processing on the ACC, that is, perform enabling processing of the ACC.
[0142] S504: The sensor management service sends a first ACC enable request to the sensor hub.
[0143] The first ACC enable request is used to enable the acceleration sensor of the electronic device itself. The sensor management service may send the first ACC enable request to the sensor hub through the HAL and the Kernel.
[0144] S505: The sensor hub starts the ACC sensor and obtains first ACC data according to the first frequency.
[0145] After the sensor hub obtains the first ACC enable request, it can start the ACC sensor. The first ACC enable request can include a first frequency and a first sensor reporting type. After the ACC sensor is started, the sensor hub can obtain first ACC data according to the first frequency.
[0146] S506: The sensor hub reports the first ACC data to the floating application through the sensor management service.
[0147] When the ACC data is acquired, the sensor hub may report the first ACC data to the floating application through the sensor management service. The sensor hub collects the ACC data according to the first frequency and continuous mode, and reports the first ACC data according to the first frequency and continuous mode. The first ACC data is the ACC data of the electronic device itself.
[0148] S507: When the electronic device is turned on, the Bluetooth application obtains a sensor list and registers a HALL.
[0149] When the electronic device is turned on, the Bluetooth application can execute getsensorlist, that is, obtain the sensor list. After executing getsensorlist, the Bluetooth application determines whether the electronic device includes a HALL sensor based on the sensor list. If the sensor list includes a HALL sensor, the Bluetooth application can execute register2, that is, register its own HALL sensor.
[0150] S508: The Bluetooth application sends second registration information to the sensor management service.
[0151] The second registration information includes the second sensor reporting type (sensor type) and the package name of the Bluetooth application. The second sensor reporting type is the change reporting onchange type. For details about the sensor reporting type, please refer to the relevant description in S502. The second registration information indicates that the Bluetooth application requests to start the HALL sensor and obtain HALL data by means of change reporting.
[0152] S509: The sensor management service executes the enabling HALL process.
[0153] After the sensor management service obtains the second registration information (after executing S508 ), it may perform active processing on the HALL, that is, perform enabling processing of the HALL.
[0154] S510: The sensor management service sends a HALL enable request to the sensor hub.
[0155] The HALL enable request is used to enable the HALL sensor of the electronic device itself. The sensor management service can send the HALL enable request to the sensor hub through the HAL and Kernel.
[0156] S511: The sensor hub starts the HALL sensor and obtains the HALL data when the HALL state changes.
[0157] When the sensor hub starts the HALL sensor, the HALL sensor driver in the sensor hub can detect high voltage or low voltage through the GPIO port. High voltage means that the magnetic field strength detected by the HALL sensor is large, and the converted detection voltage is greater than (greater than or equal to) the threshold voltage; low voltage means that the magnetic field strength detected by the HALL sensor is small, and the converted detection voltage is less than or equal to (less than) the threshold voltage. When the HALL sensor driver in the sensor hub detects a change in the HALL voltage (from high voltage to low voltage or from low voltage to high voltage), the electronic device can obtain the changed HALL data. HALL data is identification information corresponding to high voltage or low voltage.
[0158] S512: The sensor hub reports the HALL data to the floating application through the sensor management service.
[0159] When the sensor hub obtains the HALL data, it can report the HALL data to the floating application through the sensor management service. Optionally, the sensor hub can report the HALL data to the floating application through the HAL, the Kernel and the sensor management service.
[0160] S513: When the electronic device is turned on and the Bluetooth is connected to a second device, the floating application registers the second ACC.
[0161] After the electronic device is turned on, the floating application determines whether the current Bluetooth is connected to the second device. If it is connected to the second device, the floating application can execute register3, that is, register the ACC of the second device. If it is not connected to the second device or the Bluetooth is not turned on, the floating application may not process it.
[0162] S514: The floating application sends a second ACC enable request to the ACC sensor driver through the wireless communication module and the Bluetooth driver of the second device.
[0163] The second ACC enable request is used to request the second device to start and obtain the second ACC data. The second ACC enable request may include the first frequency information, the third sensor reporting type (sensor type) and the package name of the floating application. The third sensor reporting type is continuous reporting.
[0164] The wireless communication module may include a Bluetooth driver. The wireless communication module may be in accordance with.
[0165] S515: ACC sensor driving starts the ACC sensor and obtains second ACC data according to the first frequency.
[0166] After receiving the second ACC enable request, the ACC sensor driver may start the ACC sensor and obtain the second ACC data according to the first frequency.
[0167] S516: The ACC sensor driver sends the second ACC data to the floating application through the Bluetooth driver and the wireless communication module.
[0168] After the ACC sensor driver acquires the second ACC data according to the first frequency, the second ACC data may be sent to the floating application through the Bluetooth driver and the wireless communication module.
[0169] The above processes of S501 to S516 can further refer to the content of S401, which explain each other and are not described in detail.
[0170] Figure 5B In the figure, S517~S526 mainly illustrate the process of the electronic device determining the first position state based on the all state change or the ACC state change after acquiring the HALL data and the ACC data. When the first position state changes compared with the previous second position state, the electronic device determines a new second position state.
[0171] S517: When the HALL state changes or the ACC state changes, the floating application determines whether the ACC state changes in accordance with the HALL state.
[0172] Among them, S517 can refer to the relevant contents in S402 and S403, which will not be repeated here.
[0173] S518: When the HALL state changes, the suspended application determines whether the ACC state changes in accordance with the HALL state; when the ACC state changes, the electronic device determines whether the HALL state changes in accordance with the ACC state.
[0174] When the ACC state changes in accordance with the HALL state, S519 is executed; when the ACC state changes in accordance with the HALL state, S520 to S524 are executed.
[0175] For S518, the relevant contents of S403 may be referred to in sequence and will not be elaborated herein.
[0176] S519: The suspension application determines a first position state based on changes in the HALL state and the ACC state.
[0177] For S519, the relevant contents of S404 may be referred to in sequence and will not be elaborated here.
[0178] S520: The floating application sends a connection attempt request to the wireless charging driver.
[0179] S521: The wireless charging driver sends a connection request to the wireless charging driver of the second device.
[0180] After obtaining the connection attempt request, the wireless charging driver starts to try to establish a connection with the second device, that is, sends a connection request to the wireless charging driver of the second device.
[0181] S522: The wireless charging driver obtains a connection result.
[0182] Combined with the content in S405, the connection results include connected and unconnected. The two connection results may correspond to two possible situations, and S522 only executes one of the situations.
[0183] After the wireless charging driver of the electronic device sends a connection request to the wireless charging driver of the second device, the wireless charging driver of the electronic device may wait for response information from the wireless charging driver of the second device within a trial period.
[0184] In one case, the connection result obtained is connected, and within the trial time, the wireless charging driver of the electronic device obtains the response information from the wireless charging driver of the second device. In another case, the connection result obtained is not connected, and within the trial time, the wireless charging driver of the electronic device does not obtain the information from the wireless charging driver of the second device.
[0185] S523: The wireless charging driver sends a connection result to the floating application.
[0186] After the wireless charging driver obtains the connection result, it can send the connection result to the floating application.
[0187] S524: The floating application determines a first position state based on the connection result.
[0188] Among them, S520~S524 can refer to the relevant contents of S405~S406 in sequence, and will not be repeated here.
[0189] S525: The floating application determines whether the first position state is the same as the second position state.
[0190] S526: The floating application adjusts the second position state.
[0191] Among them, S525~S526 can refer to the relevant contents of S407~S408 in sequence, and will not be repeated here.
[0192] Combination Figure 4 , Figure 5A and Figure 5BIn the implementation method, the electronic device does not need multiple hall devices, but directly uses a single hall sensor and the ACC data of the two devices to determine the consistency of the change. The two-dimensional data ensures that the detection result is more accurate. In the case of inconsistent changes in the HALL and ACC states, the connection is established with the help of the wireless charging driver to ensure the accuracy of the position state in the adsorption or non-adsorption result. Of course, there is no need to further increase the number of HALL sensors, saving device costs.
[0193] In addition, the above-mentioned electronic device can be a mobile phone, a tablet computer, a laptop computer, or other device that can detect whether other devices are adsorbed or close, and the embodiments of the present application are not limited thereto.
[0194] Based on the above Figure 4 and Figure 5A and Figure 5B In the implementation method of the present invention, the present application is directed to the situation where the stylus moves from far away to near and is adsorbed to the tablet device, the situation where the stylus moves from being adsorbed to being far away from the tablet device, and the situation where there is interference caused by a magnetic device. The following are respectively described in detail. Figure 6A to Figure 6E illustrate:
[0195] Figure 6A to Figure 6E It is a schematic diagram of a set of stylus adsorption detection processes for exemplarily illustrating an embodiment of the present application.
[0196] Case 1 and Case 2 are two comparison results of the stylus pen moving from far away to close and adsorbed to the tablet device, with and without the interference of the magnetic device. Based on the two results, this application can determine that the adsorption result is correct.
[0197] Case 1: The stylus moves from far away to near and is attached to the tablet device without interference from magnetic devices.
[0198] like Fig. 6A As shown, at time T1, the stylus pen is in a non-adsorbed state, and at time T2, the stylus pen changes to an adsorbed state. From T1 to T2, the tablet device obtains that the hall state changes from a weak magnetic field state to a strong magnetic field state; the acc state changes from a non-parallel state to a parallel state, and the hall state change is consistent with the acc state change, both indicating adsorption. The tablet device can determine that the position state is an adsorbed state. In the absence of interference from magnetic devices, the hall state change is consistent with the acc state change, the detection result is accurate, and the judgment logic is fast.
[0199] Case 2: The stylus moves from far away to near and is adsorbed onto the tablet device, and there is interference from a magnetic device (a detection device is placed for interference).
[0200] like Figure 6BAs shown, the user can place the detection device close to the side frame of the tablet device. At T3, the stylus is in a non-adsorbed state, and at T4, the stylus changes from a state to an adsorbed state. From T3 to T4, the hall state obtained by the tablet device has always been a strong magnetic field state; the acc state changes from a non-parallel state to a parallel state, and the hall state change is inconsistent with the acc state change. The tablet device then attempts to establish a connection with the stylus, and the connection result is not connected (connection failed), and it is determined that the position state changes from a non-adsorbed state to an adsorbed state. In the case of interference from the magnetic device, the hall state change is inconsistent with the acc state change, and the detection result is accurate by establishing a wireless charging connection with the stylus.
[0201] In actual detection, devices such as magnets can be used as detection devices and placed close to the tablet device to interfere.
[0202] Case 3 and Case 4 are two control results from adsorption to separation from the flat device, with or without interference from the magnetic device. Based on both results, this application can determine that the adsorption result is correct.
[0203] Case 3: The stylus moves away from the tablet device without interference from magnetic devices.
[0204] like Figure 6C As shown, at time T5, the stylus pen is in the adsorption state, and at time T6, the stylus pen changes to the non-adsorption state. From T5 to T6, the tablet device obtains that the hall state changes from the strong magnetic field state to the weak magnetic field state; the acc state changes from the parallel state to the non-parallel state, and the hall state change is consistent with the acc state change, both indicating a change from adsorption to non-adsorption. The tablet device can determine that the position state changes from the adsorption state to the non-adsorption state. In the absence of interference from the magnetic device, the hall state change is consistent with the acc state change, the detection result is accurate, and the judgment logic is fast.
[0205] Case 4: The stylus moves away from the tablet device and there is interference from the magnetic device.
[0206] like Fig.6D As shown, the user can place the detection device close to the side frame of the tablet device. At T7, the stylus is in the adsorption state, and at T8, the stylus changes to the non-adsorption state. From T7 to T8, the hall state obtained by the tablet device has always been a strong magnetic field state; the acc state changes from the parallel state to the non-parallel state, and the hall state change is inconsistent with the acc state change. The tablet device then tries to establish a connection with the stylus, and the connection result is not connected (connection failed), and it is determined that the position state is changed from the adsorption state to the non-adsorption state. In the case of interference from the magnetic device, the hall state change is inconsistent with the acc state change, and the detection result is accurate by establishing a wireless charging connection with the stylus.
[0207] Case 5: The stylus is kept away from the tablet device, causing interference with the magnetic device.
[0208] like Fig. 6E As shown, from moment T9 to moment T10, the stylus remains away from the tablet and is in a non-adsorbed state. Before moment T9 to moment T10, there is no interference from magnetic devices. At moment T10, the user can place the detection device close to the side frame of the tablet device, causing interference. The tablet device obtains that the hall state changes from a weak magnetic field state to a strong magnetic field state; the acc state remains in a non-parallel state, and the hall state change is inconsistent with the acc state change. The tablet device then attempts to establish a connection with the stylus, and the connection result is not connected, and it is determined that the second position state remains in a non-adsorbed state. In the above-mentioned case of interference from a magnetic device, the hall state change is inconsistent with the acc state change, and the detection result is ensured to be accurate by establishing a wireless charging connection with the stylus. The user can place the detection device close to the side frame of the tablet device for interference detection.
[0209] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.
[0210] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0211] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.
Claims
1. A method for detecting a stylus, characterized in that: The method is applied to an electronic device, and the method comprises: When both the Hall state HALL and the acceleration state ACC change, and the HALL state change is consistent with the stylus state represented by the ACC state change, the stylus state is determined based on the HALL state change or the ACC state change; wherein the HALL state includes a strong magnetic field state and a weak magnetic field state; the ACC state includes a parallel state and a non-parallel state; and the stylus state includes an adsorption state and a non-adsorption state; When both the HALL state and the ACC state change, and the stylus state represented by the HALL state change and the ACC state change is inconsistent; or when only one of the HALL state and the ACC state changes, attempt to establish a wireless charging connection with the stylus, and determine the stylus state based on the connection result of the wireless charging connection.
2. The method according to claim 1, characterized in that The stylus state represented by the HALL state change and the ACC state change is consistent, including: the HALL state changes from a strong magnetic field state to a weak magnetic field state, and the ACC state changes from a parallel state to a non-parallel state; or the HALL state changes from a weak magnetic field state to a strong magnetic field state, and the ACC state changes from a non-parallel state to a parallel state; The determining the stylus state based on the change of the HALL state or the change of the ACC state includes: When the HALL state changes from a strong magnetic field state to a weak magnetic field state, and the ACC state changes from a parallel state to a non-parallel state, determining that the stylus state is a non-adsorption state; When the HALL state changes from a weak magnetic field state to a strong magnetic field state, and the ACC state changes from a non-parallel state to a parallel state, it is determined that the stylus state is an adsorption state.
3. The method according to claim 1, characterized in that The method further comprises: If the trigger judgment condition is met, determining whether the stylus state represented by the HALL state change is consistent with the ACC state change; The trigger judgment condition is satisfied including at least one of the following: judging that the HALL state has changed; judging that the ACC state has changed based on the acquired first ACC data and second ACC data; The first ACC data is the ACC data of the electronic device; the second ACC data is the ACC data of the stylus pen.
4. The method according to claim 3, characterized in that The method further comprises: If the HALL data is acquired, it is determined that the HALL state has changed.
5. The method according to claim 3 or 4, characterized in that: The method further comprises: determining a first ACC state based on the first ACC data and the second ACC data; determining that the ACC state has changed when the first ACC state is different from the second ACC state; and determining that the ACC state has not changed when the first ACC state is the same as the second ACC state; The second ACC state is the last ACC state stored by the electronic device.
6. The method according to claim 5, characterized in that The determining the first ACC state based on the first ACC data and the second ACC data includes: When both the first ACC data and the second ACC data satisfy the preset condition for consecutive K pairs, the first ACC state is a parallel state; when both the first ACC data and the second ACC data do not satisfy the preset condition for consecutive K pairs, the first ACC state is a non-parallel state; The preset condition is that the sum of the absolute values of the acceleration differences between the first ACC data and the second ACC data on each axis is less than or equal to the threshold acceleration; and K is a positive integer.
7. The method according to claim 5, characterized in that After determining the state of the stylus pen, the method further includes: Determine whether the currently determined stylus state is consistent with the last stored stylus state; When the currently determined stylus state is consistent with the last stored stylus state, the stored stylus state is adjusted.
8. The method according to claim 5, characterized in that After determining the state of the stylus pen, the method further includes: Adjust the stored stylus state; After determining the stylus state based on the connection result of the wireless charging connection, the method further includes: Determine whether the currently determined stylus state is consistent with the last stored stylus state; When the currently determined stylus state is consistent with the last stored stylus state, the stored stylus state is adjusted.
9. The method according to any one of claims 1 to 4, characterized in that: The determining the stylus state based on the connection result of the wireless charging connection includes: When the connection result of the wireless charging connection is a successful connection, the state of the stylus pen is an adsorption state; when the connection result of the wireless charging connection is a failed connection, the state of the stylus pen is a non-adsorption state.
10. An electronic device, characterized in that: include: One or more processors and one or more memories; the one or more processors are coupled to the one or more memories, the one or more memories are used to store computer program codes, the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the method as described in any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
