CN115291548A - Method for realizing multiple key states based on single key coding - Google Patents
Method for realizing multiple key states based on single key coding Download PDFInfo
- Publication number
- CN115291548A CN115291548A CN202210934033.8A CN202210934033A CN115291548A CN 115291548 A CN115291548 A CN 115291548A CN 202210934033 A CN202210934033 A CN 202210934033A CN 115291548 A CN115291548 A CN 115291548A
- Authority
- CN
- China
- Prior art keywords
- key
- code
- coding
- states based
- combined
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B19/00—Programme-control systems
- G05B19/02—Programme-control systems electric
- G05B19/04—Programme control other than numerical control, i.e. in sequence controllers or logic controllers
- G05B19/042—Programme control other than numerical control, i.e. in sequence controllers or logic controllers using digital processors
- G05B19/0423—Input/output
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B2219/00—Program-control systems
- G05B2219/20—Pc systems
- G05B2219/24—Pc safety
- G05B2219/24215—Scada supervisory control and data acquisition
Abstract
The invention relates to the technical field of electrical equipment, in particular to a method for realizing multiple key states based on single-key coding, wherein keys are connected with an MCU (microprogrammed control unit), and the method comprises the following steps: setting a time threshold T, defining the key pressing duration shorter than T as a short key pressing code, and defining the key pressing duration not shorter than T as a long key pressing code; setting the number n of key codes of keys contained in the combined code, and disclosing T and n; making a combined coding state table, exhaustively combining codes and defining corresponding key states; periodically detecting the key state to obtain an effective key code; combining the obtained effective key codes into a combined code within a preset input time length; and looking up the combined coding state table to obtain the key state corresponding to the combined coding. The beneficial technical effects of the invention comprise: by the coding scheme disclosed by the invention, the operation and identification of various case states can be realized by a single key, so that the single key can trigger various responses, and the equipment interaction is facilitated.
Description
Technical Field
The invention relates to the technical field of electrical equipment, in particular to a method for realizing multiple key states based on single key coding.
Background
Most products on the market at present have a man-machine interaction function, wherein the keys are relatively simple and friendly interaction devices. For a product with only one key and without liquid crystal display matching, two operation states of short pressing and long pressing can be generally realized to realize two event triggering operations. However, in some special use scenarios, the situation that more than 2 operation states are required to be realized by a single key may occur, even 8 states or more occur, and the identification and distinction of the key states are not easily realized by a single key. If the key states are distinguished only by long-press timing time, the problem that the user cannot correctly estimate the required long-press time, the operation is difficult and false triggering is easily caused occurs. It is therefore necessary to develop a method of operation and identification that achieves reliable multiple key states with a single key.
For example, chinese patent CN114326512A, published 2022, 4 and 12, discloses a multifunctional three-in-one coding transmitter, which comprises a coder operating system. The operation method of the multifunctional three-in-one coding transmitter and the coder operation system is as follows: the method comprises the following steps: the eight-digit dialing module is switched, the lock key and the lower key are simultaneously pressed, the eight-digit dialing module is switched, after the switching is finished, the upper key is pressed to carry out plus dialing input, the lower key is pressed to carry out minus dialing input, the stop key is pressed to carry out blank dialing input, 8-digit dialing is input, an indicator light flickers for three times after the inputting is finished, and the eight-digit dialing module is connected; step two: the million fixed code module is used for switching the million fixed code module when the lock button and the upper button are pressed simultaneously, and the million fixed code is automatically regulated and controlled by the single chip processor after the switching is finished; step three: and the copying code module is used for switching the copying code after the upper key and the lower key are simultaneously pressed for 5s, and key copying is carried out by pressing a copying object and a corresponding key on the coding control system after the switching is finished. The technical scheme can not solve the problems of operation and identification of multiple key states under the condition of a single key.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the problem that a single key is lack of a technology for realizing operation and identification of multiple key states at present. The method for realizing multiple key states based on single key codes is provided, can realize the operation codes of single key and identify multiple key states, and provides richer key function responses.
To solve the technical problem, the invention adopts the following technical scheme: a method for realizing multiple key states based on single-key coding is provided, wherein the key is connected with an MCU, and the method comprises the following steps:
setting a time threshold T, defining the key pressing time length shorter than T as a short key pressing code, and defining the key pressing time length not shorter than T as a long key pressing code;
setting the number n of key codes of keys contained in the combined code, and disclosing T and n;
making a combined coding state table, exhaustively combining codes and defining corresponding key states;
periodically detecting the key state to obtain an effective single-key code;
combining the obtained effective key codes into a combined code within a preset input duration;
and looking up the combined coding state table to obtain the key state corresponding to the combined coding.
Preferably, the method of obtaining a valid one-time-key code includes:
when the MCU detects a pin level signal pressed by a key, filtering signal jitter, and waiting for a preset time t1;
after the time length t1, if the MCU still detects a pin level signal pressed by the key, the state of the pin level connected with the key is detected in a period t2, otherwise, the detection of the key code of the key is finished;
if the time length T is long, the MCU still detects a pin level signal pressed by the key, and then judges that an effective long-key-press key code is received, otherwise, judges that an effective short-key-press code is received.
Preferably, the method for filtering out the signal jitter comprises the following steps: and the MCU filters out the jitter signal by a time delay method.
Preferably, the delay time is 50 milliseconds.
Preferably, the preset time period t1 is between 50 milliseconds and 100 milliseconds.
Preferably, the preset time period t1 is 50 milliseconds.
Preferably, the period t2 takes a value between 1 ms and 10 ms.
Preferably, the period t2 is 1 millisecond.
Preferably, the time threshold T is 3 seconds; the combination code contains a number n of key codes equal to 3.
Preferably, the operator is prompted by an indicator light when a valid one-time key code is obtained.
The beneficial technical effects of the invention comprise: by the coding scheme disclosed by the invention, the operation and identification of various case states can be realized by a single key, so that the single key can trigger various responses, and the equipment interaction is facilitated.
Other features and advantages of the present invention will be disclosed in more detail in the following detailed description of the invention and the accompanying drawings.
Drawings
The invention is further described with reference to the accompanying drawings:
fig. 1 is a schematic flow chart of a method for implementing multiple key states by single-key coding according to an embodiment of the present invention.
FIG. 2 is a flowchart illustrating a method for obtaining an effective one-time-key code according to an embodiment of the present invention.
FIG. 3 is a pin level diagram of a single keystroke according to an embodiment of the present invention.
Wherein, 1, a shaking area, 2, a short key code, and 3, a long key code.
Detailed Description
The technical solutions of the embodiments of the present invention are explained and illustrated below with reference to the drawings of the embodiments of the present invention, but the following embodiments are only preferred embodiments of the present invention, and not all embodiments. Based on the embodiments in the implementation, other embodiments obtained by those skilled in the art without any creative effort belong to the protection scope of the present invention.
In the following description, the appearances of the indicating orientation or positional relationship such as the terms "inner", "outer", "upper", "lower", "left", "right", etc. are only for convenience in describing the embodiments and for simplicity in description, and do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and are not to be construed as limiting the present invention.
A method for implementing multiple key states based on single-key coding, wherein a key is connected to an MCU, with reference to fig. 1, the method comprising:
step A01) setting a time threshold value T, defining the key pressing time length shorter than T as a short key pressing code 2, and defining the key pressing time length not shorter than T as a long key pressing code 3;
step A02) setting the number n of key codes contained in the combined code, and disclosing T and n;
step A03), a combined coding state table is manufactured, combined coding is exhausted, and corresponding key states are defined;
step A04) periodically detecting the key state to obtain an effective single-key code;
step A05), the obtained effective key codes are combined into a combined code within a preset input duration;
and A06) checking the combined coding state table to obtain the key state corresponding to the combined coding.
In this embodiment, the time threshold T is 3 seconds; the combination code includes a number n of key codes equal to 3. The short-key code 2 is denoted by 0, the long-key code 3 is denoted by 1, and the relationship between the single-key code and the combined code is shown in table 1.
TABLE 1 Combined coding State Table
And the identification scheme can associate at most 8 responses through a single key, enrich the functions of the keys and facilitate the interaction of the equipment.
Referring to fig. 2, a method for obtaining a valid one-time-key code includes:
step B01), when the MCU detects a pin level signal pressed by a key, filtering signal jitter, and waiting for a preset time period t1;
step B02) after the time length t1, the MCU still detects a pin level signal pressed by the key, detects the state of the pin level connected with the key in a period t2, otherwise, finishes the detection of the key code of the key;
and B03) if the MCU still detects a pin level signal of the pressed key during the time length T, judging that an effective long-press key code 3 is received, otherwise, judging that an effective short-press key code is received.
Please refer to fig. 3, which illustrates a method for filtering signal jitter: the MCU filters out the jitter signals through a time delay method. More advantageously, the delay is 50 milliseconds. As shown in fig. 3, the jitter area 1 is configured such that when the MCU first detects a low level, it waits for 50 ms and then detects again, and if a low level is still detected, the detection of the key is formally started. If the high level is detected after waiting for 50 milliseconds, the pressing is judged to be jitter, and no operation is performed. After the detection of the key is formally started, the level of the pin is collected every 1 millisecond, if the high level is collected within 3 seconds, the key is pressed for a short time to generate a short key code 2, and if the high level is not collected within 3 seconds, the key is pressed for a long time to generate a long key code 3. In this embodiment, the timing start point of 3 seconds is the time when the MCU first detects a low level.
The preset time period t1 is between 50 milliseconds and 100 milliseconds. More advantageously, the preset time period t1 is 50 milliseconds.
The period t2 takes a value between 1 millisecond and 10 milliseconds. More advantageously, the period t2 is 1 millisecond.
When the effective single-time key code is obtained, the operator is prompted through the indicating lamp. The indicator light indicates in a first state when a first valid one-time key code is obtained, indicates in a second state when a second valid one-time key code is obtained, and indicates in a third state when a third valid one-time key code is obtained. In this embodiment, the color of the indicator light is used as the indication state. The indicator light is a color LED light capable of displaying at least 3 colors, such as red, green and yellow, or two single color LED lights each displaying a single color, such as red and green. When adopting colored LED lamp, when first effective single button key code was obtained, the pilot lamp lighted red, when second effective single button key code was obtained, the pilot lamp closed red and lighted green, when third effective single button key code was obtained, the pilot lamp closed green and lighted yellow. When adopting two monochromatic LED lamps, when first effective single key-press key code was obtained, the pilot lamp lighted red, when second effective single key-press key code was obtained, the pilot lamp closed red and lighted green, when third effective single key-press key code was obtained, red and green were lighted simultaneously to the pilot lamp.
The beneficial technical effects of the embodiment include: by the coding scheme disclosed by the invention, the operation and identification of various case states can be realized by a single key, so that the single key can trigger various responses, and the equipment interaction is facilitated.
While the invention has been described with reference to specific embodiments thereof, it will be understood by those skilled in the art that the invention is not limited thereto, and may be embodied in many different forms without departing from the spirit and scope of the invention as set forth in the following claims. Any modification which does not depart from the functional and structural principles of the present invention is intended to be included within the scope of the claims.
Claims (10)
1. A method for realizing multiple key states based on single-key coding is characterized in that the keys are connected with an MCU,
the method comprises the following steps:
setting a time threshold T, defining the key pressing duration shorter than T as a short key pressing code, and defining the key pressing duration not shorter than T as a long key pressing code;
setting the number n of key codes of keys contained in the combined code, and disclosing T and n;
making a combined coding state table, exhaustively combining codes and defining corresponding key states;
periodically detecting the key state to obtain an effective single-key code;
combining the obtained effective key codes into a combined code within a preset input duration;
and looking up the combined coding state table to obtain the key state corresponding to the combined coding.
2. The method for realizing multiple key states based on single-key coding according to claim 1,
the method for obtaining the valid one-time-key code comprises the following steps:
when the MCU detects a pin level signal pressed by a key, filtering signal jitter, and waiting for a preset time period t1;
after the time length t1, if the MCU still detects a pin level signal pressed by the key, the state of the pin level connected with the key is detected in a period t2, otherwise, the detection of the key code of the key is finished;
if the time length T is long, the MCU still detects a pin level signal pressed by the key, and then judges that an effective long-key-press key code is received, otherwise, judges that an effective short-key-press code is received.
3. The method of claim 2, wherein the key state is a plurality of key states based on a single-key code,
the method for filtering the signal jitter comprises the following steps: and the MCU filters out the jitter signal by a time delay method.
4. The method of claim 3, wherein the key state is a plurality of key states based on a single-key code,
the delay is 50 milliseconds.
5. The method for realizing multiple key states based on single-key coding according to any one of claims 2 to 4,
the preset time period t1 is between 50 milliseconds and 100 milliseconds.
6. The method for realizing multiple key states based on single-key coding according to any one of claims 2 to 4,
the preset time period t1 is 50 msec.
7. The method for realizing multiple key states based on single-key coding according to any one of claims 2 to 4,
the period t2 takes a value between 1 millisecond and 10 milliseconds.
8. The method for realizing multiple key states based on single-key coding according to any one of claims 2 to 4,
the period t2 is 1 msec.
9. The method for realizing multiple key states based on single-key coding according to any one of claims 1 to 4,
the time threshold T is 3 seconds;
the combination code includes a number n of key codes equal to 3.
10. The method for realizing multiple key states based on single-key coding according to any one of claims 1 to 4,
when the effective single-time key code is obtained, the operator is prompted through the indicating lamp.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210934033.8A CN115291548A (en) | 2022-08-04 | 2022-08-04 | Method for realizing multiple key states based on single key coding |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210934033.8A CN115291548A (en) | 2022-08-04 | 2022-08-04 | Method for realizing multiple key states based on single key coding |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115291548A true CN115291548A (en) | 2022-11-04 |
Family
ID=83826922
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210934033.8A Pending CN115291548A (en) | 2022-08-04 | 2022-08-04 | Method for realizing multiple key states based on single key coding |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115291548A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112000141A (en) * | 2020-07-10 | 2020-11-27 | 惠州市德赛西威汽车电子股份有限公司 | Shake removing method for knob encoder |
CN116820256A (en) * | 2023-08-28 | 2023-09-29 | 深圳市蓝晨科技股份有限公司 | Multi-cascade key detection method and device |
-
2022
- 2022-08-04 CN CN202210934033.8A patent/CN115291548A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112000141A (en) * | 2020-07-10 | 2020-11-27 | 惠州市德赛西威汽车电子股份有限公司 | Shake removing method for knob encoder |
CN116820256A (en) * | 2023-08-28 | 2023-09-29 | 深圳市蓝晨科技股份有限公司 | Multi-cascade key detection method and device |
CN116820256B (en) * | 2023-08-28 | 2023-12-08 | 深圳市蓝晨科技股份有限公司 | Multi-cascade key detection method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115291548A (en) | Method for realizing multiple key states based on single key coding | |
EP2156279B1 (en) | Button based color navigation method and device in a lighting or visualization system | |
KR19980023623A (en) | Remote control of complex function and control method of composite product | |
US20150133101A1 (en) | Terminal and method for activating terminal | |
RU2008144994A (en) | SWITCHING THE OPERATION MODE IN THE MOBILE COMMUNICATION TERMINAL | |
CN105630384A (en) | Method for starting application through multi-click event, and control system thereof | |
CN111885556A (en) | Fast Bluetooth adaptation method, system, remote controller, intelligent terminal and medium | |
CN109217859A (en) | Key disappears fluttering method, equipment and storage medium | |
CN109462767A (en) | One multi-functional realization method and system of key of television set | |
US10133363B2 (en) | Method of operating an electronic device | |
CN111182340A (en) | Terminal control method, terminal, device and computer-readable storage medium | |
CN110096394A (en) | Fault self-detection method, device, electrical equipment and computer readable storage medium | |
CN105511254A (en) | Intelligent watch integrated with drunk driving prevention system | |
US20180336749A1 (en) | Intelligent Lock and Use Method Thereof | |
CN106233411B (en) | Automation control device | |
CN105353601A (en) | Novel intelligent watch internally provided with drunk driving prevention safety system and device thereof | |
CN114518715A (en) | Control method of food processing machine and food processing machine | |
US20070091279A1 (en) | Projection display apparatus and method of preventing inadvertent input | |
CN111833909A (en) | Hard disk destruction triggering method and device, computer readable storage medium and system | |
US7178725B2 (en) | Method for visualizing the input and display components of terminal equipment and corresponding terminal equipment | |
JPH0775180A (en) | Remote controller | |
CN104423658A (en) | Method and device for lightening touch screen and mobile terminal | |
CN215867891U (en) | Fingerprint module, electronic equipment and vehicle | |
CN218888739U (en) | Color and color temperature control circuit | |
KR100229725B1 (en) | Telephone number certifying method of keyphone |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |