FT32-based multimode fine-tuning keyboard circuit and control method
By adopting the design of domestic FT32 processor and multi-communication interface, combined with diode matrix keys, rotary encoder and rocker multi-dimensional input, the problem of single functions of traditional keyboards and dependence on imported chips is solved, and a fine-tuned keyboard circuit with multi-dimensional operation, low-cost and high anti-interference is realized, improving the user interaction experience.
Patent Information
- Application Number
- CN202510581779.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-07
- Publication Date
- 2025-08-08
AI Technical Summary
Traditional keyboards have single functions and are difficult to meet the needs of multi-dimensional operation. Relying on imported chips leads to high costs, large power consumption and weak anti-interference capabilities, limiting their application in harsh environments.
It adopts a domestic FT32 low-power processor, integrates multi-communication interface and program debugging port, combines diode matrix buttons, rotary encoder and rocker multi-dimensional input, and introduces linear regulators and multiple protection circuits through time-sharing scanning and diode collision-proof design to achieve the domestic production of core devices and improves the anti-interference capability of the core devices; at the software level, dynamic priority allocation, adaptive protocol switching and low-power mode management, achieve efficient multi-signal fusion and seamless equipment compatibility.
It realizes multi-dimensional operation capabilities, reduces costs, improves anti-interference capabilities and equipment stability, and enhances user interaction intuitiveness.
Smart Images

