Multi-key detection method, multi-key device, and multi-key system

By storing the level information of the key in the variable and determining that the key state change is valid when a preset number of the same states appear continuously in the key variable, the problem of multiple branch judgments and low execution efficiency in the existing technology is solved, and more efficient key detection is achieved.

CN117081603BActive Publication Date: 2025-10-03上海鹰击汽车部件有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311081073.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-25
Publication Date
2025-10-03
Estimated Expiration
2043-08-25

AI Technical Summary

Technical Problem

The key detection method in the prior art needs to manage two counting values: the level and whether it exceeds the filtering threshold. There are many judgment branches and the execution efficiency is low.

Method used

By obtaining the first level information of multiple keys and storing it in a preset storage variable, periodically reading and calculating the level information of the key variables, and using the consecutive appearance of a preset number of the same states in the key variables to determine that the key state change is valid, multiple branch judgments are avoided.

Benefits of technology

The execution efficiency of key detection is improved, branch judgment is reduced, and response speed and parallel operation capabilities are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117081603B_ABST
    Figure CN117081603B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a multi-key detection method and a multi-key device and a multi-key system thereof, which relate to the field of key detection. By obtaining the first level information of multiple keys, the first level information is stored in a preset storage variable; based on a preset time interval, the first level information corresponding to each key is periodically read from the storage variable; a key variable is assigned to each key, the second level information stored in the key variable corresponding to each key is shifted to the high position by a preset number of bits, and calculation information is supplemented in the low position of the key variable; the calculation information and the first level information are calculated to obtain a calculation result, and the calculation result is used as the second level information to replace the calculation information and stored in the key variable; within the preset filtering time, when a preset number of identical key states appear continuously in the key variable corresponding to the key, the key state change corresponding to the key is detected to be valid, which can improve execution efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of key detection, and in particular to a multi-key detection method and a multi-key device and a multi-key system. Background Art

[0002] In related technologies, key acquisition is first performed by reading the state of the microcontroller unit (MCU) pin level. For ease of description, the default state of the key is set to a high level, which is a non-pressed state. When a low level is detected on the key, it is considered that the key is pressed, and the press filter phase is entered. When the press time reaches the filter threshold time, the key is considered to be effectively pressed. When a high level is detected on the key, it is considered that the key is released, and the release filter phase is entered. When the release time reaches the filter threshold time, the key is considered to be effectively released. In the above technical solution, each key needs to manage two count values: the level and whether it exceeds the filter threshold. There are many judgment branches and low execution efficiency. Summary of the Invention

[0003] The present application provides a multi-key detection method and a multi-key device and a multi-key system thereof, which can improve execution efficiency.

[0004] The technical solutions of the embodiments of this application are as follows:

[0005] In a first aspect, an embodiment of the present application provides a multi-key detection method, the method comprising:

[0006] Acquire first level information of a plurality of keys, and store the first level information in a preset storage variable, wherein the first level information is used to indicate a key state;

[0007] Based on a preset time interval, periodically reading the first level information corresponding to each key from the storage variable;

[0008] Allocating a key variable to each key, shifting the second level information stored in the key variable corresponding to each key toward a higher position by a preset number of bits, and supplementing the calculation information in a lower position of the key variable;

[0009] Calculating the calculation information and the first level information to obtain a calculation result, replacing the calculation information with the calculation result as the second level information, and storing the result in the key variable;

[0010] During the preset filtering time, when a preset number of identical key states appear continuously in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is valid.

