Button state recognition method and apparatus, and electronic device
By setting a Hall sensor in the fuselage and setting a magnetic part in the button, magnetic field data is obtained to identify the button state, the problems of high cost and large space in the prior art button state recognition scheme are solved, and a lower cost and more efficient button state recognition is achieved.
Patent Information
- Application Number
- PCT/CN2024/133432
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-11-27
- Filing Date
- 2024-11-21
- Publication Date
- 2025-06-05
AI Technical Summary
The existing button status recognition scheme has high cost and large space, making it difficult to effectively reduce the area occupied by the module under the conditions of tight layout area.
By setting a Hall sensor in the fuselage and setting a magnetic part in the keys outside the fuselage, the magnetic field data generated by the magnetic part is obtained by using the Hall sensor to determine the target key state of the key.
It reduces the hardware cost of the sensor, saves the layout area of the electronic device, and improves the accuracy and efficiency of button status recognition.
Smart Images

Figure CN2024133432_05062025_PF_FP_ABST
Abstract
Description
Key state recognition method, device and electronic device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on November 27, 2023, with application number 202311601999.0 and invention name “Key state recognition method, device and electronic device”. The entire contents of the Chinese patent application are incorporated herein by reference. Technical Field
[0003] The present application belongs to the field of terminal control technology, and specifically relates to a key state recognition method, device and electronic device. Background Art
[0004] Most mobile phones currently on the market implement a one-touch mute function by toggling a physical button. This feature has been well-received by users and is driving the adoption of the mute button feature in a growing number of projects. There are two primary methods for implementing button toggling on mobile phones: differential dual Hall effect sensing and mechanical keys. The differential dual Hall effect sensing solution uses two linear Hall effect sensors and a magnet. Pressing the button up and down changes the position of the magnets, and the Hall effect sensor data is used to determine the button's status. The mechanical key solution uses a physical toggle switch to control the circuit state, thereby turning the mute button on and off. However, both methods are not only costly but also occupy a large amount of space within the entire device. Given the increasing constraints on board space, minimizing the area occupied by each module is crucial. Summary of the Invention
[0005] The purpose of the embodiments of the present application is to provide a key state recognition method, device and electronic device, which can solve the problems of high cost and large space occupied by existing key state recognition solutions.
[0006] In a first aspect, an embodiment of the present application provides a key state recognition method, which is applied to an electronic device, wherein the electronic device includes a body and a key disposed outside the body; a Hall sensor is disposed within the body, and a magnetic member is disposed within the key;
[0007] The method comprises:
[0008] Acquiring magnetic field data through the Hall sensor; the magnetic field data includes the magnetic field generated by the magnetic component;
[0009] The target key state of the key is determined according to the magnetic field data.
[0010] In a second aspect, an embodiment of the present application provides a key state recognition device, which is applied to an electronic device, wherein the electronic device includes a body and a key disposed outside the body; a Hall sensor is disposed in the body, and a magnetic member is disposed in the key;
[0011] The device comprises:
[0012] an acquisition module, configured to acquire magnetic field data through the Hall sensor; the magnetic field data including the magnetic field generated by the magnetic component;
[0013] A determination module is used to determine a target key state of the key according to the magnetic field data.
[0014] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the key state recognition method described in the first aspect are implemented.
[0015] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the key state recognition method as described in the first aspect are implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method described in the first aspect.
[0017] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the method described in the first aspect.
[0018] In the embodiments of the present application, a Hall effect sensor is provided within the device body, and a magnetic component is provided within a button located outside the device body. The Hall effect sensor then acquires magnetic field data generated by the magnetic component, and the target key state of the button is determined based on the acquired magnetic field data. Since only one Hall effect sensor is required within the device body to acquire magnetic field data, the hardware cost of the sensor is reduced, conserving the board space of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] FIG1 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
[0020] FIG2 is a schematic exploded diagram of a magnetic field vector obtained by a three-axis Hall sensor according to an embodiment of the present application;
[0021] FIG3 is a schematic flow chart of a key state recognition method according to an embodiment of the present application;
[0022] FIG4 is a schematic diagram of a magnetic field vector according to an embodiment of the present application;
[0023] FIG5 is a schematic diagram of a magnetic field vector according to another embodiment of the present application;
[0024] FIG6 is a schematic diagram of a predetermined motion trajectory according to an embodiment of the present application;
[0025] FIG7 is a schematic diagram of a magnetic field region according to an embodiment of the present application;
[0026] FIG8 is a schematic diagram of a predetermined motion trajectory according to another embodiment of the present application;
[0027] FIG9 is a schematic block diagram of a key state recognition device according to an embodiment of the present application;
[0028] FIG10 is a schematic block diagram of an electronic device according to an embodiment of the present application;
[0029] FIG11 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application. DETAILED DESCRIPTION
[0030] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.
[0031] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0032] The key state recognition method, device, and electronic device provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0033] Figure 1 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in Figure 1, the electronic device includes a body 1 and a button 2 disposed on the outside of the body 1; a Hall sensor 3 is disposed within the body 1, and a magnetic member 4 is disposed within the button 2.
[0034] Optionally, the Hall sensor 3 can be a three-axis Hall sensor, which can obtain magnetic field data in three-dimensional space, that is, the three-axis Hall sensor can decompose the magnetic field data generated by the magnetic part 4 into three directions in the three-dimensional space. For example, as shown in Figure 2, a three-dimensional coordinate axis is established with the sensing center of the three-axis Hall sensor as the coordinate origin, and the magnetic field data in the three-dimensional space can be decomposed by the three-axis Hall sensor into three directions of X, Y, and Z, so that the magnetic field data can be represented in three-dimensional space using a vector, that is, a magnetic field vector. The magnetic part can be any element or device that can generate a magnetic field, such as a magnet and a device composed of some magnetic particles or components distributed in the button. This embodiment does not limit the position of the Hall sensor in the fuselage, as long as the Hall sensor can obtain the magnetic field data generated by the magnetic part. In actual applications, the Hall sensor can be set near the button.
[0035] FIG3 is a schematic flow chart of a method for identifying a key state according to an embodiment of the present application. As shown in FIG3 , the method is applied to the electronic device shown in FIG1 , and specifically includes the following steps:
[0036] S302, obtaining magnetic field data through a Hall sensor; the magnetic field data includes the magnetic field generated by the magnetic component.
[0037] The Hall effect sensor can detect the magnetic field generated by the magnetic component when the key is stationary or in motion. When the key is stationary (i.e., not moving), the key is in its stationary position. When the key is in motion, the key is in its moving position. The Hall effect sensor can detect magnetic field data at any position of the key during its motion.
[0038] Optionally, the Hall sensor may acquire magnetic field data when a preset condition is met, where the preset condition includes at least one of the following: reaching a preset time interval, detecting key movement (ie, a change in the position of the key).
[0039] S304: Determine the target key state of the key according to the magnetic field data.
[0040] When the electronic device is a mobile phone and the button is a tactile button disposed on the exterior of the mobile phone, the target button state of the button may include an up-touch state or a down-touch state. For example, by tactilely pressing a button on the mobile phone to control the phone to be mute or unmute, when the button is in the up-touch state, the phone is in the mute state; when the button is in the down-touch state, the phone is in the unmute state.
[0041] Figures 4 and 5 are schematic diagrams of two magnetic field vectors. As shown in Figure 4, when the key is in the down state, the magnetic part is below the Hall sensor, and the Hall sensor can obtain the magnetic field vector As shown in Figure 5, when the button is in the up position, the magnetic part is above the Hall sensor, and the Hall sensor can obtain the magnetic field vector
[0042] The target key state is determined in different ways depending on the data content of the magnetic field data, and the different determination methods will be described in detail in the following embodiments.
[0043] In the embodiments of the present application, a Hall effect sensor is provided within the device body, and a magnetic component is provided within a button located outside the device body. The Hall effect sensor then acquires magnetic field data generated by the magnetic component, and the target key state of the button is determined based on the acquired magnetic field data. Since only one Hall effect sensor is required within the device body to acquire magnetic field data, the hardware cost of the sensor is reduced, conserving the board space of the electronic device.
[0044] In one embodiment, the magnetic field data includes first magnetic field vectors at multiple movement positions of the key during movement. When determining the target key state of the key based on the magnetic field data, the following steps A1-A2 may be performed:
[0045] Step A1: determining the current motion trajectory of the key according to the first magnetic field vectors corresponding to the plurality of motion positions.
[0046] The first magnetic field vector corresponding to the motion position, that is, the magnetic field vector obtained by the Hall sensor when the key is in the motion position. The number of motion positions is related to the preset time interval for obtaining magnetic field data. The longer the acquisition time interval, the fewer the number of motion positions. If the preset acquisition time interval is long, due to the short key movement time, during the entire process of key movement, only the first magnetic field vectors of the starting position and the end position of the key may be obtained, and the first magnetic field vector of the intermediate position cannot be obtained. At this time, the first magnetic field vectors of the starting position and the end position can be used to determine the current motion trajectory of the key. Optionally, the vector difference of the first magnetic field vectors of the starting position and the end position can be calculated, and the current motion trajectory of the key can be represented by the vector difference.
[0047] When determining the current motion trajectory of a key, the first magnetic field vector corresponding to the plurality of motion positions may be used to determine magnetic field vector change information of the key during its motion. Then, based on the magnetic field vector change information, the current motion trajectory of the key may be determined. The magnetic field vector change information may include magnetic field modulus change information and / or magnetic field direction change information.
[0048] Optionally, the vector difference between each two adjacent first magnetic field vectors is determined as the magnetic field vector change information of the key during the movement. The current motion trajectory of the key can be represented by the magnetic field vector change information of the key during the movement, for example, using the vector difference between each two adjacent first magnetic field vectors to represent the current motion trajectory of the key.
[0049] Assume that the sampling positions include five motion positions, that is, five points on the key's motion trajectory as the sampling positions. The first magnetic field vectors corresponding to these five motion positions are denoted as [L1, L2, L3, L4, L5], respectively. Then, based on these five first magnetic field vectors, by calculating the vector difference between each two adjacent first magnetic field vectors, the magnetic field vector change information of the key during motion can be obtained, namely: [(L2-L1), (L3-L2), (L4-L3), (L5-L4)]. The magnetic field vector change information of the key during motion represents the current motion trajectory of the key.
[0050] Step A2: determine whether the current motion trajectory is the same as the predetermined motion trajectory; if so, determine that the target button state is the predetermined button state corresponding to the predetermined motion trajectory.
[0051] Optionally, if the current motion trajectory of the key is different from the predetermined motion trajectory, any of the following processing methods can be executed: determining the target key state of the key, determining that the target key state of the key is an abnormal state, and determining that the electronic device is interfered with by an external magnetic field.
[0052] When executing step A2, i.e., determining whether the current motion trajectory is the same as the predetermined motion trajectory, the current motion trajectory and the predetermined motion trajectory can be first divided into multiple segmented vectors, and then the segmented vectors corresponding to the current motion trajectory and the predetermined motion trajectory are compared. Based on the comparison results, it is determined whether the current motion trajectory is the same as the predetermined motion trajectory.
[0053] When comparing the segment vectors corresponding to the current motion trajectory and the predetermined motion trajectory, the comparison may be performed in any of the following ways: comparing whether each segment vector in a plurality of segment vectors is identical to the corresponding segment vector in the predetermined motion trajectory, and comparing whether the vector angle of each segment vector is identical to the vector angle of the corresponding segment vector in the predetermined motion trajectory. If each segment vector is identical to the corresponding segment vector in the predetermined motion trajectory, and / or if the vector angle of each segment vector is identical to the vector angle of the corresponding segment vector in the predetermined motion trajectory, then the current motion trajectory is determined to be identical to the predetermined motion trajectory.
[0054] In step A2, the predetermined motion trajectory refers to the motion trajectory of the key when it switches from one predetermined key state to another predetermined key state. The predetermined motion trajectory corresponding to the predetermined key state can be predetermined. Optionally, in the absence of external magnetic field interference, the key can be switched from the up-dial state to the down-dial state in advance, and the switching process is achieved through the key movement. The motion trajectory during the key movement process is determined, and the motion trajectory is the predetermined motion trajectory corresponding to the key when it switches from the up-dial state to the down-dial state. Similarly, the key can be switched from the down-dial state to the up-dial state in advance, and the switching process is achieved through the key movement. The motion trajectory during the key movement process is determined, and the motion trajectory is the predetermined motion trajectory corresponding to the key when it switches from the down-dial state to the up-dial state.
[0055] Figure 6 shows the predetermined motion trajectory of a key when it switches from the down-dial state to the up-dial state in one embodiment. As shown in Figure 6, the origin of the three-dimensional coordinate axis is the sensing center of the Hall sensor. When the key is in the down-dial state, the Hall sensor can obtain the magnetic field vector When the button is in the up position, the Hall sensor can obtain the magnetic field vector Then, when the key switches from the up-dial state to the down-dial state, the predetermined motion trajectory of the key is the magnetic field vector Movement to magnetic field vector As shown in Figure 6, trajectory T. After determining the current motion trajectory of the key, if the current motion trajectory is the same as trajectory T, it can be determined that the key has switched from the up-dial state to the down-dial state, that is, the target key state of the key is the down-dial state. If the current motion trajectory is different from trajectory T, such as trajectory T' shown in Figure 6, it can be determined that the magnetic field vector has changed due to external magnetic field interference.
[0056] In this embodiment, the current motion trajectory of the key is further determined by obtaining the first magnetic field vectors at multiple motion positions of the key during its motion, and determining the magnetic field vector change information of the key during its motion based on the first magnetic field vectors corresponding to the multiple motion positions. Since the magnetic field vector change information of the key during its motion can accurately reflect the change in the magnetic field vector of the key at different motion positions, the current motion trajectory of the key can be accurately determined based on the magnetic field vector change information. Furthermore, the target key state is determined based on whether the current motion trajectory is consistent with the predetermined motion trajectory. This method of determining the key state is not only simple and highly accurate, but also has low hardware requirements, requiring only a three-axis Hall effect sensor and a magnetic component, greatly reducing hardware costs. In addition, the key state is identified by whether the motion trajectory matches. Only when the predetermined motion trajectory is met can it be identified as a valid key motion, thereby greatly reducing the probability of false triggering and avoiding misjudgment of magnetic field vector changes caused by external magnetic field interference.
[0057] In one embodiment, the plurality of motion positions include an initial position and an end position. If the key state includes an up-shift state or a down-shift state, then when the key switches from the down-shift state to the up-shift state, the initial position of the key is the position in the down-shift state, and the end position is the position in the up-shift state. Similarly, when the key switches from the up-shift state to the down-shift state, the initial position of the key is the position in the up-shift state, and the end position is the position in the down-shift state.
[0058] When determining the target key state of a key based on magnetic field data, first determine based on the magnetic field data whether the vector endpoint of the first magnetic field vector corresponding to the initial position is located within the first magnetic field region corresponding to the initial position, and whether the vector endpoint of the first magnetic field vector corresponding to the end position is located within the second magnetic field region corresponding to the end position. If so, further determine the target key state based on the magnetic field data. The first magnetic field region is a spherical region with the vector endpoint of the standard magnetic field vector corresponding to the initial position as the center and the preset maximum magnetic field error as the radius; the second magnetic field region is a spherical region with the vector endpoint of the standard magnetic field vector corresponding to the end position as the center and the maximum magnetic field error as the radius.
[0059] Considering that electronic devices may be interfered with by the body itself and the external magnetic field, errors may occur in the magnetic field vector obtained by the Hall sensor, including errors in the magnetic field modulus and magnetic field direction. Therefore, a maximum magnetic field error is pre-set, that is, the judgment condition of each movement position is relaxed to a range, which is a spherical area with the vector end point of the standard magnetic field vector as the center and the preset maximum magnetic field error as the radius. The standard magnetic field vector can be determined in advance. Optionally, in the absence of interference from the external magnetic field, the control button is located at any movement position, and the magnetic field vector is obtained at the movement position. The obtained magnetic field vector is the standard magnetic field vector corresponding to the movement position. Any movement position may include the initial position, the end position, or any position between the initial position and the end position during the movement.
[0060] The maximum magnetic field error can be understood as the maximum error allowed in the modulus of the magnetic field vector. As shown in Figure 7, assuming that the key is in the initial position, the corresponding standard magnetic field vector is Standard magnetic field vector The vector endpoint is point O in Figure 7, and the maximum magnetic field error is x. Then the spherical area S with point O as the center and x as the radius is the first magnetic field area corresponding to the initial position. In actual application, assuming that the Hall sensor obtains the first magnetic field vector when the key is in the initial position Then when the first magnetic field vector The first magnetic field vector can be determined when the following expression is satisfied: The end point of the vector is located in the first magnetic field region corresponding to the initial position:
[0061] The meaning of the above expression is: when the key is in the initial position, the first magnetic field vector and the standard magnetic field vector The difference in modulus between them is less than or equal to the maximum magnetic field error x.
[0062] In this embodiment, the calculation of the first magnetic field vector is constrained by the magnetic field area (first magnetic field area or second magnetic field area) corresponding to each movement position, which can greatly reduce the probability of false triggering and avoid misjudgment of magnetic field vector changes caused by external magnetic field interference.
[0063] In one embodiment, the key state is the up-dial state or the down-dial state. When there is a stable external interference, the magnetic field vector and the magnetic field vector The vector endpoints are no longer located in their respective magnetic field regions. is the first magnetic field vector obtained when the key is in the down state, the magnetic field vector is the first magnetic field vector obtained when the key is in the up-dial state.
[0064] As shown in Figure 8, the magnetic field vector and the magnetic field vector The corresponding magnetic field areas are shown as circular areas, and the magnetic field vector of the external interference (abbreviated as interference magnetic field vector) is After being disturbed by the external magnetic field, the magnetic field vector Superimposed interference magnetic field vector Later becomes Magnetic field vector Superimposed interference magnetic field vector Later becomes Right now, When switching between the up-dial state and the down-dial state, the corresponding predetermined motion trajectory is determined by the trajectory becomes It is understandable that when the key is disturbed by a stable external magnetic field, the shape of the predetermined motion trajectory is the same but the coordinates are different. Therefore, the key state can still be identified by determining whether the current motion trajectory of the key is the same as the predetermined motion trajectory.
[0065] In one embodiment, the magnetic field data includes a second magnetic field vector at a resting position of the key in a resting state. When determining a target key state of the key based on the magnetic field data, a determination may be made as to whether the second magnetic field vector matches a standard magnetic field vector corresponding to the resting position. If so, based on a predetermined correspondence between standard magnetic field vectors and key states, the key state corresponding to the standard magnetic field vector that matches the second magnetic field vector is determined as the target key state.
[0066] Among them, if the second magnetic field vector is the same as the standard magnetic field vector corresponding to the static position, or the vector end point of the second magnetic field vector is located within the third magnetic field region corresponding to the static position, then it is determined that the second magnetic field vector matches the standard magnetic field vector corresponding to the static position; the third magnetic field region is a spherical area with the vector end point of the standard magnetic field vector corresponding to the static position as the center and a preset maximum magnetic field error as the radius.
[0067] Taking the first magnetic field region S shown in FIG7 as an example, when the key is in a stationary state, if the vector end point of the second magnetic field vector obtained when the key is in the stationary position is located within the first magnetic field region S, the target key state of the key can be determined to be the standard magnetic field vector The corresponding button status.
[0068] In this embodiment, the key state is identified by determining whether the second magnetic field vector matches the standard magnetic field vector corresponding to the static position, making the key state identification method simpler and faster. Furthermore, as long as the vector endpoint of the second magnetic field vector is within the magnetic field region corresponding to the standard magnetic field vector, the target key state of the key can be determined to be the key state corresponding to the standard magnetic field vector. If the vector endpoint of the second magnetic field vector is outside the magnetic field region corresponding to the standard magnetic field vector, it can be determined that external magnetic field interference has been received. Therefore, while accurately identifying the key state, the accuracy of identifying external magnetic field interference can also be improved.
[0069] In addition, it can be seen from the above embodiments that regardless of whether the key is in a stationary state or a moving state, the magnetic field data generated by the magnetic parts in the key can be obtained through the Hall sensor, and the key state can be determined based on the magnetic field data, so that the acquisition and calculation of the magnetic field data are not affected by whether the key is moving, thereby improving the accuracy of determining the key state.
[0070] The key state recognition method provided in the embodiment of the present application can be executed by a key state recognition device. In the embodiment of the present application, the key state recognition device provided in the embodiment of the present application is described by taking the key state recognition method executed by the key state recognition device as an example.
[0071] Figure 9 is a schematic block diagram of a key state recognition device according to an embodiment of the present application. The device is applied to an electronic device, the electronic device comprising a body and a key disposed on the outside of the body; a Hall sensor is disposed within the body, and a magnetic member is disposed within the key;
[0072] As shown in FIG9 , the device includes:
[0073] An acquisition module 91 is configured to acquire magnetic field data through the Hall sensor; the magnetic field data includes the magnetic field generated by the magnetic component;
[0074] The determination module 92 is configured to determine a target key state of the key according to the magnetic field data.
[0075] In one embodiment, the magnetic field data includes first magnetic field vectors at a plurality of movement positions of the key during the movement process;
[0076] The determination module 92 includes:
[0077] a first determining unit, configured to determine a current motion trajectory of the key according to first magnetic field vectors corresponding to the plurality of motion positions;
[0078] a first judging unit, configured to judge whether the current motion trajectory is the same as a predetermined motion trajectory;
[0079] The second determining unit is configured to: if yes, determine that the target key state is a predetermined key state corresponding to the predetermined motion trajectory.
[0080] In one embodiment, the first determining unit is further configured to:
[0081] determining, based on the first magnetic field vectors corresponding to the plurality of movement positions, magnetic field vector change information during the movement process; the magnetic field vector change information including magnetic field modulus change information and / or magnetic field direction change information;
[0082] The current motion trajectory of the key is determined according to the magnetic field vector change information.
[0083] In one embodiment, the first determining unit is further configured to:
[0084] Dividing the current motion trajectory and the predetermined motion trajectory into a plurality of segment vectors respectively;
[0085] If each of the multiple segmented vectors is identical to the corresponding segmented vector in the predetermined motion trajectory, and / or if the vector angle of each segmented vector is identical to the vector angle of the corresponding segmented vector in the predetermined motion trajectory, then it is determined that the current motion trajectory is identical to the predetermined motion trajectory.
[0086] In one embodiment, the plurality of movement positions include an initial position and an end position;
[0087] The determination module 92 includes:
[0088] A second judgment unit is used to judge, based on the magnetic field data, whether the vector end point of the first magnetic field vector corresponding to the initial position is located in the first magnetic field area corresponding to the initial position, and whether the vector end point of the first magnetic field vector corresponding to the end position is located in the second magnetic field area corresponding to the end position; the first magnetic field area is a spherical area with the vector end point of the standard magnetic field vector corresponding to the initial position as the center and a preset maximum magnetic field error as the radius; the second magnetic field area is a spherical area with the vector end point of the standard magnetic field vector corresponding to the end position as the center and the maximum magnetic field error as the radius;
[0089] A third determining unit is configured to determine the target key state according to the magnetic field data if yes.
[0090] In one embodiment, the magnetic field data includes a second magnetic field vector at a static position of the key in a static state;
[0091] The determination module 92 includes:
[0092] a third judging unit, configured to judge whether the second magnetic field vector matches the standard magnetic field vector corresponding to the static position;
[0093] The fourth determining unit is configured to determine, based on a preset correspondence between a standard magnetic field vector and a key state, that the key state corresponding to the standard magnetic field vector matching the second magnetic field vector is the target key state.
[0094] In one embodiment, the third judgment unit is further configured to:
[0095] If the second magnetic field vector is the same as the standard magnetic field vector corresponding to the static position, or the vector end point of the second magnetic field vector is located within the third magnetic field region corresponding to the static position, then it is determined that the second magnetic field vector matches the standard magnetic field vector corresponding to the static position; the third magnetic field region is a spherical region with the vector end point of the standard magnetic field vector corresponding to the static position as the center and a preset maximum magnetic field error as the radius.
[0096] In one embodiment, the acquisition module 91 includes:
[0097] an acquisition unit, configured to acquire the magnetic field data through the Hall sensor when a preset condition is met;
[0098] The preset condition includes at least one of the following: detecting that the position of the key changes, and reaching a preset time interval.
[0099] In the embodiments of the present application, a Hall effect sensor is provided within the device body, and a magnetic component is provided within a button located outside the device body. The Hall effect sensor then acquires magnetic field data generated by the magnetic component, and the target key state of the button is determined based on the acquired magnetic field data. Since only one Hall effect sensor is required within the device body to acquire magnetic field data, the hardware cost of the sensor is reduced, conserving the board space of the electronic device.
[0100] The key state recognition device in the embodiment of the present application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a mobile Internet device (MID), an augmented reality (AR) / virtual reality (VR) device, a robot, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc. It can also be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., and the embodiment of the present application does not specifically limit it.
[0101] The key state recognition device in the embodiment of the present application can be a device having an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0102] The key state recognition device provided in the embodiment of the present application can implement each process implemented in the method embodiment of Figure 3. To avoid repetition, it will not be described here.
[0103] Optionally, as shown in Figure 10, an embodiment of the present application also provides an electronic device 1000, including a processor 1001 and a memory 1002, and the memory 1002 stores a program or instruction that can be run on the processor 1001. When the program or instruction is executed by the processor 1001, the various steps of the above-mentioned key state recognition method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0104] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0105] FIG11 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.
[0106] The electronic device 100 includes but is not limited to components such as a radio frequency unit 111 , a network module 112 , an audio output unit 113 , an input unit 114 , a sensor 115 , a display unit 116 , a user input unit 117 , an interface unit 118 , a memory 119 , and a processor 110 .
[0107] Those skilled in the art will appreciate that the electronic device 100 may further include a power source (e.g., a battery) for powering various components. The power source may be logically connected to the processor 110 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The electronic device structure shown in FIG11 does not limit the electronic device. The electronic device may include more or fewer components than shown, or may combine certain components, or have different component arrangements, which will not be described in detail here.
[0108] The processor 110 is configured to obtain magnetic field data through the Hall sensor; the magnetic field data includes the magnetic field generated by the magnetic component;
[0109] The target key state of the key is determined according to the magnetic field data.
[0110] Optionally, the magnetic field data includes first magnetic field vectors at multiple motion positions of the key during the motion process; the processor 110 is further used to determine the current motion trajectory of the key based on the first magnetic field vectors corresponding to the multiple motion positions; determine whether the current motion trajectory is the same as the predetermined motion trajectory; if so, determine that the target key state is the predetermined key state corresponding to the predetermined motion trajectory
[0111] Optionally, the processor 110 is also used to determine the magnetic field vector change information during the movement process based on the first magnetic field vectors corresponding to the multiple movement positions; the magnetic field vector change information includes magnetic field modulus change information and / or magnetic field direction change information; and determine the current movement trajectory of the key based on the magnetic field vector change information.
[0112] Optionally, the processor 110 is further used to divide the current motion trajectory and the predetermined motion trajectory into multiple segmented vectors respectively; if each segmented vector in the multiple segmented vectors is the same as the corresponding segmented vector in the predetermined motion trajectory, and / or if the vector angle of each segmented vector is the same as the vector angle of the corresponding segmented vector in the predetermined motion trajectory, then it is determined that the current motion trajectory is the same as the predetermined motion trajectory.
[0113] Optionally, the multiple motion positions include an initial position and an end position; the processor 110 is also used to determine, based on the magnetic field data, whether the vector end point of the first magnetic field vector corresponding to the initial position is located in the first magnetic field region corresponding to the initial position, and whether the vector end point of the first magnetic field vector corresponding to the end position is located in the second magnetic field region corresponding to the end position; the first magnetic field region is a spherical region with the vector end point of the standard magnetic field vector corresponding to the initial position as the center and a preset maximum magnetic field error as the radius; the second magnetic field region is a spherical region with the vector end point of the standard magnetic field vector corresponding to the end position as the center and the maximum magnetic field error as the radius; if so, the target key state is determined based on the magnetic field data.
[0114] Optionally, the magnetic field data includes a second magnetic field vector at a static position of the key in a static state; the processor 110 is further configured to determine whether the second magnetic field vector matches a standard magnetic field vector corresponding to the static position;
[0115] If so, according to a preset correspondence between a standard magnetic field vector and a key state, the key state corresponding to the standard magnetic field vector matching the second magnetic field vector is determined as the target key state.
[0116] Optionally, the processor 110 is also used to determine that the second magnetic field vector matches the standard magnetic field vector corresponding to the static position if the second magnetic field vector is the same as the standard magnetic field vector corresponding to the static position, or the vector end point of the second magnetic field vector is located within a third magnetic field region corresponding to the static position; the third magnetic field region is a spherical region with the vector end point of the standard magnetic field vector corresponding to the static position as the center and a preset maximum magnetic field error as the radius.
[0117] Optionally, the processor 110 is further configured to obtain the magnetic field data through the Hall sensor when a preset condition is met; the preset condition includes at least one of the following: detecting a change in the position of the button and reaching a preset time interval.
[0118] It should be understood that in an embodiment of the present application, the input unit 114 may include a graphics processing unit (GPU) 1141 and a microphone 1142, and the graphics processor 1141 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 116 may include a display panel 1161, and the display panel 1161 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 117 includes a touch panel 1171 and at least one of other input devices 1172. The touch panel 1171 is also called a touch screen. The touch panel 1171 may include two parts: a touch detection device and a touch controller. Other input devices 1172 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0119] The memory 119 can be used to store software programs and various data. The memory 119 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 119 may include a volatile memory or a non-volatile memory, or the memory 119 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The memory 119 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0120] Processor 110 may include one or more processing units. Optionally, processor 110 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 110.
[0121] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned key state recognition method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0122] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer-readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0123] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned key state recognition method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0124] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0125] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned key state recognition method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0126] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0127] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0128] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.
Claims
1. A key state recognition method, applied to an electronic device, wherein the electronic device comprises a body and a key arranged outside the body; A Hall sensor is arranged in the body, and a magnetic part is arranged in the button; The method comprises: Acquiring magnetic field data through the Hall sensor; the magnetic field data includes the magnetic field generated by the magnetic component; A target key state of the key is determined according to the magnetic field data.
2. The method according to claim 1, wherein: The magnetic field data includes first magnetic field vectors at a plurality of movement positions of the key during the movement process; Determining the target key state of the key according to the magnetic field data includes: determining a current motion trajectory of the key according to first magnetic field vectors corresponding to the plurality of motion positions; Determining whether the current motion trajectory is the same as the predetermined motion trajectory; If so, it is determined that the target key state is a predetermined key state corresponding to the predetermined motion trajectory.
3. The method according to claim 2, wherein: The determining the current motion trajectory of the key according to the first magnetic field vectors corresponding to the multiple motion positions includes: Determining magnetic field vector change information during the movement process according to the first magnetic field vectors corresponding to the multiple movement positions; the magnetic field vector change information includes magnetic field modulus change information and / or magnetic field direction change information; The current motion trajectory of the key is determined according to the magnetic field vector change information.
4. The method according to claim 2, wherein: The determining whether the current motion trajectory is the same as the predetermined motion trajectory includes: Dividing the current motion trajectory and the predetermined motion trajectory into a plurality of segment vectors respectively; If each of the multiple segmented vectors is the same as the corresponding segmented vector in the predetermined motion trajectory, and / or if the vector angle of each segmented vector is the same as the vector angle of the corresponding segmented vector in the predetermined motion trajectory, it is determined that the current motion trajectory is the same as the predetermined motion trajectory.
5. The method according to claim 2, wherein: The plurality of movement positions include an initial position and an end position; Determining the target key state of the key according to the magnetic field data includes: According to the magnetic field data, determine whether the vector end point of the first magnetic field vector corresponding to the initial position is located in the first magnetic field region corresponding to the initial position, and whether the vector end point of the first magnetic field vector corresponding to the end position is located in the second magnetic field region corresponding to the end position; the first magnetic field region is a spherical region with the vector end point of the standard magnetic field vector corresponding to the initial position as the center and a preset maximum magnetic field error as the radius; the second magnetic field region is a spherical region with the vector end point of the standard magnetic field vector corresponding to the end position as the center and the maximum magnetic field error as the radius; If so, the target key state is determined according to the magnetic field data.
6. The method according to claim 1, wherein: The magnetic field data includes a second magnetic field vector at a static position of the key in a static state; Determining the target key state of the key according to the magnetic field data includes: Determining whether the second magnetic field vector matches the standard magnetic field vector corresponding to the static position; If so, according to the correspondence between the preset standard magnetic field vector and the key state, the key state corresponding to the standard magnetic field vector matching the second magnetic field vector is determined as the target key state.
7. The method according to claim 6, wherein: The determining whether the second magnetic field vector matches the standard magnetic field vector corresponding to the static position includes: If the second magnetic field vector is the same as the standard magnetic field vector corresponding to the static position, or the vector end point of the second magnetic field vector is located within the third magnetic field region corresponding to the static position, then it is determined that the second magnetic field vector matches the standard magnetic field vector corresponding to the static position; the third magnetic field region is a spherical region with the vector end point of the standard magnetic field vector corresponding to the static position as the center and a preset maximum magnetic field error as the radius.
8. The method according to claim 1, wherein: The obtaining of magnetic field data by the Hall sensor comprises: When a preset condition is met, acquiring the magnetic field data through the Hall sensor; The preset condition includes at least one of the following: detecting that the position of the key changes and reaching a preset time interval.
9. A key state recognition device, applied to an electronic device, the electronic device comprising a body and a key arranged outside the body; A Hall sensor is arranged in the body, and a magnetic part is arranged in the button; The device comprises: An acquisition module, used to acquire magnetic field data through the Hall sensor; the magnetic field data includes the magnetic field generated by the magnetic component; A determination module is used to determine a target key state of the key according to the magnetic field data.
10. An electronic device comprising a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the key state recognition method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Magnetic key triggering method and electronic equipment
CN114427823A
Electronic equipment
CN114582648A
Control key adjusting method, electronic equipment and storage medium
CN114785334A
Electronic equipment, electronic equipment state determination method and related equipment
CN114877793A
Key state identification method and device and electronic equipment
CN117640811A