Figure CN120447750A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of fine-tuning keyboards. More specifically, the present invention discloses a multi-mode fine-tuning keyboard circuit and a control method based on FT32. Background Art
[0002] With the in-depth application of computer technology in various professional fields, traditional general-purpose keyboards have gradually exposed problems such as limited functionality and insufficient adaptability. In scenarios such as industrial control, medical equipment, and precision instruments, users often need to simultaneously perform complex operations such as parameter adjustment, direction control, and mode switching. However, traditional keyboards are limited to a single key input method and cannot meet these multi-dimensional operational needs. In addition, existing professional keyboards often rely on imported chips and complex circuit designs, resulting in high costs, high power consumption, weak anti-interference capabilities, and insufficient stability in harsh environments, which seriously restricts their application scope.
[0003] In current technology, some solutions attempt to expand input functions by adding knobs or joysticks, but there are still significant defects, including signal conflicts when multiple buttons are triggered simultaneously, strong dependence on imported main control chips, and the need to manually switch device interfaces. Summary of the Invention
[0004] In view of the above problems, the purpose of the present invention is to provide a multi-mode fine-tuning keyboard circuit and control method based on FT32. At the hardware level, it adopts the domestic FT32 low-power processor, integrates multiple communication interfaces and program debugging ports, and realizes the localization of core components; the input module integrates diode matrix keys, rotary encoders and joystick multi-dimensional inputs, and takes into account both pin resource optimization and operation diversity through time-sharing scanning and diode anti-collision design; the power module introduces linear regulators and multiple protection circuits to improve anti-interference capabilities. At the software level, through dynamic priority allocation, adaptive protocol switching and low-power mode management, efficient fusion of multiple signals, seamless compatibility of equipment and energy consumption optimization are achieved. In addition, the status indication module drives the LED dynamic display based on the shift register, and realizes multi-dimensional information feedback with single-line control, which significantly improves the intuitiveness of user interaction.
[0005] In order to achieve the above object, the first aspect of the present invention provides a multi-mode fine-tuning keyboard circuit based on FT32, wherein the multi-mode fine-tuning keyboard circuit based on FT32: Main control module, input module, power module, communication interface module and status indication module; The main control module adopts the FT32 domestic low-power processor chip, which includes RS232 and USB communication interfaces and is equipped with a program download and debugging port. The input module includes a diode matrix key circuit, a rotary encoder circuit and a joystick multi-dimensional input circuit, wherein the diode matrix key circuit is composed of a row-and-column diode network, and each key is connected in series with a diode; The power module adopts a linear voltage regulator with an input voltage range of 1.7V to 7.5V; the input end of the linear voltage regulator is connected in series with a varistor, a voltage-stabilizing diode and a noise reduction capacitor, and the output end is connected to an anti-interference capacitor; The communication interface module includes a USB to serial port circuit and an RS232 circuit, and the USB to serial port circuit is connected to the main chip through a level conversion chip; The status indication module drives multiple LED indicator lights through an 8-bit shift register, and the shift register is connected to the main chip through a serial data input port and a clock signal.
[0006] In this solution, the diode matrix key circuit includes row lines and column lines, specifically: The row line and the column line are respectively connected to different general input or output pins of the main chip, and the key triggering state is determined by time-sharing scanning of the row line signal and detecting the change of the column line level; The diode is a unidirectional conducting element. The anode of the diode is connected to the row line corresponding to the key after being connected in series with the key, and the cathode of the diode is connected to the column line corresponding to the key.
[0007] In this solution, the rotary encoder circuit is specifically: Including incremental encoder; The incremental encoder outputs a quadrature pulse signal to the main chip; Wherein, the orthogonal pulse signal includes step number information and phase difference information.
[0008] In this solution, the joystick multi-dimensional input circuit includes a potentiometer or a Hall sensor, specifically: The potentiometer or Hall sensor is used to detect the X-axis and Y-axis displacement signals of the joystick; The displacement signal is converted into a digital signal by an analog-to-digital converter and then input into the main chip.
[0009] A second aspect of the present invention further provides a multi-mode fine-tuning keyboard control method based on FT32, which is applied to any of the multi-mode fine-tuning keyboard circuits based on FT32 described above, and the control method includes: Based on the preset time-sharing scan, the first trigger information of the diode matrix button is collected in real time; According to a preset first time period, first orthogonal pulse information of the rotary encoder and first displacement information of the joystick multi-dimensional input are collected in real time; Obtaining phase difference information and step number information according to the first orthogonal pulse information, determining the rotation direction according to the phase difference information, and determining the rotation step number according to the step number information; determining coordinate information according to the first displacement information; Based on the preset fusion priority, a first composite operation instruction is obtained according to the three types of input signals; Automatically selecting a USB or RS232 communication protocol based on the type of the connected device, and generating and sending a control data frame according to the first composite operation instruction; receiving a feedback data frame, and obtaining system status information according to the feedback data frame; According to the system status information, the LED is driven to display dynamically through the shift register.
[0010] In this solution, the acquisition process of the first trigger information of the diode matrix button is specifically as follows: outputting the first electrical level to the row lines of the diode matrix key circuit in sequence according to a preset second time period; The level information of the column line input of the diode matrix key circuit is read in sequence, wherein; determining whether the level information is the first level; If so, it means that the key corresponding to the current row and column line is in the pressed state; If not, it means that the keys corresponding to the current row and column lines are in the lifted state; According to the status of all buttons, the first trigger information is obtained.
[0011] In this solution, the acquisition process of the first orthogonal pulse information of the rotary encoder is specifically as follows: Capturing the first pulse signal and the second pulse signal of the rotary encoder through a preset edge-triggered interrupt; Recording the number of first pulse signals within the first time period to obtain the step count information; Obtaining the phase difference information according to a time difference between a rising edge of the first pulse signal and a rising edge of the second pulse signal; According to the step number information and the phase difference information, the first orthogonal pulse information is obtained In this solution, the process of collecting the first displacement information of the joystick multi-dimensional input is specifically as follows: Acquire the first analog-to-digital information and the second analog-to-digital information in real time according to a preset first time period; Obtaining abscissa information based on the abscissa length in a preset coordinate system and the first modulus information; Obtaining ordinate information based on the length of the ordinate in the preset coordinate system and the second modulus information; The first displacement information is obtained according to the horizontal coordinate information and the vertical coordinate information.
[0012] In this solution, based on the preset fusion priority, the first composite operation instruction is obtained according to the three types of input signals, specifically: The joystick input has the fastest response speed, followed by the rotary encoder, and the button is the conventional trigger; Determine whether there is a joystick multi-dimensional input signal or a rotary encoder signal; If yes, generating a first composite operation instruction according to the coordinate information and / or the rotation direction and number of steps; If not, a first compound operation instruction is generated according to the first trigger information.
[0013] In this solution, according to the system status information, the LED is driven to display dynamically through the shift register, specifically: Encoding the interface connection status, input signal and battery power into a display mark, wherein the display mark is an 8-bit binary number; updating the display mark according to the system status information; Based on a preset data transmission cycle, the display flag is transmitted bit by bit to the shift register.
[0014] The present invention provides a multi-mode fine-tuning keyboard circuit and control method based on FT32. At the hardware level, it adopts the domestically produced FT32 low-power processor, integrates multiple communication interfaces and program debugging ports, and realizes the localization of core components; the input module integrates diode matrix keys, rotary encoders and joystick multi-dimensional inputs, and takes into account both pin resource optimization and operation diversity through time-sharing scanning and diode anti-collision design; the power module introduces linear regulators and multiple protection circuits to improve anti-interference capabilities. At the software level, through dynamic priority allocation, adaptive protocol switching and low-power mode management, efficient fusion of multiple signals, seamless compatibility of equipment and energy consumption optimization are achieved. In addition, the status indication module drives LED dynamic display based on shift registers, and realizes multi-dimensional information feedback with single-line control, which significantly improves the intuitiveness of user interaction. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope.
[0016] Figure 1 The present invention provides a schematic diagram of a multi-mode fine-tuning keyboard circuit based on FT32; Figure 2The present invention provides a flowchart of a multi-mode fine-tuning keyboard control method based on FT32; Figure 3 A flow chart of generating a first composite operation instruction provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0017] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0018] Unless otherwise defined, all terms (including technical and scientific terms) used in the embodiments of the present invention have the same meaning as commonly understood by those skilled in the art to which the present invention belongs. It should also be understood that terms such as those defined in common dictionaries should be interpreted as having meanings consistent with their meanings in the context of the relevant technology, and should not be interpreted in an idealized or extremely formal sense, unless explicitly defined in this manner in the embodiments of the present invention.
[0019] The words "first", "second" and similar terms used in the embodiments of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Words such as "one", "an" or "the" do not indicate a quantity limitation, but rather indicate the existence of at least one. Similarly, words such as "include" or "comprise" mean that the elements or objects preceding the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Words such as "connect" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The steps before or after the method of the embodiment of the present invention do not necessarily have to be performed in exact order. On the contrary, the various steps may be processed in reverse order or simultaneously. At the same time, other operations may be added to these processes, or one or more steps may be removed from these processes.
[0020] Please refer to Figure 1 , Figure 1 A structural block diagram of the FT32-based multi-mode fine-tuning keyboard circuit provided by an embodiment of the present invention is shown.
[0021] like Figure 1 As shown, the first aspect of the present invention discloses the multi-mode fine-tuning keyboard circuit based on FT32, the circuit comprising: A main control module (101), an input module (102), a power supply module (103), a communication interface module (104), and a status indication module (105); The main control module adopts the FT32 domestic low-power processor chip, which includes RS232 and USB communication interfaces and is equipped with a program download and debugging port. The input module comprises a diode matrix key circuit (1021), a rotary encoder circuit (1022) and a joystick multi-dimensional input circuit (1023), wherein the diode matrix key circuit is composed of a row-column diode network, with each key connected in series with a diode; The power module adopts a linear voltage regulator with an input voltage range of 1.7V to 7.5V; the input end of the linear voltage regulator is connected in series with a varistor, a voltage-stabilizing diode and a noise reduction capacitor, and the output end is connected to an anti-interference capacitor; The communication interface module comprises a USB-to-serial port circuit (1041) and an RS232 circuit (1042), wherein the USB-to-serial port circuit is connected to the main chip via a level conversion chip; The status indication module drives multiple LED indicator lights through an 8-bit shift register, and the shift register is connected to the main chip through a serial data input port and a clock signal.
[0022] It should be noted that in this embodiment, the main control module uses a domestically produced FT32 low-power processor chip as the core controller. As an implementation, the FT32F072R8AT7 is used as the core controller. This chip has built-in RS232 and USB communication interfaces, supporting multi-protocol communication. Program download and debug ports include SWD or JTAG for firmware burning and real-time debugging. The main chip connects to the input module via GPIO pins, including general-purpose input / output pins for buttons, timer capture mode pins for encoders, and analog-to-digital converter pins for joysticks. The input module controls the shift register to drive the LEDs via SPI or I2C buses. The input module integrates a diode matrix key circuit, a rotary encoder circuit, and a multi-dimensional joystick input circuit. The diode matrix key circuit utilizes a matrix layout of at least 6 rows and 19 columns, with each key connected in series with a diode. The row lines connect to the main chip's output pins, and the column lines connect to its input pins. The rotary encoder circuit uses an incremental encoder, outputting A / B phase quadrature pulse signals to the main control chip. The main chip captures the pulses via timer interrupts to parse direction and step count. The joystick's multi-dimensional input circuit uses a dual-axis potentiometer or Hall effect sensor to detect the joystick's displacement in the X and Y axes. The signal is converted to a digital value by the analog-to-digital converter built into the main control chip. The power module uses a linear regulator to control the input voltage within a set range, including but not limited to 1.8V, 3.3V, and 5V. A varistor and a Zener diode are connected in series at the power module's input to suppress surges, and a noise reduction capacitor is connected in parallel to filter high-frequency noise. A low-ESR capacitor is configured at the power module's output to further stabilize the output voltage. The USB-to-serial circuit uses a CH340G chip to convert between USB and UART protocols. The RS232 circuit uses a MAX232 chip to convert between TTL and RS232 levels, making it compatible with industrial equipment. The status indicator module receives instructions from the main chip via serial data and clock lines using at least one 8-bit shift register chip, such as the 74HC595, to drive at least eight LEDs to display system status. This invention uses the FT32 chip to reduce dependence on imported chips; integrated buttons, knobs, and joysticks support complex operating scenarios; in addition, the power module includes multiple protection designs to ensure stability in harsh environments.
[0023] According to an embodiment of the present invention, the diode matrix key circuit includes row lines and column lines, specifically: The row line and the column line are respectively connected to different general input or output pins of the main chip, and the key triggering state is determined by time-sharing scanning of the row line signal and detecting the change of the column line level; The diode is a unidirectional conducting element. The anode of the diode is connected to the row line corresponding to the key after being connected in series with the key, and the cathode of the diode is connected to the column line corresponding to the key.
[0024] It's important to note that the row lines connect to the main chip's GPIO output pins, and the column lines connect to the main chip's GPIO input pins. Each button bridges the row and column lines, with a diode connected in series. The diode's anode connects to the corresponding row line, and its cathode connects to the corresponding column line. The diode's unidirectional conduction prevents reverse current flow, preventing short circuits between the row and column lines when multiple buttons are triggered simultaneously.
[0025] According to an embodiment of the present invention, the rotary encoder circuit is specifically: Including incremental encoder; The incremental encoder outputs a quadrature pulse signal to the main chip; Wherein, the orthogonal pulse signal includes step number information and phase difference information.
[0026] It should be noted that, as one implementation, the EC11 is used as an incremental encoder. Phases A and B of the EC11 are connected to the timer capture pins of the main chip. When a rising edge on phase A triggers an interrupt, the level of phase B is read. If the level of phase B is high, clockwise rotation is determined; if it is low, counterclockwise rotation is determined. The number of rising edges of phase A per unit time is counted, with each pulse corresponding to one step unit. The EC11's quadrature pulses offer a resolution of 100 steps per revolution, meeting precise control requirements.
[0027] According to an embodiment of the present invention, the joystick multi-dimensional input circuit includes a potentiometer or a Hall sensor, specifically: The potentiometer or Hall sensor is used to detect the X-axis and Y-axis displacement signals of the joystick; The displacement signal is converted into a digital signal by an analog-to-digital converter and then input into the main chip.
[0028] It should be noted that the joystick is mechanically connected to a dual-axis potentiometer or Hall effect sensor to detect the joystick's position offset. Taking the dual-axis potentiometer as an example, the joystick's position offset is calculated based on the change in resistance along the X and Y axes. The analog-to-digital converter within the main control chip converts the resistance value into a digital value. Based on this digital value, the main control chip determines the specific joystick displacement. The joystick implements two-dimensional input detection, extending the functionality of a traditional keyboard and suitable for directional control.
[0029] Please refer to Figure 2 , Figure 2 The flowchart of the multi-mode fine-tuning keyboard control method based on FT32 provided by the present invention is shown.
[0030] like Figure 2 As shown, the second aspect of the present invention discloses the multi-mode fine-tuning keyboard control method based on FT32, and the control method includes: S202, based on the preset time-sharing scan, collecting the first trigger information of the diode matrix button in real time; S204, collecting first quadrature pulse information of the rotary encoder and first displacement information of the joystick multi-dimensional input in real time according to a preset first time period; S206, obtaining phase difference information and step number information based on the first orthogonal pulse information, determining a rotation direction based on the phase difference information, and determining a rotation step number based on the step number information; S208, determining coordinate information according to the first displacement information; S210, obtaining a first composite operation instruction based on the three types of input signals based on a preset fusion priority; S212, automatically selecting a USB or RS232 communication protocol based on the connected device type, and generating and sending a control data frame according to the first composite operation instruction; S214, receiving a feedback data frame, and obtaining system status information according to the feedback data frame; S216: According to the system status information, the LED is driven to display dynamically via the shift register.
[0031] It should be noted that, first, during the input signal acquisition phase, a three-second matrix key is used to detect the trigger state according to a preset time-sharing scanning period. Based on a preset first time period, the A / B phase pulse signals of the rotary encoder and the analog-to-digital conversion values corresponding to the joystick position state of the multi-dimensional joystick input are captured in real time by the timer. A table lookup based on the analog-to-digital conversion values is then used to obtain first displacement information. Based on the A / B phase pulse signals, the rotation direction and number of rotation steps of the rotary encoder are determined. The specific coordinates of the joystick position are determined based on the first displacement information. Secondly, a corresponding first composite operation instruction is generated based on the input signal, with the priority of the joystick being higher than that of the encoder and higher than that of the key. This embodiment also supports the linkage of encoder adjustment and joystick control, meaning that the same composite operation instruction includes both encoder rotation information and joystick coordinate information. Next, based on the connected device, the corresponding communication transmission protocol is automatically identified and selected. Based on the first composite operation instruction and the communication transmission protocol, a corresponding transmission data frame is generated to transmit the control data frame. Finally, based on the feedback data frame of the connected device, the system status information is parsed and obtained; based on the system status information, the LED dynamic display is driven by the shift register to display at least the real-time connection status, input mode and battery power.
[0032] In the embodiment of the present invention, the process of collecting the first trigger information of the diode matrix button is specifically as follows: outputting the first electrical level to the row lines of the diode matrix key circuit in sequence according to a preset second time period; The level information of the column line input of the diode matrix key circuit is read in sequence, wherein; determining whether the level information is the first level; If so, it means that the key corresponding to the current row and column line is in the pressed state; If not, it means that the keys corresponding to the current row and column lines are in the lifted state; According to the status of all buttons, the first trigger information is obtained.
[0033] It should be noted that this embodiment provides a scanning process for matrix buttons. First, the main chip activates the row lines one by one in a preset order, that is, the output pins corresponding to the row lines output a high level. Next, the voltage levels on all column lines are read; if the column line is high, the corresponding key is pressed; if the column line is low, the corresponding key is lifted. Then, a software debounce mechanism is set. That is, the same key must be detected in the pressed state at least three times in a row before it is considered valid. Finally, the status of all keys is stored in a cache for generating trigger information.
[0034] In the embodiment of the present invention, the acquisition process of the first quadrature pulse information of the rotary encoder is specifically as follows: Capturing the first pulse signal and the second pulse signal of the rotary encoder through a preset edge-triggered interrupt; Recording the number of first pulse signals within the first time period to obtain the step count information; Obtaining the phase difference information according to a time difference between a rising edge of the first pulse signal and a rising edge of the second pulse signal; First orthogonal pulse information is obtained according to the step number information and the phase difference information.
[0035] It should be noted that this embodiment provides an encoder signal acquisition process. Based on the main chip's timer capture pin, the encoder's A / B phase state is captured in real time. When the A-phase pulse is on the rising edge, if the B-phase pulse is high, it indicates clockwise rotation of the knob; if the B-phase pulse is low, it indicates counterclockwise rotation of the knob. Furthermore, within a preset first time period, the number of rising edges of the A-phase pulse is recorded to indicate the number of steps the knob has rotated.
[0036] In the embodiment of the present invention, the process of collecting the first displacement information of the joystick multi-dimensional input is specifically as follows: Acquire the first analog-to-digital information and the second analog-to-digital information in real time according to a preset first time period; Obtaining abscissa information based on the abscissa length in a preset coordinate system and the first modulus information; Obtaining ordinate information based on the length of the ordinate in the preset coordinate system and the second modulus information; The first displacement information is obtained according to the horizontal coordinate information and the vertical coordinate information.
[0037] It should be noted that this embodiment provides a joystick signal acquisition process. During a preset first time period, the main control chip uses at least two analog-to-digital converters to convert the analog voltages corresponding to the X and Y axes of the joystick input circuit, respectively, to obtain at least two digital quantities. The digital quantities are then converted based on the lengths corresponding to the coordinate system to obtain the joystick mapping and coordinate position in the coordinate system. The FT32 main control chip's analog-to-digital converter has a 12-bit resolution, meaning the joystick detection accuracy reaches 4096 levels.
[0038] Figure 3 A flow chart of generating a first composite operation instruction provided by an embodiment of the present invention is shown.
[0039] In the embodiment of the present invention, Figure 3 As shown, based on the preset fusion priority, the first composite operation instruction is obtained according to the three types of input signals, specifically: S302, the joystick input has the highest response speed, followed by the rotary encoder, and the button is a regular trigger; S304, determining whether there is a joystick multi-dimensional input signal or a rotary encoder signal; S306, if yes, generating a first composite operation instruction according to the coordinate information and / or the rotation direction and number of steps; S308: If not, generate a first compound operation instruction according to the first trigger information.
[0040] It should be noted that in this embodiment, the priority of input responses is, from high to low, joystick, knob, and button. As an implementation, joystick input is triggered via an interrupt and has the highest priority; encoder input is captured via a timer interrupt and has the next highest priority; and button input is detected via polling and has the lowest priority. This priority division avoids command conflicts and improves control accuracy. Furthermore, if the joystick and encoder are triggered simultaneously, the joystick controls the target position, while the encoder adjusts the movement speed. In an application scenario, the joystick controls the direction of the robotic arm, while the encoder adjusts the movement speed, and the main chip outputs a composite command.
[0041] In an embodiment of the present invention, the LED is driven to display dynamically through a shift register according to the system status information, specifically: Encoding the interface connection status, input signal and battery power into a display mark, wherein the display mark is an 8-bit binary number; updating the display mark according to the system status information; Based on a preset data transmission cycle, the display flag is transmitted bit by bit to the shift register.
[0042] It should be noted that the system status includes at least the interface connection status, input signal, and battery power level. The interface connection status indicates whether the interface is connected, the input signal indicates whether the joystick, knob, or button is activated, and the battery power level indicates the remaining battery charge level. In one embodiment, the display flag data is sent to the shift register via the SPI bus. Only two pins are required to control multiple LEDs, conserving pin resources.
[0043] It is worth mentioning that the adaptation process of the communication interface is also included, specifically: After the fine-tuning keyboard circuit is powered on or awakened from sleep mode, first voltage information of the input terminal is detected; If the first voltage information is within a preset first voltage range, enabling the USB mode; If the first voltage information is within a preset second voltage range, enabling the RS232 mode; Among them, the encapsulation operation instructions in USB mode adopt the HID report descriptor format, and in RS232 mode, it is encapsulated into a serial frame structure including a start bit, data bits and check bits.
[0044] It should be noted that after the fine-tuning keyboard circuit is powered on or awakened from sleep mode, it detects the voltage at the communication interface input. If the voltage is within the range of 5V±0.5V, USB mode is enabled, and the data is packaged into an 8-byte HID report. If the voltage is within the range of 15V±1.5V, RS232 mode is enabled, and the data is assembled into a data frame consisting of a start bit, 8 data bits, an odd parity bit, and a stop bit. This automatic identification of the interface device eliminates the need for manual protocol switching, reducing user operation complexity.
[0045] It is worth mentioning that it also includes low power mode switching, specifically: Get the first duration of continuous no-operation; If the first duration information does not exceed the preset first duration threshold, entering the working mode; If the first duration information exceeds a preset first duration threshold, the device enters sleep mode and turns off the LED indicator light and the power supply of the communication interface; If the first duration information exceeds a preset second duration threshold, the system enters a deep sleep mode, retaining only the main chip basic clock and key interrupt wake-up functions.
[0046] It should be noted that this embodiment provides a low-power mode switching mechanism. In working mode, full functions are running, and the LED and communication interface are powered normally. If the keyboard is not operated for more than 5 minutes, it enters sleep mode, turns off the LED and communication interface, and the main chip enters a low-power state, retaining the key interrupt wake-up function; at this time, an interrupt is triggered by pressing a button, moving the joystick, or rotating the encoder, and the main chip immediately switches to working mode and resumes full-function operation. If the keyboard is not operated for more than 15 minutes, only the basic clock of the main chip is retained; at this time, a specific key combination or hardware reset is required to wake up.
[0047] In summary, the present invention provides a multi-mode fine-tuning keyboard circuit and control method based on FT32. At the hardware level, it adopts the domestically produced FT32 low-power processor, integrates multiple communication interfaces and program debugging ports, and realizes the localization of core components; the input module integrates the multi-dimensional input of the diode matrix key, rotary encoder and joystick, and takes into account the optimization of pin resources and the diversity of operations through time-sharing scanning and diode anti-collision design; the power module introduces a linear regulator and multiple protection circuits to improve the anti-interference ability. At the software level, through dynamic priority allocation, adaptive protocol switching and low-power mode management, efficient fusion of multiple signals, seamless compatibility of equipment and energy consumption optimization are achieved. In addition, the status indication module drives the LED dynamic display based on the shift register, and realizes multi-dimensional information feedback with single-line control, which significantly improves the intuitiveness of user interaction.
[0048] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0049] If the functions are implemented as software modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0050] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A multi-mode fine-tuning keyboard circuit based on FT32, characterized in that: The multi-mode fine-tuning keyboard circuit based on FT32 includes: Main control module, input module, power module, communication interface module and status indication module; The main control module adopts the FT32 domestic low-power processor chip, which includes RS232 and USB communication interfaces and is equipped with a program download and debugging port. The input module includes a diode matrix key circuit, a rotary encoder circuit and a joystick multi-dimensional input circuit, wherein the diode matrix key circuit is composed of a row-and-column diode network, and each key is connected in series with a diode; The power module adopts a linear voltage regulator with an input voltage range of 1.7V to 7.5V; the input end of the linear voltage regulator is connected in series with a varistor, a voltage-stabilizing diode and a noise reduction capacitor, and the output end is connected to an anti-interference capacitor; The communication interface module includes a USB to serial port circuit and an RS232 circuit, and the USB to serial port circuit is connected to the main chip through a level conversion chip; The status indication module drives multiple LED indicator lights through an 8-bit shift register, and the shift register is connected to the main chip through a serial data input port and a clock signal.
2. The multi-mode fine-tuning keyboard circuit based on FT32 according to claim 1, characterized in that: The diode matrix key circuit includes row lines and column lines, specifically: The row line and the column line are respectively connected to different general input or output pins of the main chip, and the key triggering state is determined by time-sharing scanning of the row line signal and detecting the change of the column line level; The diode is a unidirectional conducting element. The anode of the diode is connected to the row line corresponding to the key after being connected in series with the key, and the cathode of the diode is connected to the column line corresponding to the key.
3. The multi-mode fine-tuning keyboard circuit based on FT32 according to claim 1, characterized in that: The rotary encoder circuit is specifically: Including incremental encoder; The incremental encoder outputs a quadrature pulse signal to the main chip; Wherein, the orthogonal pulse signal includes step number information and phase difference information.
4. The multi-mode fine-tuning keyboard circuit based on FT32 according to claim 1, characterized in that: The joystick multi-dimensional input circuit includes a potentiometer or a Hall sensor, specifically: The potentiometer or Hall sensor is used to detect the X-axis and Y-axis displacement signals of the joystick; The displacement signal is converted into a digital signal by an analog-to-digital converter and then input into the main chip.
5. A multi-mode fine-tuning keyboard control method based on FT32, applied to the multi-mode fine-tuning keyboard circuit based on FT32 according to any one of claims 1 to 4, characterized in that: The control method includes: Based on the preset time-sharing scan, the first trigger information of the diode matrix button is collected in real time; According to a preset first time period, first orthogonal pulse information of the rotary encoder and first displacement information of the joystick multi-dimensional input are collected in real time; Obtaining phase difference information and step number information according to the first orthogonal pulse information, determining the rotation direction according to the phase difference information, and determining the rotation step number according to the step number information; determining coordinate information according to the first displacement information; Based on the preset fusion priority, a first composite operation instruction is obtained according to the three types of input signals; Automatically selecting a USB or RS232 communication protocol based on the type of the connected device, and generating and sending a control data frame according to the first composite operation instruction; receiving a feedback data frame, and obtaining system status information according to the feedback data frame; According to the system status information, the LED is driven to display dynamically through the shift register.
6. The multi-mode fine-tuning keyboard control method based on FT32 according to claim 5 is characterized in that: The acquisition process of the first trigger information of the diode matrix button is specifically as follows: outputting the first electrical level to the row lines of the diode matrix key circuit in sequence according to a preset second time period; The level information of the column line input of the diode matrix key circuit is read in sequence, wherein; determining whether the level information is the first level; If so, it means that the key corresponding to the current row and column line is in the pressed state; If not, it means that the keys corresponding to the current row and column lines are in the lifted state; According to the status of all buttons, the first trigger information is obtained.
7. The multi-mode fine-tuning keyboard control method based on FT32 according to claim 5, characterized in that: The acquisition process of the first orthogonal pulse information of the rotary encoder is specifically as follows: Capturing the first pulse signal and the second pulse signal of the rotary encoder through a preset edge-triggered interrupt; Recording the number of first pulse signals within the first time period to obtain the step count information; Obtaining the phase difference information according to a time difference between a rising edge of the first pulse signal and a rising edge of the second pulse signal; First orthogonal pulse information is obtained according to the step number information and the phase difference information.
8. The multi-mode fine-tuning keyboard control method based on FT32 according to claim 5 is characterized in that: The acquisition process of the first displacement information of the joystick multi-dimensional input is specifically as follows: Acquire the first analog-to-digital information and the second analog-to-digital information in real time according to a preset first time period; Obtaining abscissa information based on the abscissa length in a preset coordinate system and the first modulus information; Obtaining ordinate information based on the length of the ordinate in the preset coordinate system and the second modulus information; The first displacement information is obtained according to the horizontal coordinate information and the vertical coordinate information.
9. The multi-mode fine-tuning keyboard control method based on FT32 according to claim 5, characterized in that: The first composite operation instruction is obtained based on the preset fusion priority and the three types of input signals, specifically: The joystick input has the fastest response speed, followed by the rotary encoder, and the button is the conventional trigger; Determine whether there is a joystick multi-dimensional input signal or a rotary encoder signal; If yes, generating a first composite operation instruction according to the coordinate information and / or the rotation direction and number of steps; If not, a first compound operation instruction is generated according to the first trigger information.
10. The multi-mode fine-tuning keyboard control method based on FT32 according to claim 5, characterized in that: The LED dynamic display is driven by the shift register according to the system status information, specifically: Encoding the interface connection status, input signal and battery power into a display mark, wherein the display mark is an 8-bit binary number; updating the display mark according to the system status information; Based on a preset data transmission cycle, the display flag is transmitted bit by bit to the shift register.