[0011] In the above technical solution, first level information of multiple keys is obtained, the first level information is used to indicate the key state, and the first level information is stored in a preset storage variable, which is conducive to preserving the key state and facilitating the subsequent acquisition of the real-time key state; based on a preset time interval, the first level information corresponding to each key is periodically read from the storage variable, and the real-time key state can be obtained after the time interval; a key variable is assigned to each key, the second level information stored in the key variable corresponding to each key is shifted to the high bit by a preset number of bits, and the calculation information is supplemented in the low bit of the key variable; the calculation information and the first level information are calculated to obtain a calculation result, and the calculation result is used as the second level information to replace the calculation information and stored in the key variable, which is conducive to subsequently judging whether the key state is valid according to the stored value in the key variable; within the preset filtering time, when a preset number of identical key states appear continuously in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is valid. The validity of the key state change is determined by the continuous occurrence of the preset number of identical key states, avoiding the counting of multiple count values, thereby avoiding a large number of branches, and improving execution efficiency. Compared with the prior art with many judgment branches and low execution efficiency, the embodiment of the present application saves the first level information by storing variables to store the status of multiple buttons, obtains the first level information at a preset time interval, and performs calculation processing with the calculation information supplemented by the low bit of the button variable, and then determines that the button status change is valid through the continuous occurrence of a preset number of the same button status, which can effectively avoid too many branches and improve execution efficiency.

[0012] In some embodiments of the present application, the calculating information and the first level information are calculated to obtain a calculation result, including:

[0013] Setting the calculation information and the first level information to have the same data format;

[0014] Perform an OR operation on the calculation information and the first level information to obtain a calculation result.

[0015] In the above technical solution, the calculation information and the first level information are first set to have the same data format so that the calculation of the two can be realized. The calculation information and the first level information are ORed to obtain the operation result. The operation result can reflect whether the key state is updated, thereby judging whether the change is valid.

[0016] In some embodiments of the present application, the button state includes a pressed state and a released state;

[0017] When a preset number of identical key states appear continuously in the key variable corresponding to the key, detecting that the key state change corresponding to the key is valid includes:

[0018] When a preset number of identical pressed states appear continuously in the key variable corresponding to the key, it is detected that the pressed state change corresponding to the key is valid;

[0019] When a preset number of identical release states appear continuously in the key variable corresponding to the key, it is detected that the change in the release state corresponding to the key is valid.

[0020] In the above technical solution, by judging whether a preset number of identical pressed states appear in a key variable continuously, it is detected that the pressed state change corresponding to the key is valid, thus avoiding multiple branch judgments and improving execution efficiency. By judging whether a preset number of identical released states appear in a key variable continuously, it is detected that the released state change corresponding to the key is valid, thus avoiding multiple branch judgments and improving execution efficiency.

[0021] In some embodiments of the present application, the first level information includes a high level and a low level, the low level indicates a pressed state, and the high level indicates a released state;

[0022] The step of storing the first level information in a preset storage variable includes:

[0023] Numbering each of the buttons, wherein the number corresponds to the subscript of the storage variable;

[0024] When the key is in the pressed state, storing the low level in a space corresponding to the subscript of the storage variable corresponding to the key;

[0025] When the key is in the released state, the high level is stored in the space corresponding to the subscript of the storage variable corresponding to the key.

[0026] In the above technical solution, by numbering each key and corresponding the number to the subscript of the storage variable, it is possible to obtain the level information corresponding to the key from the storage variable according to the key, and the key state of the corresponding key can be obtained by obtaining the level information in the storage variable.

[0027] In some embodiments of the present application, the preset number is obtained by the following steps:

[0028] During the preset filtering time, the preset number is calculated according to the time interval.

[0029] In the above technical solution, a preset number is obtained according to the filtering time and the time interval. According to setting different time intervals, the same bits of the preset number are judged differently, which is widely used.

[0030] In some embodiments of the present application, assigning a key variable to each key, shifting the second level information stored in the key variable corresponding to each key to a higher position by a preset number of bits, and supplementing the calculation information in the lower position of the key variable, includes:

[0031] Allocating a key variable to each key, storing the second level information from the low bit of the key variable, wherein the key variable occupies a plurality of storage spaces;

[0032] The second level information stored in the key variable corresponding to each key is shifted one bit higher, and calculation information is supplemented at the lower bit.

[0033] In the above technical solution, a key variable is assigned to each key to achieve a one-to-one correspondence between the key and the key variable, and also a one-to-one correspondence between the key variable and the storage variable. The calculation information is supplemented by storing the key variable in the low position and shifting it one position to the left of the high position, which is conducive to the subsequent calculation of the latest stored key status based on the calculation information.

