Key detection method and system
By collecting and comparing the voltage data of the keys and using preset thresholds to determine the key status, it solves the existing problems of low key accuracy and poor user experience, and achieves high-precision key detection and good user experience.
Patent Information
- Application Number
- CN202110713378.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-25
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-06-25
AI Technical Summary
Existing buttons are prone to mis-pressing or being unable to accurately identify pressing or releasing during long-term use, resulting in low accuracy and poor user experience.
Collect the voltage value of the button through the preset frequency, obtain the voltage data set and calculate the average value, compare it with the first and second preset thresholds, determine the current status information of the button, and avoid misoperation and signal mistransmission.
It achieves accurate judgment of key status, improves detection accuracy and user experience, reduces misjudgments, and ensures high key accuracy and good user experience.
Smart Images

Figure CN113484742B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of key detection, and more specifically, to a key detection method and system. Background Art
[0002] At present, most traditional buttons are mechanical buttons, but mechanical buttons not only have a limited service life and poor control experience, but also have a raised appearance and are difficult to clean, which has led to the continuous development and application of other types of alternative buttons, such as touch buttons or piezoelectric effect buttons.
[0003] However, during use, all types of existing buttons realize corresponding signal conduction or transmission by pressing the buttons. During long-term use, due to their structural characteristics, the buttons are easily pressed by mistake or the pressing or releasing of the buttons cannot be accurately identified, so the accuracy of the buttons cannot be guaranteed, affecting the user experience. Summary of the invention
[0004] In view of the above problems, an object of the present invention is to provide a key detection method and system to solve the problems of low accuracy and poor user experience of existing keys.
[0005] The key detection method provided by the present invention includes: collecting the voltage value of the key to be detected at a preset frequency to obtain a voltage data set corresponding to the key to be detected; obtaining the mean of all voltage values in the voltage data set in real time and comparing it with a first preset threshold and a second preset threshold, and obtaining a comparison result between the mean and the first preset threshold and the second preset threshold; wherein the first preset threshold is less than the second preset threshold.
[0006] In addition, an optional technical solution is that the process of collecting the voltage value of the key to be detected at a preset frequency to obtain a voltage data set corresponding to the key to be detected includes: collecting the current voltage value of the key to be detected in real time at a preset frequency, and iteratively updating the current voltage value to the voltage data set; wherein, the voltage data set includes all voltage values of the key to be detected collected within a preset time interval, and iteratively updating the current voltage value to the voltage data set includes: adding the current voltage value to the voltage data set, and removing the earliest voltage value collected in the voltage data set.
[0007] In addition, an optional technical solution is that the step of acquiring the mean of all voltage values in the voltage data set in real time and comparing it with the first preset threshold and the second preset threshold includes: calculating the mean of all voltage values in the updated voltage data set and comparing it with the first preset threshold and the second preset threshold.
[0008] In addition, an optional technical solution is that the process of obtaining the comparison result between the mean and the first preset threshold and the second preset threshold, and determining the current state information of the key to be detected based on the comparison result includes: judging the size of the mean and the first preset threshold, when the mean is greater than the first preset threshold, determining that the key to be detected is in the first pressed state; otherwise, when the mean is not greater than the first preset threshold, and the current state information of the key to be detected is the first pressed state, determining that the key to be detected is in an abnormal pressed state, and clearing the state information of the key to be detected.
[0009] In addition, an optional technical solution is to further include: when the mean value is less than a first preset threshold and the historical state information of the key to be detected is a second pressing state, determining that the key to be detected is in a normal release state, and clearing the state information of the key to be detected.
[0010] In addition, an optional technical solution is to obtain a comparison result between the mean and a second preset threshold, and determine the current state information of the key to be detected based on the comparison result. The process includes: judging the size of the mean and the second preset threshold, when the mean is greater than the second preset threshold, and the current state information of the key to be detected is the first pressed state, determining that the key to be detected is the second pressed state; otherwise, when the mean is not greater than the second preset threshold, and the current state information of the key to be detected is the first pressed state or the second pressed state, keeping the current state information unchanged.
[0011] In addition, an optional technical solution is that the process of obtaining the comparison result between the mean and the first preset threshold and the second preset threshold, and determining the current state information of the key to be detected based on the comparison result also includes: when the mean is greater than the second preset threshold, and the current state information of the key to be detected is the second pressing state, keeping the current state information unchanged.
[0012] In addition, an optional technical solution is that the first preset threshold is determined according to the minimum voltage value of the key to be detected in a normal pressing state; the second preset threshold is determined according to the maximum voltage value of the key to be detected in a normal pressing state.
[0013] In addition, an optional technical solution is that the key includes a piezoelectric ceramic key and / or a mechanical key.
[0014] According to another aspect of the present invention, there is provided a key detection system, comprising: a voltage data set unit, used to collect voltage values of a key to be detected at a preset frequency, so as to obtain a voltage data set corresponding to the key to be detected; a comparison result acquisition unit, used to acquire the mean of all voltage values in the voltage data set in real time and compare it with a first preset threshold and a second preset threshold, so as to obtain a comparison result between the mean and the first preset threshold and the second preset threshold; wherein the first preset threshold is less than the second preset threshold; and a state information determination unit, used to determine the current state information of the key to be detected based on the comparison result.
[0015] By utilizing the above-mentioned key detection method and system, the voltage value of the key to be detected is collected at a preset frequency, and the average of all voltage values is obtained in real time and compared with the first preset threshold and the second preset threshold, and the comparison result of the average value and the first preset threshold and the second preset threshold is obtained; based on the comparison result, the current state information of the key to be detected is determined to achieve accurate judgment of the key state, avoid signal mistransmission caused by misoperation or non-active pressing, and the key detection accuracy is high, and the user experience is strong.
[0016] In order to achieve the above and related purposes, one or more aspects of the present invention include the features that will be described in detail later. The following description and the accompanying drawings describe some exemplary aspects of the present invention in detail. However, these aspects indicate only some of the various ways in which the principles of the present invention can be used. In addition, the present invention is intended to include all these aspects and their equivalents. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] By referring to the following description in conjunction with the accompanying drawings, and with a more comprehensive understanding of the present invention, other objects and results of the present invention will become more apparent and easy to understand. In the accompanying drawings:
[0018] Figure 1 is a flow chart of a key detection method according to an embodiment of the present invention;
[0019] Figure 2 FIG. 4 is a block diagram of a key detection device according to an embodiment of the present invention.
[0020] The same reference numerals throughout the drawings indicate similar or corresponding features or functions. DETAILED DESCRIPTION
[0021] In the following description, for the purpose of illustration, in order to provide a comprehensive understanding of one or more embodiments, many specific details are set forth. However, it is apparent that these embodiments may also be implemented without these specific details. In other examples, for ease of describing one or more embodiments, known structures and devices are shown in the form of block diagrams.
[0022] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0023] To describe the key detection method and system of the present invention in detail, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0024] Figure 1 The schematic flow chart of the key detection method according to the embodiment of the present invention is shown.
[0025] like Figure 1 As shown, the key detection method of the embodiment of the present invention includes:
[0026] S110: collecting the voltage value of the key to be detected at a preset frequency to obtain a voltage data set corresponding to the key to be detected.
[0027] In this step, the voltage value of the key to be detected (hereinafter referred to as the key) can be collected by setting a certain collection frequency. The voltage value can use the voltage difference between the two ends of the key to be detected to obtain the voltage value information at each moment, and all the voltage value information is collected to form a voltage data set corresponding to the key to be detected, so as to perform average value processing operations on each voltage value subsequently.
[0028] As a specific example, the frequency of collecting the voltage value of the button per second is set to KHz. After the voltage collection device is powered on, the voltage of the button is collected. The preset time interval is T = N / K seconds. Within the preset time interval, the number of samples of the voltage value obtained is N. Then the voltage data set read is C = [a1, a2, ..., a N ], where the number of elements in the voltage data set C, that is, the number of voltage values, is N, a N It is the voltage value read at the N / Kth second.
[0029] S120: Acquire the mean of all voltage values in the voltage data set in real time and compare it with a first preset threshold and a second preset threshold to obtain a comparison result of the mean, the first preset threshold and the second preset threshold, wherein the first preset threshold is less than the second preset threshold.
[0030] Among them, the first preset threshold is determined according to the minimum voltage value of the key in the normal pressing state. Specifically, in this embodiment, the first preset threshold can be set to the minimum voltage value of the key in the normal pressing state; the second preset threshold is determined according to the maximum voltage value of the key in the normal pressing state. Specifically, in this embodiment, the second preset threshold can be set to half of the maximum voltage value of the key in the normal pressing state. In other embodiments, the first preset threshold can be set to increase the minimum voltage value of the key in the normal pressing state by 10%, and the second preset threshold can be set to reduce the maximum voltage value of the key in the normal pressing state by 30%. The first preset threshold and the second preset threshold can also be set by the user before using the key.
[0031] Specifically, the voltage data set includes all the voltage values of the keys to be detected collected within a preset time interval, and the current voltage value of the keys to be detected is collected in real time according to a preset frequency, and the current voltage value is iteratively updated to the voltage data set. The number of voltage values in the voltage data set can be determined according to the preset time interval and the preset frequency. The preset frequency is KHz, and the preset time interval is T=N / K seconds, then the number of voltage values in the voltage data set is N. When the number of collected voltage values of the keys exceeds N, the voltage values in the voltage data set can be iteratively updated, the collected current voltage value is added to the voltage data set, and the earliest voltage value collected in the voltage data set is removed, so as to always ensure that the number of voltage values in the voltage data set is N.
[0032] Specifically, the mean of all voltage values in the updated voltage data set is calculated, that is, the mean of all voltage values in the voltage data set is obtained in real time and compared with the first preset threshold and the second preset threshold. Each time the voltage data set is updated iteratively, the mean of all voltage values in the voltage data set is calculated correspondingly, and compared with the first preset threshold and the second preset threshold, the comparison result of the mean value and the first preset threshold and the second preset threshold is obtained, and the current state information of the key to be detected is determined based on the comparison result.
[0033] It should be noted that the number of voltage values in the voltage data set can be set according to the application scenario of the key and the user's detection requirements for the key, and is not limited to specific values.
[0034] S130: Determine the current state information of the key to be detected based on the comparison result.
[0035] In this step, the process of obtaining the comparison result between the mean value and the first preset threshold value and the second preset threshold value, and determining the current state information of the key to be detected based on the comparison result includes: judging the size of the mean value and the first preset threshold value, when the mean value is greater than the first preset threshold value, determining that the key to be detected is in the first pressing state; otherwise, when the mean value is not greater than the first preset threshold value, and the current state information of the key to be detected is the first pressing state, determining that the key to be detected is in an abnormal pressing state, and clearing the state information of the key to be detected. The first pressing state refers to the state corresponding to the process of the key from being never pressed to being fully pressed to being normally pressed, and the voltage value corresponding to the first pressing state is relatively small.
[0036] Furthermore, the key detection method further includes: when the mean value is less than a first preset threshold value and the current state information of the key to be detected is a second pressing state, determining that the key to be detected is in a normal release state, and clearing the state information of the key to be detected. The second pressing state refers to a state in which the key is normally pressed after being pressed, and the voltage value corresponding to the second pressing state is larger than that corresponding to the first pressing state.
[0037] In addition, the process of obtaining the comparison result between the mean and the first preset threshold and the second preset threshold, and determining the current state information of the key to be detected based on the comparison result includes: judging the size of the mean and the second preset threshold, when the mean is greater than the second preset threshold, and the current state information of the key to be detected is the first pressed state, determining that the key to be detected is the second pressed state; otherwise, when the mean is not greater than the second preset threshold, and the current state information of the key to be detected is the first pressed state or the second pressed state, keeping the current state information unchanged.
[0038] Furthermore, the key detection method also includes: when the average value is greater than a second preset threshold value and the current state information of the key to be detected is a second pressing state, the current state is kept unchanged.
[0039] As a specific example, the mean value of the voltage data set at the N / Kth second can be expressed as At this time, compare the mean value with the first preset threshold value. AVE If the voltage change of the current key is greater than the first preset threshold, the current key is considered to be in the first pressing state, and the current state information is set to state=pressing, and the voltage value collection and average calculation are continued; otherwise, when the average value V AVEWhen the value of the current state information of the key to be detected is not greater than the first preset threshold value, and the current state information of the key to be detected is the first pressing state, that is, state=pressing, it is considered that the current key is subjected to non-active pressing operations such as external vibration or falling, and the key to be detected is determined to be in an abnormal pressing state. At this time, the state information of the key to be detected is cleared, the current state information is set to state=Null, and the voltage value collection and mean calculation steps are continued; when the mean is less than the first preset threshold value, and the current state information of the key to be detected is the second pressing state, it is determined that the key to be detected is in a normal release state, and the state information of the key to be detected is cleared, the current state information is set to state=Null, and the voltage value collection and mean calculation steps are continued.
[0040] Compare the mean with the second preset threshold. If the mean is greater than the second preset threshold, and the first pressing state of the current state information is state=Pressing, it is considered that the current button is pressed normally, and the current state information is set to the second pressing state, state=Pressed, and continue to sample the voltage value and process the mean value. If the mean is not greater than the second preset threshold, and the current state information of the button to be detected is the first pressing state or the second pressing state, keep the current state information unchanged. If the mean is greater than the second preset threshold, and the current state information of the button to be detected is the second pressing state, that is, state=Pressed, keep the current state information unchanged, and continue to collect voltage values and obtain the mean value.
[0041] It should be noted that the first preset threshold and the second preset threshold can be flexibly adjusted according to needs. The sizes of these two preset values will affect the detection accuracy of the key. In specific application scenarios, they can be set and adjusted according to relevant parameters.
[0042] In a specific embodiment of the present invention, the button may include a piezoelectric ceramic button and / or a mechanical button. When the button is a piezoelectric ceramic button, the voltage value of the button can be directly obtained through the piezoelectric effect. When the button is a mechanical button, a corresponding detection circuit can be set under the button, and the voltage values on both sides of the button can collect the voltage values of the corresponding detection circuit, etc.
[0043] It can be seen that due to the special properties of piezoelectric ceramic materials, their application in electronic products is becoming more and more extensive. When piezoelectric ceramic materials are deformed by external forces in a certain direction, polarization will occur inside them, and opposite positive and negative charges will appear on their two opposite surfaces. When the external force is removed, it will return to an uncharged state. This phenomenon is called the positive piezoelectric effect. When an electric field is applied in the polarization direction of the dielectric, these dielectrics will also deform. When the electric field is removed, the deformation of the dielectric disappears. This phenomenon is called the inverse piezoelectric effect.
[0044] Since piezoelectric materials will produce specific voltage changes when pressed, when piezoelectric ceramic materials are used as key materials, the voltage of the piezoelectric ceramic key is read and the voltage changes at both ends are judged to determine whether the current key is pressed, with high detection accuracy.
[0045] Corresponding to the above-mentioned key detection method, the present invention also provides a key
[0046] According to another aspect of the present invention, a key detection system is provided. Figure 2 The schematic logic of the key detection system according to the embodiment of the present invention is shown.
[0047] like Figure 2 As shown, the key detection system 200 of the embodiment of the present invention includes:
[0048] The voltage data set unit 210 is used to collect the voltage value of the key to be detected according to a preset frequency to obtain a voltage data set corresponding to the key to be detected;
[0049] The comparison result acquisition unit 220 is used to acquire the mean of all voltage values in the voltage data set in real time and compare it with the first preset threshold and the second preset threshold to obtain the comparison result of the mean and the first preset threshold and the second preset threshold; wherein the first preset threshold is less than the second preset threshold.
[0050] The state information determining unit 230 is used to determine the current state information of the key to be detected based on the comparison result.
[0051] It should be noted that the embodiments of the above-mentioned key detection system can refer to the description in the embodiment of the key detection method, which will not be described in detail here.
[0052] According to the key detection method and system provided by the present invention, by acquiring the voltage value of the key and averaging the voltage value, and then comparing the average value with the first preset threshold and the second preset threshold, the current state information of the key can be accurately judged, and the current state information can be changed or maintained according to the judgment result. The detection accuracy is high, and the key can be effectively identified by non-active pressing operations such as external vibration or falling, and the voltage interference signal generated by mis-touching the key can be better processed, so that the voltage change curve is smoother, misjudgment is reduced, the key detection accuracy is high, and the user experience is good.
[0053] The key detection method and system according to the present invention are described above by way of example with reference to the accompanying drawings. However, those skilled in the art should understand that various improvements can be made to the key detection method and system proposed by the present invention without departing from the content of the present invention. Therefore, the protection scope of the present invention should be determined by the content of the attached claims.
Claims
1. A key detection method, characterized in that: The method comprises: Collecting the voltage value of the key to be detected according to a preset frequency to obtain a voltage data set corresponding to the key to be detected; Acquire the mean of all voltage values in the voltage data set in real time and compare it with a first preset threshold and a second preset threshold, and obtain a comparison result of the mean with the first preset threshold and the second preset threshold; wherein the first preset threshold is less than the second preset threshold; The first preset threshold is determined according to the minimum voltage value of the key to be detected in a normal pressing state, and the second preset threshold is determined according to the maximum voltage value of the key to be detected in a normal pressing state; Determine the current state information of the key to be detected based on the comparison result; The process of obtaining the comparison result between the mean value and the first preset threshold value and the second preset threshold value, and determining the current state information of the key to be detected based on the comparison result includes: The difference between the mean and the first preset threshold is determined. When the mean is greater than the first preset threshold, it is determined that the key to be detected is in the first pressing state; otherwise, When the mean value is not greater than the first preset threshold value and the current state information of the key to be detected is the first pressing state, determining that the key to be detected is in an abnormal pressing state, and clearing the state information of the key to be detected; and determining the size of the mean value and the second preset threshold value. When the mean value is greater than the second preset threshold value and the current state information of the key to be detected is the first pressed state, determining that the key to be detected is in the second pressed state; otherwise, When the mean value is not greater than the second preset threshold value, and the current state information of the key to be detected is the first pressed state or the second pressed state, keeping the current state information unchanged; The first pressing state refers to the state corresponding to the process from the key being never pressed to being fully pressed to being normally pressed. The second pressing state refers to the state of the key being normally pressed after being pressed. The voltage value corresponding to the second pressing state is larger than that of the first pressing state.
2. The key detection method according to claim 1, characterized in that: The process of collecting the voltage value of the key to be detected according to the preset frequency to obtain a voltage data set corresponding to the key to be detected includes: Collecting the current voltage value of the key to be detected in real time according to the preset frequency, and iteratively updating the current voltage value to the voltage data set; The voltage data set includes all voltage values of the key to be detected collected within a preset time interval, and iteratively updating the current voltage value to the voltage data set includes: adding the current voltage value to the voltage data set and removing the earliest voltage value collected in the voltage data set.
3. The key detection method according to claim 2, characterized in that: The step of acquiring the mean of all voltage values in the voltage data set in real time and comparing the mean of the voltage values with the first preset threshold and the second preset threshold comprises: The average of all voltage values in the updated voltage data set is calculated and compared with the first preset threshold and the second preset threshold.
4. The key detection method according to claim 1, characterized in that: Also includes: When the mean value is smaller than the first preset threshold value and the current state information of the key to be detected is the second pressing state, it is determined that the key to be detected is in a normal release state, and the state information of the key to be detected is cleared.
5. The key detection method according to claim 1, characterized in that: The process of obtaining a comparison result between the mean value and the first preset threshold value and the second preset threshold value, and determining the current state information of the key to be detected based on the comparison result further includes: When the mean value is greater than the second preset threshold, and the current state information of the key to be detected is the second pressing state, the current state information is kept unchanged.
6. The key detection method according to claim 1, characterized in that: The keys include piezoelectric ceramic keys and / or mechanical keys.
7. A key detection system, characterized in that: include: A voltage data set unit, used to collect the voltage value of the key to be detected according to a preset frequency to obtain a voltage data set corresponding to the key to be detected; a comparison result acquisition unit, configured to acquire the mean of all voltage values in the voltage data set in real time and compare it with a first preset threshold and a second preset threshold, and acquire the comparison result of the mean with the first preset threshold and the second preset threshold; wherein the first preset threshold is less than the second preset threshold; the first preset threshold is determined according to the minimum voltage value of the key to be detected in a normal pressing state, and the second preset threshold is determined according to the maximum voltage value of the key to be detected in a normal pressing state; A state information determining unit, configured to determine the current state information of the key to be detected based on the comparison result; The process of obtaining the comparison result between the mean value and the first preset threshold value and the second preset threshold value, and determining the current state information of the key to be detected based on the comparison result includes: The difference between the mean and the first preset threshold is determined. When the mean is greater than the first preset threshold, it is determined that the key to be detected is in the first pressing state; otherwise, When the mean value is not greater than the first preset threshold value and the current state information of the key to be detected is the first pressing state, determining that the key to be detected is in an abnormal pressing state, and clearing the state information of the key to be detected; Determine the size of the mean value and the second preset threshold value, and when the mean value is greater than the second preset threshold value and the current state information of the key to be detected is the first pressed state, determine that the key to be detected is in the second pressed state; otherwise, When the mean value is not greater than the second preset threshold value, and the current state information of the key to be detected is the first pressed state or the second pressed state, keeping the current state information unchanged; The first pressing state refers to the state corresponding to the process from the key being never pressed to being fully pressed to being normally pressed. The second pressing state refers to the state of the key being normally pressed after being pressed. The voltage value corresponding to the second pressing state is larger than that of the first pressing state.
