A multi-functional keyboard
The multi-functional keyboard, which integrates a main controller and a multi-function module, solves the problem of the traditional keyboard's limited functionality, enabling custom configuration and multi-mode switching, thus improving user experience and operational efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG UNIV OF TECH
- Filing Date
- 2026-03-19
- Publication Date
- 2026-06-16
AI Technical Summary
Traditional keyboards have limited functionality and cannot meet users' needs for high efficiency, high customization, and multi-functional interaction in specific scenarios. They also lack integrated interaction modules and flexible configuration capabilities.
Design a multi-functional keyboard that integrates a main controller with multiple modules (keys, joystick, rotary encoder, keyboard lights, and buzzer). The main controller enables centralized control and data processing, supports custom configuration and multi-mode switching, employs a filtering algorithm to eliminate key bounce, and achieves multi-functional control of the joystick and rotary encoder, along with buzzer audio feedback and RGB lighting effects.
It achieves a high degree of keyboard integration, customizable configuration, and multi-mode switching, improving user experience and operational efficiency, and providing rich interactive feedback and flexible adaptability.
Smart Images

Figure CN122219781A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of keyboard-related technology, and in particular to a multi-functional keyboard. Background Technology
[0002] As one of the most basic input devices for computers, the keyboard is widely used in various electronic devices. Traditional keyboards have limited functionality, typically only providing standard key input, and cannot meet users' needs for high efficiency, high customization, and multifunctional interaction in specific scenarios. For example, in professional fields such as gaming, design, and programming, users often need to frequently use shortcut key combinations, precise cursor control, or multimedia adjustments, and traditional keyboards struggle to provide intuitive and quick operation methods.
[0003] While some keyboards on the market currently feature additional function keys or knobs, their functions are fixed and not customizable, and they lack integrated interactive modules such as joysticks, RGB lighting effects, and buzzer audio feedback. Furthermore, existing keyboards typically lack the ability to configure functions, switch modes, and adjust parameters via a host computer, limiting their flexibility in adapting to different user habits and application scenarios.
[0004] Therefore, it is necessary to design a multi-functional keyboard that is highly integrated, customizable, and supports multi-mode switching and interactive feedback to improve user experience and operational efficiency. Summary of the Invention
[0005] The purpose of this invention is to address at least one of the shortcomings of the prior art by providing a multi-functional keyboard.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: Specifically, a multi-functional keyboard is proposed, including the following: The main controller communicates with the host computer. The button is electrically connected to the main controller, and the host computer configures the key value of the button module through the main controller. The joystick is electrically connected to the main controller and is used for preset mode control. The joystick position is sampled by an ADC and converted into a corresponding control signal after being processed by a preset algorithm. A rotary encoder is electrically connected to the main controller. The main controller determines the rotation direction and step value through state machine logic. It is used for two-way two-button mode control and can also simulate CTRL+scroll wheel. The keyboard light is electrically connected to the main controller, and its color and brightness are adjusted by the main controller via PWM. The buzzer is electrically connected to the main controller and is adjusted by the main controller through PWM frequency and duty cycle to achieve four-octave scale performance, used for prompting sounds or playing simple music. The button module consists of buttons, a joystick, and a rotary encoder. The button module uses a filtering algorithm to eliminate button bounce.
[0007] Furthermore, specifically, the process by which the button module uses a filtering algorithm to eliminate button bounce includes: The button module includes a 4×4 matrix keyboard, plus a joystick and a rotary encoder, for a total of 18 buttons, each corresponding to one of 18 I / O ports. When a button is pressed, a low level is read. The I / O port level is read for button filtering to eliminate bounce. A preset function is used to determine whether the I / O port has actually been triggered. This preset function is a for loop that iterates through an array named `key_quies`, where each element represents the current state of the button. Different logic is executed based on the button's state. If the button is currently in a normal state (`key_quies[i]` equals 0) and the read level is different from the previously used level, then a possible button press has occurred. In this case, `key_quies[i]` is set to 0xFF to record this edge confirmation information. If the button has already been marked as waiting for confirmation (`key_quies[i]` equals 0xFF) and the level is indeed changing, then the button's usage state is updated to silent state, and `key_quies[i]` is set to `KEY_FILTER_SET`. Start the silent counting; otherwise, if the button state changes again, reset key_quies[i] to 0. When the button is in a silent state, if the time difference dt is less than key_quies[i], it means that the silent period has not ended, so subtract this time from key_quies[i]. If the time difference is too large, that is, dt is not less than key_quies[i], directly set key_quies[i] to 0, that is, return to the normal state.
[0008] Furthermore, specifically, the control logic of the joystick is as follows: a function named RK_EC_key_handle is used to handle the operation related to the joystick button. First, an index value is obtained by selecting the array related to the joystick button according to the parameter. A corresponding button value is obtained from the index value. The button state is obtained by keyState=key_state
[17] . Then there is a loop for(uint8_t rk_ec= 0; rk_ec < 2; rk_ec++). When rk_ec == 1, the parameter is reselected and the button state is obtained again. The loop is judged according to the button state. If keyState is false, it is skipped. The operation is performed according to the button state. When the button state is case 1, there is a loop that traverses the index from 3 to KB_len. If KeyBrd_data[i] is false, key_insert(i,key_rk_ec) is called to insert the button value into the preset position determined by i. The defined function is RK_handle, which has three variables: RK_pulse, x_pic, and The `y_pic` parameter's `clear` part sets all three variables to 0 and then returns directly. It calculates `key_rk_cs` for parameter selection, defines `dx` and `dy` as initialized to 0, and calculates the values of `x` and `y` based on `dir_x` and `dir_y`. It calculates the coordinate values based on the rotation flag, with `x` positively pointing to the right and `y` positively pointing upwards. It determines the equivalent radius and dead zone, calculating the maximum of the absolute values of `x` and `y` to obtain the equivalent radius. If the value is within the preset dead zone, it exits without further operation.
[0009] Furthermore, specifically, the control logic of the rotary encoder includes, Define the rotary encoder processing function EC_handle, and define the static variables required for encoder processing: oldTime (recording time), old encoder count value TIM_old, count change value TIM_count; execution flag EC_flag, execution count EC_count, interval flag EC_pulse; handle the clear command: if clear=1 is passed, indicating that a clear signal exists, then reset the count value, execution flag, interval flag, etc. to 0, and return directly to terminate the current processing. Based on the encoder's orientation configuration, read the TIM register value and calculate the change in the current count value, TIM_count. By judging the magnitude of the count change, different execution flags are set: If the current count change TIM_count is more than 4 times EC_count, set the execution flag EC_flag to 1; If the current count change TIM_count is less than 4 times EC_count, set the execution flag EC_flag to 2; EC_flag is used to indicate the rotation direction and state of the encoder, with 1 indicating forward rotation, 2 indicating reverse rotation, and 0 indicating no rotation. If the current count value TIM_count is inconsistent with the previously recorded TIM_old, update oldTime to the current system recording time and synchronize TIM_old to the current count value; If the time since the last change in the count value exceeds a preset time threshold, it is determined that the encoder has not moved for a long time, and the static variable is reset to the initial state. In the two-way two-button mode, the key value output is processed according to the execution flag: Determine the interval flag EC_pulse: If EC_pulse=1 (a signal has been sent previously), then clear EC_pulse and reset the key data buffer; If EC_pulse=0 (no signal sent this time), then the corresponding key value is inserted into the key data buffer according to the execution flag EC_flag; The update interval flag EC_pulse is set to 1 to indicate that this transmission has been completed. Then, the next interval will be used to complete the encoder key value output in this mode.
[0010] Furthermore, specifically, the keyboard light is an RGB light, and whether to enable the keyboard light is selected by choosing case1 or case2. The control process of the keyboard light is as follows: after obtaining the X and Y coordinates of the joystick, the X and Y coordinates are converted into polar coordinates, and the brightness of the keyboard light is obtained through a preset polar coordinate mapping rule, and the larger the radius, the greater the brightness.
[0011] Furthermore, the keyboard is also equipped with indicator lights to illuminate preset running content.
[0012] The beneficial effects of this invention are as follows: This invention proposes a multi-functional keyboard where all modules (4x4 matrix keyboard, joystick, rotary encoder, RGB lights, and buzzer) are connected to a single main control chip, STM32F103C8T6. The main control chip acts as the sole brain, using its GPIO, ADC, and TIMER (for PWM and encoder counting) peripherals to acquire data, process logic, and output instructions to all modules. This achieves centralized hardware control, and each module has its own dedicated, fully functional processing functions, ensuring independence and low coupling between modules. The final output of all input modules (buttons, joysticks, encoders) is normalized into "key values" or "standard data packets". This data is stored in a unified array and sent to the host computer through the same HID communication protocol, realizing unified control logic. Attached Figure Description
[0013] The above and other features of this disclosure will become more apparent from the detailed description of the embodiments illustrated in conjunction with the accompanying drawings. In the accompanying drawings, the same reference numerals denote the same or similar elements. Obviously, the drawings described below are merely some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without any creative effort. In the drawings: Figure 1 The diagram shown is a schematic diagram of the structure of a multi-functional keyboard according to the present invention. Figure 2 The diagram shown is a circuit diagram of a key in a preferred embodiment of a multi-functional keyboard according to the present invention. Figure 3 The diagram shown is a circuit schematic of the main controller of a preferred embodiment of a multi-functional keyboard according to the present invention. Figure 4 The diagram shown is, from left to right, a circuit diagram of a joystick, a rotary encoder, and a keyboard light, according to a preferred embodiment of a multifunctional keyboard of the present invention. Figure 5 The diagram shown is a circuit schematic of a buzzer in a preferred embodiment of a multifunctional keyboard according to the present invention. Figure 6 The diagram shown is a code representation of key filtering in one embodiment of a multi-functional keyboard according to the present invention. Figure 7 The diagram shown is a design code diagram of a joystick for key filtering in one embodiment of a multi-functional keyboard according to the present invention. Figure 8 The diagram shown is a parameter definition code diagram of a rotary encoder in one embodiment of a multifunctional keyboard according to the present invention. Figure 9 The diagram shown is a code diagram for calculating the encoder count value and change amount of a rotary encoder in one embodiment of a multifunctional keyboard of the present invention. Figure 10 The diagram shown is a code diagram of encoder key value processing in a bidirectional two-key mode of a rotary encoder in one embodiment of a multifunctional keyboard of the present invention. Figure 11 The diagram shown is a code diagram illustrating the mapping between a remote sensor and keyboard lights in one embodiment of a multifunctional keyboard according to the present invention. Figure 12The diagram shown is a code diagram of the buzzer playing mode set by the host computer in one embodiment of a multi-functional keyboard of the present invention. Figure 13 The diagram shown is a structural diagram of one embodiment of a multi-functional keyboard according to the present invention. Detailed Implementation
[0014] The following will provide a clear and complete description of the concept, specific structure, and technical effects of the present invention in conjunction with embodiments and accompanying drawings, so as to fully understand the purpose, solution, and effects of the present invention. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. The same reference numerals used throughout the accompanying drawings indicate the same or similar parts.
[0015] Example 1, referring to Figure 1 as well as Figure 13 This invention proposes a multi-functional keyboard, comprising the following: The main controller communicates with the host computer. The button is electrically connected to the main controller, and the host computer configures the key value of the button module through the main controller. The joystick is electrically connected to the main controller and is used for preset mode control. The joystick position is sampled by an ADC and converted into a corresponding control signal after being processed by a preset algorithm. A rotary encoder is electrically connected to the main controller. The main controller determines the rotation direction and step value through state machine logic. It is used for two-way two-button mode control and can also simulate CTRL+scroll wheel. The keyboard light is electrically connected to the main controller, and its color and brightness are adjusted by the main controller via PWM. The buzzer is electrically connected to the main controller and is adjusted by the main controller through PWM frequency and duty cycle to achieve four-octave scale performance, used for prompting sounds or playing simple music. Reference Figure 12 Buzzer PWM audio synthesis technology: Based on the working principle of passive buzzers, simply changing the frequency and duty cycle of the input PWM wave to adjust its frequency and volume can achieve a simple playing effect. Simply configure the button mode settings box to enter the buzzer playing mode. Below is the specific code from the host computer. The button module consists of buttons, a joystick, and a rotary encoder. The button module uses a filtering algorithm to eliminate button bounce.
[0016] In this embodiment 1, all modules (4x4 matrix keyboard, joystick, rotary encoder, RGB lights, buzzer) are connected to the same main control chip, STM32F103C8T6. The main control chip acts as the sole brain, using its GPIO, ADC, TIMER (for PWM and encoder counting), and other peripherals to acquire data, process logic, and output instructions to all modules. This achieves centralized hardware control, and each module has its own dedicated, fully functional processing functions, ensuring independence and low coupling between them. The final output of all input modules (buttons, joysticks, encoders) is normalized into "key values" or "standard data packets". This data is stored in a unified array and sent to the host computer through the same HID communication protocol, realizing unified control logic.
[0017] Customizable Key Functions: Each key supports single-key, combination key, continuous click, toggle key, lighting control, buzzer mode, and other function settings; key values are configured via host computer software, and configuration information is stored in the microcontroller's Flash memory; software filtering algorithms are used to eliminate key bounce and improve response accuracy. Joystick Multi-Function Control: Supports four modes: four-way button, speed mouse, absolute cursor movement, and eight-way button; dead zone and return-to-center values can be set, and X / Y axis reversal is supported; joystick position is sampled by an ADC and converted into corresponding control signals after algorithm processing. Rotary Encoder Control: Supports two-way two-button mode, which can be set as media control (such as volume adjustment) or shortcut keys; has reverse function settings and supports CTRL+scroll wheel simulation; uses state machine logic to determine rotation direction and step value. RGB Lighting Control: Supports multiple modes such as constant light and breathing; brightness and color can be adjusted via PWM; joystick movements can be mapped to RGB light color changes, providing visual feedback; in lighting control mode, the keyboard locks to a dedicated layout for adjusting lighting parameters. Buzzer audio feedback: Four-octave scale playback is achieved through PWM frequency and duty cycle adjustment; volume adjustment is supported for notification sounds or simple music playback. Host computer configuration interface: Provides a graphical interface for configuring various keyboard functions; supports saving, importing, and exporting configurations, and can write to the keyboard's internal storage; supports advanced functions such as joystick calibration, filter time setting, and screen size setting.
[0018] See also Figure 2 , Figure 3 , Figure 4 as well as Figure 5 The circuit structure for implementing this invention is given.
[0019] Reference Figure 6 In a preferred embodiment of the present invention, specifically, the process by which the button module uses a filtering algorithm to eliminate button bounce includes: The button module includes a 4×4 matrix keyboard, plus a joystick and a rotary encoder, for a total of 18 buttons, each corresponding to one of 18 I / O ports. When a button is pressed, a low level is read. The I / O port level is read for button filtering to eliminate bounce. A preset function is used to determine whether the I / O port has actually been triggered. This preset function is a for loop that iterates through an array named `key_quies`, where each element represents the current state of the button. Different logic is executed based on the button's state. If the button is currently in a normal state (`key_quies[i]` equals 0) and the read level is different from the previously used level, then a possible button press has occurred. In this case, `key_quies[i]` is set to 0xFF to record this edge confirmation information. If the button has already been marked as waiting for confirmation (`key_quies[i]` equals 0xFF) and the level is indeed changing, then the button's usage state is updated to silent state, and `key_quies[i]` is set to `KEY_FILTER_SET`. Start the silent counting; otherwise, if the button state changes again, reset key_quies[i] to 0. When the button is in a silent state, if the time difference dt is less than key_quies[i], it means that the silent period has not ended, so subtract this time from key_quies[i]. If the time difference is too large, that is, dt is not less than key_quies[i], directly set key_quies[i] to 0, that is, return to the normal state.
[0020] Reference Figure 7As a preferred embodiment of the present invention, specifically, the control logic of the joystick is as follows: a function named RK_EC_key_handle is used to handle the operation related to the joystick button. First, according to the parameter, an array related to the joystick button is selected to obtain an index value. The corresponding button value is obtained from the index value. The button state is obtained by keyState=key_state
[17] . Then there is a loop for(uint8_t rk_ec= 0; rk_ec < 2; rk_ec++). When rk_ec == 1, the parameter is reselected and the button state is obtained again. The loop is judged according to the button state. If keyState is false, it is skipped. The operation is performed according to the button state. When the button state is case 1, there is a loop that traverses the index from 3 to KB_len. If KeyBrd_data[i] is false, key_insert(i,key_rk_ec) is called to insert the button value into the preset position determined by i. The defined function is RK_handle, which has three variables: RK_pulse, x_pic, and The `y_pic` parameter's `clear` part sets all three variables to 0 and then returns directly. It calculates `key_rk_cs` for parameter selection, defines `dx` and `dy` as initialized to 0, and calculates the values of `x` and `y` based on `dir_x` and `dir_y`. It calculates the coordinate values based on the rotation flag, with `x` positively pointing to the right and `y` positively pointing upwards. It determines the equivalent radius and dead zone, calculating the maximum of the absolute values of `x` and `y` to obtain the equivalent radius. If the value is within the preset dead zone, it exits without further operation.
[0021] Additionally, it supports joystick calibration, which commands the keyboard to update the current joystick position to the joystick center position and store it in FLASH. Newly flashed keyboards do not store the joystick center position, so it is recommended to perform joystick calibration after flashing the firmware to avoid significant drift.
[0022] Reference Figure 8 , Figure 9 as well as Figure 10 In a preferred embodiment of the present invention, the control logic of the rotary encoder specifically includes, Define the rotary encoder processing function EC_handle, and define the static variables required for encoder processing: oldTime (recording time), old encoder count value TIM_old, count change value TIM_count; execution flag EC_flag, execution count EC_count, interval flag EC_pulse; handle the clear command: if clear=1 is passed, indicating that a clear signal exists, then reset the count value, execution flag, interval flag, etc. to 0, and return directly to terminate the current processing. Based on the encoder's orientation configuration, read the TIM register value and calculate the change in the current count value, TIM_count. By judging the magnitude of the count change, different execution flags are set: If the current count change TIM_count is more than 4 times EC_count, set the execution flag EC_flag to 1; If the current count change TIM_count is less than 4 times EC_count, set the execution flag EC_flag to 2; EC_flag is used to indicate the rotation direction and state of the encoder, with 1 indicating forward rotation, 2 indicating reverse rotation, and 0 indicating no rotation. If the current count value TIM_count is inconsistent with the previously recorded TIM_old, update oldTime to the current system recording time and synchronize TIM_old to the current count value; If the time since the last change in the count value exceeds a preset time threshold, it is determined that the encoder has not moved for a long time, and the static variable is reset to the initial state. In the two-way two-button mode, the key value output is processed according to the execution flag: Determine the interval flag EC_pulse: If EC_pulse=1 (a signal has been sent previously), then clear EC_pulse and reset the key data buffer; If EC_pulse=0 (no signal sent this time), then the corresponding key value is inserted into the key data buffer according to the execution flag EC_flag; The update interval flag EC_pulse is set to 1 to indicate that this transmission has been completed. Then, the next interval will be used to complete the encoder key value output in this mode.
[0023] In this preferred embodiment, the code snippets used in this design module collectively implement the application of a rotary encoder in a multi-functional keyboard. By rotating the encoder, users can simulate key presses, increasing the keyboard's interactivity and flexibility. The code uses static variables to maintain the state, determines the rotation direction by comparing count values, and resets the state when there is no action for a certain period; all of these measures aim to improve the system's stability and responsiveness.
[0024] Here, the encoder count uses static variables to maintain the state between function calls, which is necessary for tracking continuous state changes in the encoder. When the encoder state needs to be reset, it can be done by calling EC_handle(1). This part of the code defines a handler function EC_handle, which initializes several static variables to store the encoder state. The clear parameter is used to reset these states.
[0025] In the encoder's technical logic, the rotation direction can be determined by comparing TIM_count and EC_count, which is essential for implementing the functionality of a rotary encoder. This part of the code updates TIM_count based on the encoder's rotation direction and value. Then, based on the comparison result between TIM_count and EC_count, EC_flag is set. EC_flag indicates the encoder's rotation direction and state: 1 indicates forward rotation, 2 indicates reverse rotation, and 0 indicates no rotation.
[0026] Simultaneously, encoder state updates are configured. This prevents erroneous operations due to minor encoder fluctuations or noise, ensuring that the encoder does not incorrectly trigger events when inactive. An "if...else" function is used; this code checks if the encoder's count value has changed, and updates the time if it has. If the encoder remains inactive for a period of time, all relevant states are reset.
[0027] This design allows users to simulate key operations by rotating the encoder, increasing the keyboard's versatility and implementing a two-way, two-key logic, where the two directions of the encoder correspond to two different key operations.
[0028] Reference Figure 11 In a preferred embodiment of the present invention, the keyboard light is an RGB light, and the keyboard light is enabled or disabled by selecting case1 or case2. The control process of the keyboard light is as follows: after obtaining the X and Y coordinates of the joystick, the X and Y coordinates are converted into polar coordinates, and the brightness of the keyboard light is obtained by a preset polar coordinate mapping rule, and the larger the radius, the greater the brightness.
[0029] In a preferred embodiment of the present invention, the keyboard is also provided with indicator lights for indicating the activation of preset operating content.
[0030] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0031] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or system capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0032] Although the description of the invention has been quite detailed and particularly of several described embodiments, it is not intended to limit it to any of these details or embodiments or any particular embodiment, but should be considered as providing a broad possible interpretation of the claims by referring to the appended claims and taking into account the prior art, thereby effectively covering the intended scope of the invention. Furthermore, the invention has been described above with respect to embodiments foreseeable by the inventors in order to provide a useful description, and non-substantial modifications to the invention that have not yet been foreseen may still represent equivalent modifications.
[0033] The above description is merely a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. Any embodiment that achieves the technical effects of the present invention using the same means should fall within the protection scope of the present invention. Within the protection scope of the present invention, various modifications and variations can be made to the technical solutions and / or implementation methods.
Claims
1. A multi-functional keyboard, characterized in that, Including the following: The main controller communicates with the host computer. The button is electrically connected to the main controller, and the host computer configures the key value of the button module through the main controller. The joystick is electrically connected to the main controller and is used for preset mode control. The joystick position is sampled by an ADC and converted into a corresponding control signal after being processed by a preset algorithm. A rotary encoder is electrically connected to the main controller. The main controller determines the rotation direction and step value through state machine logic. It is used for two-way two-button mode control and can also simulate CTRL+scroll wheel. The keyboard light is electrically connected to the main controller, and its color and brightness are adjusted by the main controller via PWM. The buzzer is electrically connected to the main controller and is adjusted by the main controller through PWM frequency and duty cycle to achieve four-octave scale performance, used for prompt tone or simple music playback; The button module consists of buttons, a joystick, and a rotary encoder. The button module uses a filtering algorithm to eliminate button bounce.
2. A multi-functional keyboard according to claim 1, characterized in that, Specifically, the process by which the button module uses a filtering algorithm to eliminate button bounce includes: The button module includes a 4×4 matrix keyboard, plus a joystick and a rotary encoder, for a total of 18 buttons, each corresponding to one of 18 I / O ports. When a button is pressed, a low level is read. The I / O port level is read for button filtering to eliminate bounce. A preset function is used to determine whether the I / O port has actually been triggered. This preset function is a for loop that iterates through an array named `key_quies`, where each element represents the current state of the button. Different logic is executed based on the button's state. If the button is currently in a normal state (`key_quies[i]` equals 0) and the read level is different from the previously used level, then a possible button press has occurred. In this case, `key_quies[i]` is set to 0xFF to record this edge confirmation information. If the button has already been marked as waiting for confirmation (`key_quies[i]` equals 0xFF) and the level is indeed changing, then the button's usage state is updated to silent state, and `key_quies[i]` is set to `KEY_FILTER_SET`. Start the silent counting; otherwise, if the button state changes again, reset key_quies[i] to 0. When the button is in a silent state, if the time difference dt is less than key_quies[i], it means that the silent period has not ended, so subtract this time from key_quies[i]. If the time difference is too large, that is, dt is not less than key_quies[i], directly set key_quies[i] to 0, that is, return to the normal state.
3. A multi-functional keyboard according to claim 1, characterized in that, Specifically, the control logic of the joystick is as follows: a function named RK_EC_key_handle is used to handle the operation related to the joystick button. First, an array related to the joystick button is selected according to the parameters to obtain an index value. A corresponding button value is obtained from the index value. The button state is obtained by keyState=key_state[17]. Then there is a loop for(uint8_t rk_ec= 0; rk_ec < 2; rk_ec++). When rk_ec == 1, the parameters are reselected and the button state is obtained again. The loop is judged according to the button state. If keyState is false, it is skipped. The operation is performed according to the button state. When the button state is case 1, there is a loop that traverses the index from 3 to KB_len. If KeyBrd_data[i] is false, key_insert(i,key_rk_ec) is called to insert the button value into the preset position determined by i. The defined function is RK_handle, which has three variables: RK_pulse, x_pic, and The `y_pic` parameter's `clear` part sets all three variables to 0 and then returns directly. It calculates `key_rk_cs` for parameter selection, defines `dx` and `dy` as initialized to 0, calculates the values of `x` and `y` based on `dir_x` and `dir_y`, calculates the coordinate values based on the rotation flag (x is positive to the right, y is positive upwards), determines the equivalent radius and dead zone, calculates the maximum of the absolute values of `x` and `y` to obtain the equivalent radius, and exits without further operation if the value is within the preset dead zone.
4. A multi-functional keyboard according to claim 1, characterized in that, Specifically, the control logic of the rotary encoder includes, Define the rotary encoder processing function EC_handle, and define the static variables required for encoder processing: oldTime (recording time), old encoder count value TIM_old, count change value TIM_count; execution flag EC_flag, execution count EC_count, interval flag EC_pulse; handle the clear command: if clear=1 is passed, indicating that a clear signal exists, then reset the count value, execution flag, interval flag, etc. to 0, and return directly to terminate the current processing. Based on the encoder's orientation configuration, read the TIM register value and calculate the change in the current count value, TIM_count. By judging the magnitude of the count change, different execution flags are set: If the current count change TIM_count is more than 4 times EC_count, set the execution flag EC_flag to 1; If the current count change TIM_count is less than 4 times EC_count, set the execution flag EC_flag to 2; EC_flag is used to indicate the rotation direction and state of the encoder, with 1 indicating forward rotation, 2 indicating reverse rotation, and 0 indicating no rotation. If the current count value TIM_count is inconsistent with the previously recorded TIM_old, update oldTime to the current system recording time and synchronize TIM_old to the current count value; If the time since the last change in the count value exceeds a preset time threshold, it is determined that the encoder has not moved for a long time, and the static variable is reset to the initial state. In the two-way two-button mode, the key value output is processed according to the execution flag: Determine the interval flag EC_pulse: If EC_pulse=1, then clear EC_pulse and reset the key data cache; If EC_pulse=0, then the corresponding key value is inserted into the key data buffer according to the execution flag EC_flag; The update interval flag EC_pulse is set to 1 to indicate that this transmission has been completed. Then, the next interval will be used to complete the encoder key value output in this mode.
5. A multi-functional keyboard according to claim 1, characterized in that, Specifically, the keyboard light is an RGB light, and whether to enable the keyboard light is selected by choosing case1 or case2. The control process of the keyboard light is as follows: after obtaining the X and Y coordinates of the joystick, the X and Y coordinates are converted into polar coordinates, and the brightness of the keyboard light is obtained through a preset polar coordinate mapping rule, and the larger the radius, the greater the brightness.
6. A multi-functional keyboard according to claim 1, characterized in that, The keyboard is also equipped with indicator lights to illuminate preset running content.