[0034] In some embodiments of the present application, after calculating the calculation information and the first level information to obtain a calculation result, replacing the calculation information with the calculation result as the second level information, and storing the result in the key variable, the method further includes:

[0035] During the preset filtering time, when a preset number of identical key states do not appear continuously in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is invalid.

[0036] In the above technical solution, if a preset number of identical key states do not appear continuously in the key variable, it indicates an incorrect touch, and the key state change is invalid.

[0037] In some embodiments of the present application, the preset filtering time is 40ms, which is a commonly set filtering time and can fully demonstrate that key detection within this time is reliable.

[0038] In a second aspect, an embodiment of the present application provides a multi-button device, the multi-button device comprising: a button;

[0039] A key trigger circuit comprises an input end and an output end, wherein the input end of the key trigger circuit is connected to the key;

[0040] A controller comprising at least one key detection pin, wherein the at least one key detection pin is connected to an output end of the key trigger circuit;

[0041] Wherein, the controller includes:

[0042] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor so as to enable the at least one processor to execute the multi-key detection method according to any one of claims 1 to 8.

[0043] In a third aspect, an embodiment of the present application provides a multi-key system, comprising: a transmission bus;

[0044] a main controller connected to the transmission bus;

[0045] In the multi-button device according to the second aspect, each of the multi-button devices is connected to the transmission bus.

[0046] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0047] 1. Due to the adoption of a technical means of storing first level information in a storage variable, reading the first level information from the storage variable at a preset time interval, performing calculation processing on the first level information and the calculation information supplemented by the low-bit of the key variable, storing the calculation result in the key variable, and then determining whether the key state change is effective by the consecutive occurrence of a preset number of the same key state in the key variable, the problem of multiple judgment branches and low execution efficiency in the related art is effectively solved. The embodiment of the present application can effectively avoid multiple branches and improve execution efficiency.

[0048] 2. The level information of each key is stored through storage variables and key variables to ensure that multiple keys can be operated in parallel with fast response speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 This is a flowchart of a multi-key detection method provided by an embodiment of the present application;

[0050] Figure 2 yes Figure 1 A schematic flow chart of a sub-step of step S100;

[0051] Figure 3 yes Figure 1 A schematic flow chart of a sub-step of step S300;

[0052] Figure 4 yes Figure 1 A schematic flow chart of a sub-step of step S400;

[0053] Figure 5 yes Figure 1A schematic flow chart of a sub-step of step S500;

[0054] Figure 6 This is a diagram showing the correspondence between key states and bn values ​​provided by an embodiment of the present application;

[0055] Figure 7 This is a schematic diagram of module connections of a multi-button device provided by one embodiment of the present application;

[0056] Figure 8 This is a schematic diagram of module connections of a multi-button system provided in one embodiment of the present application. DETAILED DESCRIPTION

[0057] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.

[0058] In the description of the embodiments of this application, words such as "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "for example" or "for instance" in the embodiments of this application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "for example" or "for instance" is intended to present the relevant concepts in a concrete manner.

[0059] In the description of the embodiments of the present application, the term "multiple" means two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0060] In related technologies, key acquisition is first performed by reading the state of the microcontroller unit (MCU) pin level. For ease of description, the default state of a key is set to a high level, indicating a non-pressed state. When a low level is detected on the key, it is considered to be pressed, and the press filter phase begins. When the press time reaches the filter threshold, the key is considered to be effectively pressed. When a high level is detected on the key, it is considered to be released, and the release filter phase begins. When the release time reaches the filter threshold, the key is considered to be effectively released. After processing one key, the next key is processed immediately, and this cycle repeats. When there are multiple keys, the later the key is executed, the slower the response.

[0061] Based on this, an embodiment of the present application provides a multi-key detection method and a multi-key device and a multi-key system thereof. The multi-key detection method obtains first-level information of multiple keys, where the first-level information is used to indicate the key state, and stores the first-level information in a preset storage variable, which is beneficial for preserving the key state and facilitating subsequent acquisition of the real-time key state; based on a preset time interval, periodically reads the first-level information corresponding to each key from the storage variable, and after the time interval, the real-time key state can be obtained; a key variable is assigned to each key, and the second-level information stored in the key variable corresponding to each key is shifted to the high bit by a preset number of bits, and calculation information is supplemented in the low bit of the key variable; the calculation information and the first-level information are calculated to obtain a calculation result, and the calculation result is used as the second-level information to replace the calculation information and stored in the key variable, which is beneficial for subsequent determination of whether the key state is valid according to the stored value in the key variable; within a preset filtering time, when a preset number of identical key states appear consecutively in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is valid. The validity of the key state change is determined by the consecutive occurrence of the preset number of identical key states, avoiding counting multiple count values, thereby avoiding a large number of branches, and improving execution efficiency. Compared with the prior art with many judgment branches and low execution efficiency, the embodiment of the present application saves the first level information by storing variables to store the status of multiple buttons, obtains the first level information at a preset time interval, and performs calculation processing with the calculation information supplemented by the low bit of the button variable, and then determines that the button status change is valid through the continuous occurrence of a preset number of the same button status, which can effectively avoid too many branches and improve execution efficiency.

[0062] It should be noted that the multi-key detection method is applied to key detection devices in automobiles, especially to the detection of multiple keys on various functional control panels in the automobile field. As there are many types of automobiles, the method can be applied to different types of automobiles and has a wide range of applications.

[0063] The technical solutions provided in the embodiments of the present application are further described below in conjunction with the accompanying drawings.

[0064] Reference Figure 1 , Figure 1 1 is a flow chart of a multi-key detection method provided by an embodiment of the present application. The multi-key detection method is applied to a multi-key device and includes steps S100, S200, S300, S400, and S500.

[0065] Step S100 : acquiring first level information of a plurality of keys, and storing the first level information in a preset storage variable, wherein the first level information is used to indicate a key state.

[0066] In one embodiment, the first level information is used to indicate the state of a key. By reading the level transition state of the microcontroller pin to obtain the first level information of multiple keys, the key state can be obtained. The first level information is stored in a preset storage variable. The storage variable can reflect the key state of each key, which is convenient for subsequently reading the first level information from the storage variable to determine whether the change in the key state is valid. By storing the first level information of each key in the storage variable, the level information of all keys can be saved, which is convenient for subsequent parallel processing and improves execution efficiency. Among them, the storage variable can be an array, a dictionary, a list, etc., as long as it can achieve the correspondence between the key and the first level information. It will not be described in detail here. The first level information includes a high level and a low level, and the key state includes a pressed state and a released state. A low level can indicate a pressed state and a high level indicates a released state, or a high level can indicate a pressed state and a low level indicates a released state. It is agreed that a low level indicates a pressed state and a high level indicates a released state. The following embodiments are described.

[0067] like Figure 2 As shown, storing the first level information in a preset storage variable includes but is not limited to the following steps:

[0068] Step S110: number each button, and the number corresponds to the subscript of the storage variable.

[0069] In a possible embodiment of the present application, each key is numbered. For example, there are 4 keys, and each key corresponds to a corresponding number. The number corresponds to the subscript of the storage variable, which is conducive to the correspondence between the key and the first level information in the storage variable, and facilitates the subsequent acquisition of the first level information corresponding to each key. For example, the storage variable is represented by an array, and the array is represented as arr. Then, arr[0] represents key 1, arr[1] represents key 2, arr[2] represents key 3, and arr[3] represents key 4.

[0070] Step S120: When the key is in a pressed state, the low level is stored in the space corresponding to the subscript of the storage variable corresponding to the key.

[0071] In a possible embodiment of the present application, when the button is in a pressed state, the pressed state is represented as 1, and the low level is stored in the space corresponding to the subscript of the storage variable corresponding to the button, which is conducive to subsequently reading the first level information from the storage variable, thereby determining whether the change in the button state is valid.

[0072] Step S130 , when the key is in the released state, the high level is stored in the space corresponding to the subscript of the storage variable corresponding to the key.

