Coding switch detection method, computer storage medium and device
By detecting the signal output by the encoding switch port and forming a level combination, combined with the state machine configuration, the jitter and interference problems in the rotation direction determination of the encoding switch are solved, and stable and reliable rotation direction detection is achieved.
Patent Information
- Application Number
- CN202010868377.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-26
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2040-08-26
AI Technical Summary
The existing encoding switch detection method is prone to jitter and interference signals during rotation, leading to incorrect determination of the rotation direction.
By detecting the signals output by the first port and the second port of the encoding switch, the state changes of the level combination over time are formed. The rotation direction is first predetermined in a preset period, and then judged in another preset period. Combined with State machine configuration, serial signal changes to avoid incorrect judgments.
It effectively eliminates erroneous detection results caused by jitter and interference signals, achieves stable and reliable rotation direction determination, and improves detection accuracy and convenience.
Smart Images

Figure CN114113993B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of signal detection, and in particular to a coding switch detection method, a computer storage medium and a device. Background Art
[0002] Coding switches are often used in electronic products in production and life because of their advantages such as convenient parameter adjustment and long service life. With the increasing functions of electrical equipment, it is often necessary to use coding switches to set the working mode of electrical equipment, adjust the working parameters, etc., so as to solve the problems of cumbersome operation and poor experience when using ordinary buttons and switches. When using a coding switch, you usually only need to rotate the coding switch clockwise or counterclockwise to achieve mode switching and parameter adjustment of the electrical equipment.
[0003] When the coding switch rotates, the current operation is generally determined to be clockwise or counterclockwise by detecting the level state of the coding switch output port. A common coding switch detection method in the prior art is: when a level jump occurs at one of the output ports of the A-phase port and the B-phase port, the level of the other output port is detected. This coding switch detection method has the following problems: jitter and interference signals often occur when rotating the coding switch. When an erroneous level jump is detected, an erroneous judgment of clockwise or counterclockwise rotation will be made based on the level detected immediately. Summary of the invention
[0004] In view of the above problems, the present invention provides a coding switch detection method which can eliminate erroneous detection results caused by jitter and interference signals, and is convenient, fast, stable and reliable. A computer storage medium and device are also provided.
[0005] A technical means adopted by the present invention is to provide a coding switch detection method, comprising:
[0006] Detecting a first signal output from a first port of a coding switch and a second signal output from a second port of the coding switch;
[0007] In a first preset period, the rotation direction of the coding switch is predetermined according to the state change of the level combination formed by the first signal and the second signal over time; the level combination is formed by the level of the first signal and the level of the second signal at the same time in a preset order;
[0008] In a second preset period, the rotation direction of the encoding switch is determined in combination with the predetermined rotation direction of the encoding switch and according to the state change over time of the level combination formed by the first signal and the second signal.
[0009] Another technical means adopted by the present invention is: providing a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the coding switch detection method.
[0010] Another technical means adopted by the present invention is: providing a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the coding switch detection method.
[0011] Due to the adoption of the above technical scheme, the coding switch detection method, computer storage medium and device provided by the present invention detect the signal output by the coding switch port, obtain the level state change of the port signal over time, and determine whether the level state change of the port signal meets the preset change situation and conditions, and then determine the rotation direction of the coding switch. The configuration of the state machine can effectively connect the level state changes of the first signal and the second signal in the entire predetermined period in series. The present invention can determine the rotation direction of the coding switch according to the level state changes of the first signal and the second signal in the entire detection period, and can effectively eliminate the erroneous detection results caused by jitter and interference signals, and is convenient, fast, stable and reliable. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0013] in:
[0014] Figure 1 is a flow chart of a coding switch detection method in an embodiment;
[0015] Figure 2 is a flow chart of step 20 in one embodiment;
[0016] Figure 3 is a flow chart of step 30 in one embodiment;
[0017] Figure 4 is an internal structural diagram of a computer device in one embodiment;
[0018] Figure 5 is an exemplary diagram of a coding switch detection circuit in an embodiment;
[0019] Figure 6 is an example waveform diagram of a coding switch rotating clockwise in one embodiment;
[0020] Figure 7 The figure is an example waveform diagram of the counterclockwise rotation of the encoding switch in one embodiment. DETAILED DESCRIPTION
[0021] In order to make the purpose of the invention, technical scheme and technical effects of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described in this specification are only for explaining the present invention, not for limiting the present invention. In the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other.
[0022] The present invention provides a coding switch detection method, such as Figure 1 As shown, in one embodiment, the method may include:
[0023] Step 10: Detect a first signal output from a first port of a coding switch and a second signal output from a second port of the coding switch.
[0024] A coding switch is an electronic device that can rotate clockwise and counterclockwise, and can also be called a rotary coding switch. The coding switch mainly has three ports or pins, one of which is a ground port and the other two are signal ports. When the rotary coding switch rotates, pulse waves are usually emitted from two signal ports, namely the A phase port and the B phase port. Figure 6 As shown in the figure, when the encoder switch rotates clockwise, the pulse wave output from the A-phase port will lead the rectangular wave output from the B-phase port by 1 / 4 of the phase. Figure 7 As shown, when the encoding switch rotates counterclockwise, the pulse wave output by the B-phase port will lead the rectangular wave output by the A-phase port by 1 / 4 phase.
[0025] The first port may be an A-phase port, and the first signal is a signal output by the A-phase port of the coding switch; the second port may be a B-phase port, and the second signal is a signal output by the B-phase port of the coding switch.
[0026] For example, Figure 5 An example diagram of a coding switch detection circuit is shown, such as Figure 5As shown, the A-phase port of the coding switch S2 is connected to a 5V power supply via a pull-up resistor R105, and is output by a network number PH6 after passing through a resistor R108. The B-phase port is connected to a 5V power supply via a pull-up resistor R103, and is output by a network number PH7 after passing through a resistor R110. The network numbers PH6 and PH7 can be connected to a controller or processor such as a single-chip microcomputer, a CPU, and read by a controller or processor such as a single-chip microcomputer, a CPU, so as to obtain the pulse change state output by the coding switch port. The network number PH6 in the figure can be used to know the level state of the A-phase port of the coding switch, and the network number PH7 can be used to know the level state of the B-phase port of the coding switch.
[0027] When detecting the first port and the second port of the coding switch, a time base can be set to regularly read the level status of the first port and the second port, and the level status of the first port and the level status of the second port are detected at intervals based on the timing time base. The timing time base can be adjusted according to factors such as the actual output waveform of the coding switch and operation requirements.
[0028] Step 20, setting the state of the state machine and predetermining the rotation direction of the coding switch according to the state change of the level combination formed by the first signal and the second signal over time; the level combination is formed by the level of the first signal and the level of the second signal at the same time in a preset order.
[0029] Based on the detection results of the level state of the first port and the level state of the second port of the coding switch, the level of the first signal and the level of the second signal at the same time can be obtained. Step 20 can be performed within a first preset period, and the first preset period can be half the length of a predetermined period. Then, according to the state changes of the level of the first signal and the level of the second signal over time within 1 / 2 of the predetermined period, the rotation direction of the coding switch is predetermined, and the predetermined period is the detection period of the coding switch. The predetermined rotation direction of the coding switch refers to the result of a preliminary determination of the rotation direction of the coding switch based on the state change data of the level combination formed by the first signal and the second signal over time, for example, the preliminary determination of the rotation direction of the coding switch is clockwise or counterclockwise, and the preliminary determination result is obtained based on the state change data of the level combination over time within the first preset period.
[0030] The level combination is composed of the level of the first signal and the level of the second signal at the same time in a preset order, and can change over time. In the case where the first port is an A-phase port and the second port is a B-phase port, the preset order is that the level of the first signal is first and the level of the second signal is second. If the first port is a B-phase port and the second port is an A-phase port, the preset order is that the level of the second signal is first and the level of the first signal is second.
[0031] Exemplarily, assuming that the signal of the first level is at a high level and the level of the second signal is at a high level, the level combination is a high level high level. If the high level is represented by binary 1 and the low level is represented by binary 0, the level combination of high level high level can be represented as 11. After a period of time, the level of the first signal and the level of the second signal are detected again. Assuming that the signal of the first level is still at a high level and the level of the second signal is still at a high level, the formed level combination still remains at a high level high level. If the level state of the first signal and the second signal is detected again after a period of time, it is obtained that the signal of the first level is at a low level and the level of the second signal is at a high level, the formed level combination is updated to a low level high level, which is represented by 01 in binary. With the rotation of the coding switch, the level combination corresponding to different times may be the same or different. Based on the state change of the level combination over time, for example, the level combination of high level high level changes to the level combination of low level high level, or the level combination of high level high level changes to the level combination of high level low level, etc., the rotation direction of the coding is predetermined.
[0032] Step 30, combining the predetermined rotation direction of the coding switch and according to the state change of the level combination formed by the first signal and the second signal over time, setting the state of the state machine and determining the rotation direction of the coding switch.
[0033] The rotation direction of the coding switch can be clockwise or counterclockwise. When the rotation direction is clockwise, it means that the coding switch rotates clockwise, and when the rotation direction is counterclockwise, it means that the coding switch rotates counterclockwise.
[0034] Step 30 can be performed within a second preset period, the second preset period can be half the length of a predetermined period, the first preset period and the second preset period can constitute the entire predetermined period in chronological order, specifically, the first preset period is in front and the second preset period is in the back. In step 20, the predetermined direction of rotation of the coding switch is obtained based on the state change data of the level combination over time in the first preset period, and further combined with step 30, the direction of rotation of the coding switch is determined based on the state change data of the level combination over time in the second preset period. In order to avoid signal interference, the level state of the first signal and the level state of the second signal can be detected multiple times within the timing time base.
[0035] This embodiment detects the signal output by the coding switch port, obtains the level state change of the port signal over time, and determines whether the level state change of the port signal meets the preset change and conditions, thereby determining the rotation direction of the coding switch. The present invention can determine the rotation direction of the coding switch according to the level state change of the first signal and the second signal in the entire detection cycle, and the configuration of the state machine can effectively connect the level state change of the first signal and the second signal in the entire predetermined cycle in series. The present invention detects and determines the level state change throughout the entire detection cycle, and does not respond to and discards the signal level state data that does not meet the requirements at different stages, which can avoid using the first signal and the second signal level state when the coding switch rotates as the basis for determining the rotation direction, resulting in an erroneous determination result due to signal interference or jitter, thereby effectively eliminating the erroneous detection results caused by jitter and interference signals, and is convenient, fast, stable and reliable.
[0036] The state machine refers to a control center that can transfer states according to a preset state based on a control signal, and can coordinate related signal actions and complete specific operations. Through the configuration of the state machine, it is possible to record the current level combination state of the first signal and the second signal, and at the same time, before the state machine is updated according to the current level combination, it is convenient to understand the state of the previous level combination by calling the state of the state machine, and then effectively connect the level state changes of the first signal and the second signal in the entire predetermined period, so as to determine the rotation direction of the coding switch according to the level state changes of the first signal and the second signal in the entire predetermined period.
[0037] In one embodiment, Figure 2 As shown, step 20, i.e., the step of setting the state of the state machine according to the state change of the level combination formed by the first signal and the second signal over time, and predetermining the rotation direction of the encoding switch, may include the following steps:
[0038] Step 210: If the first signal is at a high level and the second signal is at a high level, the current state of the state machine is set to a first preset state.
[0039] At this time, the level combination formed by the first signal and the second signal is a high level high level. Assuming that the level combination is represented by the aforementioned binary form, the level combination at this time can be represented as 11. The process of setting the current state of the state machine to the first preset state can be to directly set a state mark for the state machine that can distinguish other states and can correspond to the situation where the level combination in the initial stage is a high level high level. The initial stage refers to the coding switch being in an unrotated state. Exemplarily, for example, the state mark H is used to represent the first preset state. When the current state of the state machine is the first preset state, it indicates that the first signal and the second signal correspond to a high level high level level combination.
[0040] Step 220: within a first preset time, if the first signal is continuously maintained at a high level and the second signal is continuously maintained at a high level, then the current state of the state machine is set to a second preset state.
[0041] Specifically, the level of the first signal and the level of the second signal can be detected multiple times in succession, and the number of detections can be adjusted according to the waveform and operation requirements of the coding switch, so as to ensure that the level of the first signal is a continuously maintained high level within the first preset time, and the level of the second signal is a continuously maintained high level, which is conducive to avoiding the interference of the jitter signal caused by a single detection. Exemplarily, for example, the state mark I can be used to represent the second preset state. When the current state of the state machine is the second preset state, it indicates that at this time, the first signal and the second signal correspond to a level combination of continuously maintaining a high level and a high level.
[0042] If at least one of the first signal or the second signal fails to maintain a high level continuously, return to step 210 to further confirm whether the first signal and the second signal constitute a level combination of a high level and a high level. If the first signal and the second signal do not constitute a level combination of a high level and a high level in step 210, the state of the state machine is not set to the first preset state, and step 210 is continued until the level combination formed by the first signal and the second signal is a high level and a high level.
[0043] What if the first signal or the second signal does not remain at a high level continuously? What should be done? Please add the logical processing for another situation.
[0044] Step 230, when the current state of the state machine is the second preset state, if one of the first signal and the second signal is at a high level and the other is at a low level, the rotation direction of the encoding switch is predetermined, and the current state of the state machine is set to a third preset state.
[0045] The execution of step 230 requires that the current state of the state machine is the second preset state as a prerequisite, that is, if the current state of the state machine is not the second preset state at this time, it is not determined whether one of the first signal and the second signal is a high level and the other is a low level. Step 230 is only executed when the current state of the state machine is the second preset state, that is, the level combination before executing step 230 is a continuously maintained high level.
[0046] If one of the first signal and the second signal is at a high level and the other is at a low level, it means that the first signal is at a high level and the second signal is at a low level, or the first signal is at a low level and the second signal is at a high level, and accordingly, the level combination formed by the first signal and the second signal is a high level low level or a low level high level, and exemplarily, it is 10 or 01 in binary. In step 230, if the level combination formed by the first signal and the second signal is a high level low level, it means that the coding switch rotates counterclockwise at this time, and if the level combination formed by the first signal and the second signal is a low level high level, it means that the coding switch rotates clockwise at this time. At this time, if the level of the first signal and the level of the second signal form a level combination other than a high level low level or a low level high level, no processing is performed, thereby achieving the discarding and non-response of the detection results of the jitter and interference signals.
[0047] Exemplarily, for example, the state mark J can be used to represent the third preset state. When the current state of the state machine is the third preset state, it indicates that the first signal and the second signal form a level combination in which one is high level and the other is low level when the current state of the state machine is the second preset state. The level states of the first signal and the second signal that change with time are effectively connected in series as the steps of the method of the present invention are continuously executed.
[0048] In one embodiment, further, in the case where the first port is an A-phase port and the second port is a B-phase port, the step of predetermining the rotation direction of the coding switch may include:
[0049] Step 231: If the first signal is at a high level and the second signal is at a low level, it is predetermined that the rotation direction of the encoding switch is counterclockwise.
[0050] Combination Figure 7As shown, after the first signal and the second signal both maintain high levels continuously, if the first signal is high and the second signal is low, it can be preliminarily determined that the rotation direction of the encoding switch is counterclockwise.
[0051] Step 232: If the first signal is at a low level and the second signal is at a high level, it is predetermined that the rotation direction of the encoding switch is clockwise.
[0052] Combination Figure 6 As shown, after the first signal and the second signal both maintain high level continuously, if the first signal is low level and the second signal is high level at the same time, it can be preliminarily determined that the rotation direction of the encoding switch is clockwise.
[0053] In one embodiment, Figure 3 As shown, step 30, i.e., the step of setting the state of the state machine in combination with the predetermined rotation direction of the coding switch and according to the state change of the level combination formed by the first signal and the second signal over time, and determining the rotation direction of the coding switch may include:
[0054] Step 310: When the current state of the state machine is the third preset state, determine whether the first signal and the second signal are both at a low level.
[0055] The execution of step 310 requires that the current state of the state machine is the third preset state as a prerequisite, that is, if the current state of the state machine is not the third preset state at this time, it is not determined whether the first signal and the second signal are both low levels. Step 310 is only executed when the current state of the state machine is the third preset state, that is, the level combination of the first signal and the second signal before executing step 310 is high level low level or low level high level.
[0056] At this time, if the level of the first signal and the level of the second signal form a level combination other than a low level or a low level, no processing is performed. For example, if the level combination of the first signal and the second signal is a high level high level, a high level low level, or a low level high level, no processing is performed, thereby discarding and not responding to the detection results of the jitter and interference signals. Exemplarily, the low level or low level level combination can be represented as 00 in binary.
[0057] Step 320: If the first signal and the second signal are both at low levels, setting the current state of the state machine to a fourth preset state.
[0058] Exemplarily, for example, the fourth preset state can be indicated by the state mark K. When the current state of the state machine is the fourth preset state, it indicates that the first signal and the second signal form a low level low level level combination when the current state of the state machine is the third preset state.
[0059] Step 330: When the current state of the state machine is the fourth preset state, determine whether the level combination formed by the first signal and the second signal is a preset level combination in combination with the predetermined rotation direction of the encoding switch.
[0060] The execution of step 330 requires that the current state of the state machine is the fourth preset state as a prerequisite, that is, if the current state of the state machine is not the fourth preset state at this time, it is not determined whether the level combination formed by the first signal and the second signal is the preset level combination. Step 330 is only executed when the current state of the state machine is the fourth preset state, that is, the level combination of the first signal and the second signal before executing step 330 is low level.
[0061] In one embodiment, when the first port is an A-phase port and the second port is a B-phase port, the step of determining whether the level combination formed by the first signal and the second signal is a preset level combination in combination with the predetermined rotation direction of the coding switch, i.e., step 330, may include:
[0062] Step 331: If the predetermined rotation direction of the encoding switch is clockwise, determine whether the first signal is at a high level and whether the second signal is at a low level.
[0063] At this time, the preset level combination is a high level and a low level, which is 10 in binary representation.
[0064] Step 332: If the predetermined rotation direction of the encoding switch is counterclockwise, determine whether the first signal is at a low level and whether the second signal is at a high level.
[0065] At this time, the preset level combination is a low level and a high level, which is 01 in binary representation.
[0066] For step 330, step 331 and step 332, at this time, if the level of the first signal and the level of the second signal form other level combinations that are not preset level combinations, no processing is performed. For example, if the level combination of the first signal and the second signal is neither a high level nor a low level nor a high level, no processing is performed, thereby achieving the abandonment and non-response of the detection results of the jitter and interference signals.
[0067] Step 340: When the level combination formed by the first signal and the second signal is a preset level combination, determine the rotation direction of the encoding switch.
[0068] In one embodiment, the step of determining the rotation direction of the coding switch, i.e., step 340, may include:
[0069] Step 341: If the predetermined rotation direction of the coding switch is clockwise, and the first signal is at a high level and the second signal is at a low level, it is determined that the rotation direction of the coding switch is clockwise.
[0070] Combination Figure 6 As shown, when the levels of the first signal and the second signal appear in sequence as a level combination of high level high level, low level high level, low level low level, and high level low level, it can be determined that the rotation direction of the encoding switch is clockwise.
[0071] Step 342: If the predetermined rotation direction of the encoding switch is counterclockwise, and the first signal is at a low level and the second signal is at a high level, it is determined that the rotation direction of the encoding switch is counterclockwise.
[0072] Combination Figure 7 As shown, when the levels of the first signal and the second signal appear in sequence as a level combination of high level high level, high level low level, low level low level, and low level high level, it can be determined that the rotation direction of the encoding switch is counterclockwise.
[0073] In one embodiment, after the step of determining the rotation direction of the coding switch, i.e., step 340, the following steps may also be included:
[0074] If the first signal is at a high level and the second signal is at a high level at the same time, the current state of the state machine is set to the first preset state.
[0075] When the level of the first signal and the level of the second signal return to a high level high level level combination, it is considered that a detection cycle is completed. At this time, the current state of the state machine is configured as the first preset state, and prepares to start the next detection.
[0076] The present invention further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes the coding switch detection method as described in any of the above embodiments.
[0077] The present invention also provides a computer device, in one embodiment, such as Figure 4As shown, it includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the coding switch detection method as described in any of the above embodiments.
[0078] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0079] The above description is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, shall make equivalent replacements or changes according to the technical solution and inventive concept of the present invention, which shall be covered within the protection scope of the present invention. In addition, although some specific terms are used in this specification, these terms are only for the convenience of explanation and do not constitute any limitation to the present invention.
Claims
1. A coding switch detection method, characterized in that: The method comprises: Detecting a first signal output from a first port of a coding switch and a second signal output from a second port of the coding switch; In a first preset period, the rotation direction of the coding switch is predetermined according to the state changes of the levels of the first signal and the second signal over time, wherein the first preset period is half of the length of the predetermined period, and the predetermined period is the detection period of the coding switch; if the first signal is at a high level and the second signal is at a high level at the same time, the current state of the state machine is set to the first preset state; within the first preset time, if the first signal is continuously maintained at a high level and the second signal is continuously maintained at a high level, the current state of the state machine is set to the second preset state; when the current state of the state machine is the second preset state, if one of the first signal and the second signal is at a high level and the other is at a low level, the rotation direction of the coding switch is predetermined, and the current state of the state machine is set to the third preset state; the level combination is formed by the level of the first signal and the level of the second signal at the same time in a preset order; In a second preset period, the rotation direction of the coding switch is determined according to the state change data of the level combination over time, and the second preset period is half of the length of the predetermined period; when the current state of the state machine is the third preset state, it is determined whether the first signal and the second signal are both low levels; if the first signal and the second signal are both low levels, the current state of the state machine is set to the fourth preset state; when the current state of the state machine is the fourth preset state, combined with the predetermined rotation direction of the coding switch, it is determined whether the level combination formed by the first signal and the second signal is a preset level combination; when the level combination formed by the first signal and the second signal is a preset level combination, the rotation direction of the coding switch is determined.
2. The coding switch detection method according to claim 1, characterized in that: The first port is an A-phase port, and the second port is a B-phase port; The step of predetermining the rotation direction of the coding switch comprises: If the first signal is at a high level and the second signal is at a low level, it is predetermined that the rotation direction of the encoding switch is counterclockwise; If the first signal is at a low level and the second signal is at a high level, it is predetermined that the rotation direction of the encoding switch is clockwise.
3. The coding switch detection method according to claim 1, characterized in that: The first port is an A-phase port, and the second port is a B-phase port; The step of determining whether the level combination formed by the first signal and the second signal is a preset level combination in combination with the predetermined rotation direction of the coding switch comprises: If the predetermined rotation direction of the encoding switch is clockwise, determining whether the first signal is at a high level and whether the second signal is at a low level; If the predetermined rotation direction of the encoding switch is counterclockwise, it is determined whether the first signal is at a low level and whether the second signal is at a high level.
4. The coding switch detection method according to claim 3, characterized in that: The step of determining the rotation direction of the coding switch comprises: If the predetermined rotation direction of the coding switch is clockwise, and the first signal is at a high level and the second signal is at a low level, it is determined that the rotation direction of the coding switch is clockwise; If the predetermined rotation direction of the encoding switch is counterclockwise, and the first signal is at a low level and the second signal is at a high level, it is determined that the rotation direction of the encoding switch is counterclockwise.
5. The coding switch detection method according to claim 1, characterized in that: After the step of determining the rotation direction of the coding switch, the following steps are also included: If the first signal is at a high level and the second signal is at a high level at the same time, the current state of the state machine is set to the first preset state.
6. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the coding switch detection method according to any one of claims 1 to 5.
7. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the coding switch detection method according to any one of claims 1 to 5.