[0073] In a possible embodiment of the present application, when the key is in a released state, the released state is represented as 0, and the high level is stored in the space corresponding to the subscript of the storage variable corresponding to the key, which is conducive to subsequently reading the first level information from the storage variable, thereby determining whether the change in the key state is valid.

[0074] For example, there are four keys 1, 2, 3 and 4, arr[0] represents key 1, arr[1] represents key 2, arr[2] represents key 3, and arr[3] represents key 4. If key 1 is in the released state, key 2 is in the pressed state, key 3 is in the released state, and key 4 is in the pressed state, then arr[0]=0, arr[1]=1, arr[2]=0, and arr[3]=1.

[0075] Step S200: periodically reading first level information corresponding to each key from a storage variable based on a preset time interval.

[0076] In one embodiment, the preset time interval may be 4, 5, or 8 ms. At the preset time interval, the first level information corresponding to each key is periodically read from the storage variable, and the reading can be performed in parallel, thereby improving reading efficiency. By reading the first level information at the preset time interval, the number of readings can be reduced while still being able to determine the key status.

[0077] Step S300: assign a key variable to each key, shift the second level information stored in the key variable corresponding to each key to the higher bit by a preset number of bits, and supplement the calculation information in the lower bit of the key variable.

[0078] In one embodiment, the first-level information of each key is stored in a storage variable, and a key variable is assigned to each key. The key variable occupies multiple storage spaces to record the key state changes of each key. The key variable is represented by a queue, and the second-level information of each key is stored in the key variable queue in a first-in, first-out manner, so that the latest key state is stored at the end of the storage variable queue. The second-level information stored in the key variable corresponding to each key is shifted to the higher position by a preset number of bits, leaving a storage bit at the lower position at the end. The calculation information is supplemented in the lower position of the key variable, which facilitates the subsequent storage of updated key states in the key variable.

[0079] like Figure 3 As shown, a key variable is assigned to each key, the second level information stored in the key variable corresponding to each key is shifted to the high position by a preset number of bits, and the calculation information is supplemented in the low position of the key variable, including but not limited to the following steps:

[0080] Step S310: Allocate a key variable to each key, and store the second level information from the low bit of the key variable, wherein the key variable occupies multiple storage spaces.

[0081] In one possible embodiment of the present application, a key variable is assigned to each key. The key variable occupies multiple storage spaces, providing sufficient space for data storage to avoid overflow issues. Because the key variable is represented by a queue, the second-level information of each key is first-in-first-out, and the second-level information is stored starting from the low bit of the key variable, which facilitates the subsequent movement of the second-level information.

[0082] Step S320 , shifting the second level information stored in the key variable corresponding to each key one bit higher, and supplementing the calculation information at the lower bit.

[0083] In one possible embodiment of the present application, since the high level and the low level can be represented by a single binary bit, the preset number of bits is one. The second level information stored in the key variable corresponding to each key is shifted one bit higher, and calculation information is added to the lower bit so that the calculation information can be subsequently calculated with the first level information, ensuring that the information stored in the lower bit is the latest key state.

[0084] Step S400 , calculating the calculation information and the first level information to obtain a calculation result, and using the calculation result as the second level information to replace the calculation information, and storing the result in the key variable.

[0085] In one embodiment, the calculation information and the first level information are calculated to obtain a calculation result, which is conducive to storing the latest key state obtained in the key variable. By replacing the calculation information with the calculation result as the second level information and storing it in the key variable, it is ensured that the information stored in the low position is the latest key state.

[0086] like Figure 4 As shown, calculating the calculation information and the first level information to obtain a calculation result includes but is not limited to the following steps:

[0087] Step S410: setting the calculation information and the first level information to have the same data format.

[0088] In one possible embodiment of the present application, the data format of the calculation information is first set according to the data format of the first level information, so that the calculation information can be operated on with the first level information. For example, the first level information includes a high level and a low level, with the high level represented by 0 and the low level represented by 1. The calculation information is supplemented with 0. This does not affect the original stored content and allows subsequent calculation processing.

[0089] Step S420 , performing an OR operation on the calculation information and the first level information to obtain an operation result.

[0090] In a possible embodiment of the present application, according to the setting of step S410, since the binary OR operation is 1 if there is 1 and 0 if there is no 1, the supplementary calculation information is set to 0, and the calculation information and the first level information are ORed to obtain the operation result, which can ensure that the latest stored key state is accurate.

[0091] For example, there are four keys 1, 2, 3, and 4. arr[0] represents key 1, arr[1] represents key 2, arr[2] represents key 3, and arr[3] represents key 4. If key 1 is in the released state, key 2 is in the pressed state, key 3 is in the released state, and key 4 is in the pressed state, then arr[0]=0, arr[1]=1, arr[2]=0, and arr[3]=1. Each key corresponds to a key variable, which is represented by bn. b1 represents key 1, b2 represents key 2, b3 represents key 3, and b4 represents key 4. b1=0, b2=1, b3=0, and b4=1. When key 3 is pressed, the key state changes from the released state to the pressed state, arr[2]=1, and then the first level information of key 3 in the storage variable is obtained as 1. The key variable b3 is obtained based on key 3. At this time, b3 is shifted left by one bit and the calculation information 0 is added, so b3=00. The calculation information 0 is ORed with the first level information 1 to obtain a result of 1. The calculation information in b3 is replaced with 1, so b3 = 01. Reading data at preset time intervals can obtain more continuous key states, which is helpful for subsequent determination of whether the state change is valid.

[0092] Step S500 : During a preset filtering time, when a preset number of identical key states appear continuously in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is valid.

[0093] In one embodiment, the preset filtering time is 40ms, and can also be set to 50ms. In the embodiment of the present application, it is set to 40ms. Within the preset filtering time, the preset number is calculated based on the time interval. Specifically, the preset number is obtained by dividing the filtering time by the time interval. This facilitates the subsequent determination of the validity of the key state change. For example, if the time interval is set to 5ms, the preset number is 40 / 5 = 8.

[0094] In another embodiment, based on the update of the key variable in step S400, when a preset number of identical key states appear consecutively in the key variable corresponding to the key during the filtering time, indicating that the key state has not changed, the key state change corresponding to the key is detected to be valid. This avoids multiple branches generated by counting multiple values, thereby improving execution efficiency.

[0095] like Figure 5 As shown, when a preset number of identical key states appear continuously in the key variable corresponding to the key, detecting that the key state change corresponding to the key is valid includes but is not limited to the following steps:

[0096] In step S510 , when a preset number of identical pressing states appear continuously in the key variable corresponding to the key, it is detected that the pressing state change corresponding to the key is valid.

[0097] In one possible embodiment of the present application, if eight consecutive occurrences of the same pressed state appear in the key variable corresponding to a key, it indicates that the key has maintained the same pressed state after the key state change, and is always in the pressed state. In this case, the pressed state change corresponding to the key is detected to be valid, i.e., the press operation is valid. This avoids multiple branches generated by counting multiple values, thereby improving execution efficiency.

[0098] In step S520 , when a preset number of identical release states appear continuously in the key variable corresponding to the key, it is detected that the change in the release state corresponding to the key is valid.

[0099] In one possible embodiment of the present application, if eight consecutive occurrences of the same pressed state appear in the key variable corresponding to a key, it indicates that the key has maintained the same pressed state after the key state change and has been in the released state. In this case, the release state change corresponding to the key is detected to be valid, i.e., the release operation is valid. This avoids multiple branches generated by counting multiple values, thereby improving execution efficiency.

[0100] For example, if key 3 is pressed and eight consecutive identical 1s appear in the key variable b3 corresponding to key 3, it means that key 3 is pressed effectively. b3 is represented as 0101011111111, indicating that key 3 is pressed. If key 3 is released, b3 is represented as 010101111111100000000, indicating that key 3 is released.

[0101] In a possible embodiment of the present application, when the time interval is set to 8ms, five consecutive identical key states appear in the key variable corresponding to the key detection key to determine whether the state change is valid, which will not be elaborated here.

[0102] In a possible embodiment of the present application, according to the update of the key variable in step S400, during the preset filtering time, when the preset number of identical key states do not appear continuously in the key variable corresponding to the key, it indicates that the key state has changed again, and then the key state change corresponding to the key is detected to be invalid, which may be a false touch, or other situations. It avoids multiple branches generated by counting multiple values, and can improve execution efficiency. For example, if key 3 is touched by mistake, b3 is represented as 01010, and the preset number of identical key states do not appear continuously, then the key operation is invalid. For example, the corresponding relationship between the key input and the value of each stage of bn is as follows: Figure 6 shown.

[0103] like Figure 7As shown, the multi-button device includes a button 10, a button trigger circuit 20, and a controller 30. The multi-button device is a device for inputting commands and data used to operate a device. The multi-button device can be fixed to the device or connected to the device via a cable. For example, an input / output device such as a display screen generates corresponding commands and data by clicking a single button 10 or clicking several buttons 10 in sequence, receives and processes the commands and data, and transmits the operating status to the display screen, which displays the commands and data, as well as the operating status.

[0104] In one embodiment, the key trigger circuit 20 includes an input terminal and an output terminal. The input terminal of the key trigger circuit 20 is connected to the key 10, and the output terminal of the key trigger circuit 20 is connected to the controller 30. The controller 30 includes at least one key detection pin, and the at least one key detection pin is connected to the output terminal of the key trigger circuit 20.

[0105] The controller 30 includes at least one processor and a memory in communication with the at least one processor. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the multi-key detection method disclosed in any of the above embodiments. The multi-key detection method obtains first level information of multiple keys, the first level information is used to indicate the key status, and the first level information is stored in a preset storage variable, which is conducive to preserving the key status and facilitating the subsequent acquisition of the real-time key status; based on a preset time interval, the first level information corresponding to each key is periodically read from the storage variable, and the real-time key status can be obtained after the time interval; a key variable is assigned to each key, the second level information stored in the key variable corresponding to each key is shifted to the high bit by a preset number of bits, and calculation information is supplemented in the low bit of the key variable; the calculation information and the first level information are calculated to obtain a calculation result, and the calculation result is used as the second level information to replace the calculation information and stored in the key variable, which is conducive to subsequently determining whether the key status is valid according to the stored value in the key variable; within a preset filtering time, when a preset number of identical key states appear continuously in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is valid. The validity of the key state change is determined by the continuous occurrence of the preset number of identical key states, avoiding the counting of multiple count values, thereby avoiding a large number of branches, and improving execution efficiency.

[0106] The processor may include one or more processing cores. The processor utilizes various interfaces and circuits to connect various components within the server. It executes instructions, programs, code sets, or instruction sets stored in memory, and accesses data stored in memory to perform various server functions and process data. Optionally, the processor may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing content displayed on the display; and the modem handles wireless communications. It is understood that the modem may also be implemented as a separate chip, rather than integrated into the processor.

[0107] The memory may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory includes non-transitory computer-readable storage medium. The memory may be used to store instructions, programs, code, code sets, or instruction sets. The memory may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned method embodiments, etc.; the data storage area may store data involved in the above-mentioned method embodiments, etc. The memory may also optionally be at least one storage device located remotely from the aforementioned processor.

[0108] The processor can be used to call an application program storing a multi-key detection method in a memory. When executed by one or more processors, the multi-key device executes one or more methods in the above-mentioned embodiments. It should be noted that for the aforementioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited to the described order of actions, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for this application.

[0109] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0110] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are merely schematic, such as the division of units, which is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interface, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0111] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0112] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0113] like Figure 8 As shown, the multi-button system includes a transmission bus 40, a main controller 50, and a plurality of multi-button devices as disclosed in any of the above embodiments.

[0114] In one embodiment, the multi-key device is a basic processing unit of the multi-key system, which is used to independently process key events and upload key detection and execution results to the main controller 50 through the transmission bus 40. The main controller 50 is used to store, manage and control the key detection and execution results.

[0115] It should also be noted that the above embodiments provide devices that implement their functions using only the division of the above functional modules as examples. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0116] The above are merely exemplary embodiments of the present disclosure and are not intended to limit the scope of the present disclosure. In other words, any equivalent variations and modifications made in accordance with the teachings of the present disclosure are still within the scope of the present disclosure. Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the disclosure and the practical implications thereof.

[0117] This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not described herein. The description and examples are to be considered as exemplary only, and the scope and spirit of the present disclosure are to be defined by the claims.

Claims

1. A multi-key detection method, characterized in that: The method comprises: Acquire first level information of a plurality of keys, and store the first level information in a preset storage variable, wherein the first level information is used to indicate a key state; Based on a preset time interval, periodically reading the first level information corresponding to each key from the storage variable; Allocating a key variable to each key, shifting the second level information stored in the key variable corresponding to each key toward a higher position by a preset number of bits, and supplementing the calculation information in a lower position of the key variable; Calculating the calculation information and the first level information to obtain a calculation result, replacing the calculation information with the calculation result as the second level information, and storing the result in the key variable; During the preset filtering time, when a preset number of identical key states appear continuously in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is valid.

2. The method according to claim 1, characterized in that The calculating the calculation information and the first level information to obtain a calculation result includes: Setting the calculation information and the first level information to have the same data format; Perform an OR operation on the calculation information and the first level information to obtain a calculation result.

3. The method according to claim 1, characterized in that The button state includes a pressed state and a released state; When a preset number of identical key states appear continuously in the key variable corresponding to the key, detecting that the key state change corresponding to the key is valid includes: When a preset number of identical pressed states appear continuously in the key variable corresponding to the key, it is detected that the pressed state change corresponding to the key is valid; When a preset number of identical release states appear continuously in the key variable corresponding to the key, it is detected that the change in the release state corresponding to the key is valid.

4. The method according to claim 3, characterized in that The first level information includes a high level and a low level, the low level indicates a pressed state, and the high level indicates a released state; The step of storing the first level information in a preset storage variable includes: Numbering each of the buttons, wherein the number corresponds to the subscript of the storage variable; When the key is in the pressed state, storing the low level in a space corresponding to the subscript of the storage variable corresponding to the key; When the key is in the released state, the high level is stored in the space corresponding to the subscript of the storage variable corresponding to the key.

5. The method according to claim 1 or 3, characterized in that The preset number is obtained by the following steps: During the preset filtering time, the preset number is calculated according to the time interval.

6. The method according to claim 1, wherein The step of allocating a key variable to each key, shifting the second level information stored in the key variable corresponding to each key to a higher position by a preset number of bits, and supplementing the calculation information in the lower position of the key variable includes: Allocating a key variable to each key, storing the second level information from the low bit of the key variable, wherein the key variable occupies a plurality of storage spaces; The second level information stored in the key variable corresponding to each key is shifted one bit higher, and calculation information is supplemented at the lower bit.

7. The method according to claim 1, characterized in that After calculating the calculation information and the first level information to obtain a calculation result, replacing the calculation information with the calculation result as the second level information, and storing the result in the key variable, the method further includes: During the preset filtering time, when a preset number of identical key states do not appear continuously in the key variable corresponding to the key, it is detected that the key state change corresponding to the key is invalid.

8. The method according to claim 1, characterized in that The default filtering time is 40ms.

9. A multi-button device, characterized in that: include: button; A key trigger circuit comprises an input end and an output end, wherein the input end of the key trigger circuit is connected to the key; A controller comprising at least one key detection pin, wherein the at least one key detection pin is connected to an output end of the key trigger circuit; Wherein, the controller includes: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor so as to enable the at least one processor to execute the multi-key detection method according to any one of claims 1 to 8.

10. A multi-button system, characterized in that: include: Transmission bus; a main controller connected to the transmission bus; The multi-button device as claimed in claim 9, wherein each of the multi-button devices is connected to the transmission bus.

Citation Information

Patent Citations

  • Key driving method and device

    CN106972863A

  • Code switch detection method, computer storage medium and equipment

    CN114113993A