Driving and function integration configuration method of multifunctional key in configuration software
By defining a list of virtual buttons and configuring functions in the configuration software, unified driving and integrated management of buttons with different physical interfaces are achieved. This solves the problem of multiple button interface types and inconsistent configuration methods in existing technologies, and improves the system's flexibility and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CSIC WUHAN LINCOM ELECTRONICS
- Filing Date
- 2026-03-10
- Publication Date
- 2026-05-29
AI Technical Summary
Existing configuration software has a variety of physical button interfaces with different function configurations and lacks unified management, resulting in simple interaction and insufficient flexibility, making it difficult to achieve flexible configuration of multi-functional buttons in complex industrial environments.
By defining a list and mapping table of virtual buttons and configuring virtual button functions, a unified driver and interface conversion between physical buttons and virtual buttons is achieved, supporting single-key, combination key, and long-press functions. Real-time detection and function triggering are performed using a button event queue and interrupt callback function.
It enables unified management of various interface buttons such as GPIO, USB, PS2, serial port, and network, improving the system's scalability and compatibility, enriching the dimensions of button interaction, enhancing operational flexibility and user experience, and reducing development and maintenance costs.
Smart Images

Figure CN122111303A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for driving and configuring the functions of a multi-function button, specifically a method for driving and configuring the functions of a multi-function button in configuration software, belonging to the field of human-computer interaction technology in industrial automation. Background Technology
[0002] Configuration software is a specialized software tool used in industrial automation, primarily for monitoring and controlling equipment and systems in production processes. It allows users to intuitively configure, manage, and operate various industrial equipment through a graphical interface, eliminating the need for complex coding. Configuration software typically features data acquisition, real-time monitoring, alarm management, and historical data storage, and is widely used in industries such as power, petroleum, chemical, and manufacturing. Its advantages lie in its high flexibility and ease of use, significantly improving production efficiency and system reliability. Configuration software is generally designed on a host computer and then downloaded to an HMI (Human Machine Interface) device for operation, enabling communication and control with devices such as PLCs and sensors. These HMI devices usually have touch functionality, using virtual buttons on the touchscreen for control and switching functions. However, in certain environments and situations, such as oil contamination, vibration, or high temperature and humidity, the touchscreen may not function properly or may be inconvenient to use. Due to the convenience and safety of physical buttons, some users prefer them. In such cases, physical buttons are required to control the HMI device.
[0003] In the prior art, 1) the method and storage medium for extending the function of button controls in configuration software disclosed in CN112416224B, which allows a button to be bound to multiple actions to achieve centralized control functions such as one-click full opening by adding a multi-action start option to the button control properties, but this technical solution is limited to virtual button controls on touch screens and fails to solve the problem of unified access for buttons with different physical interfaces. Moreover, its multi-action configuration still depends on the modification of specific control properties and lacks the abstraction and unified management of the underlying physical button interface; 2) a button mapping method, electronic device and system disclosed in CN114527903A, which identifies the button area in the game application through image processing algorithm and establishes the mapping relationship between the physical buttons of the game controller and the virtual buttons of the game. Although it realizes the control of virtual buttons by physical buttons, this solution is mainly for the matching of specific physical game controllers and game applications in game scenarios. Its mapping relationship is based on the recognition of virtual buttons at the application layer and fails to involve the unified processing of the driver layer of multiple physical interface buttons in industrial configuration software, nor does it provide the functional differentiation configuration of buttons under different configuration pages and the definition of multiple functions such as long press.
[0004] In summary, HMI devices have a variety of physical button interfaces, often including USB / PS2 keyboard buttons, GPIO buttons, serial port buttons, network buttons, CAN buttons, and other interface protocols. The button function configurations of different interfaces are not the same. Traditional HMI devices have problems such as fixed functions and simple interaction, and urgently need to improve flexibility through intelligent transformation. Summary of the Invention
[0005] The purpose of this invention is to provide a method for driving and configuring the functions of multi-function buttons in configuration software in order to solve at least one of the above-mentioned technical problems.
[0006] The present invention achieves the above objectives through the following technical solution: a method for driving and configuring the integrated function of a multi-function button in configuration software, comprising a button function configuration module and a button function implementation module; wherein, the button function configuration module performs unified virtual button driver mapping and virtual button function configuration for buttons with different interfaces, and the button function implementation module is used to implement virtual button driver registration, button interface and protocol conversion, and the implementation of the configured virtual button functions;
[0007] The configuration method includes the following steps:
[0008] Step 1: Define the virtual button list and configure the virtual button mapping table corresponding to different button interfaces;
[0009] Step 2: Configure virtual button functions, and configure the functions of single keys or combination keys;
[0010] Step 3: Register the virtual button driver;
[0011] Step 4: Interface and protocol conversion between physical buttons and virtual buttons;
[0012] Step 5: Virtual button detection and implementation.
[0013] As a further aspect of the present invention: In step one, defining the virtual button list specifically involves defining 100 virtual buttons ranging from Key1 to Key100; configuring the virtual button mapping table corresponding to different button interfaces specifically includes configuring the physical buttons of the GPIO interface, the key codes of the USB / PS2 keyboard, the key codes in the serial port protocol, and the key codes in the network or CAN interface protocol to correspond to a certain virtual button in the virtual button list, so as to realize the press or release event of the corresponding virtual button when the physical button is pressed or released.
[0014] As a further aspect of the present invention: In step two, the virtual button function configuration specifically includes configuring one or more button function records. Each record includes a button name, enable state, virtual button composition, single button or multiple combination buttons, configuration page supported by the virtual button, virtual button press function, virtual button release function, and virtual button long press function. The configuration page supported by the virtual button is configured to allow the same button to be configured with different functions on different pages. The virtual button long press function is configured to support multiple long press durations, each long press duration corresponding to a different operation function. Each virtual button long press function needs to be configured with long press duration, long press function configuration, long press execution count, and total execution count.
[0015] As a further aspect of the present invention: In step three, a set of virtual button drivers is registered, the state of the button queue is detected in real time, and the press and release events of the virtual buttons are triggered. The registration process specifically includes:
[0016] Define a key press event queue keyPressQueue and a key release event queue keyReleaseQueue to store keyboard press and release events of the virtual key driver;
[0017] Initialize the key table from key1 to key100. Each key includes the key state of press and release. The initial state is release.
[0018] Register the virtual button press interrupt callback function keyPressFunc and the virtual button release interrupt callback function keyReleaseFunc;
[0019] Check if there is an event in the key press event queue. If there is, take a key press event key from the tail of the queue and call the key press interrupt callback function keyPressFunc(key) to execute the key press function.
[0020] Check if there are any events in the key release event queue. If so, retrieve a release event key from the tail of the queue and call the key release interrupt callback function keyReleaseFunc(key) to execute the key release function.
[0021] The virtual button driver repeatedly checks whether there are events in the button press event queue and whether there are events in the button release event queue, and performs corresponding operations.
[0022] As a further aspect of this invention: In step four, the interface and protocol conversion between physical buttons and virtual buttons is used to perform unified virtual button interface conversion for buttons with different interfaces, supporting buttons with any interface such as GPIO buttons, USB keyboard buttons, PS / 2 keyboard buttons, serial keyboard buttons, and network keyboard buttons; the specific interface conversion approach includes:
[0023] Detect the button status of different interfaces. When a configured button is detected to be pressed, send a button press event to the button press event queue keyPressQueue.
[0024] When a key release is detected, a key release event is sent to the key release event queue keyReleaseQueue;
[0025] The virtual button driver module is used to uniformly handle the press and release events of all different interface buttons.
[0026] As a further aspect of the present invention: In step five, the virtual key detection and implementation involves implementing the functions of the virtual key press interrupt callback function keyPressFunc and the release interrupt callback function keyReleaseFunc, specifically including:
[0027] The virtual key press function `keyPressFunc` implements the configuration function for key presses, including single key presses and combination key presses. It defines a global real-time combination key list `m_multkey` to represent all keys pressed in real time, and is used to store the virtual keys that have been pressed in real time.
[0028] The virtual key press interrupt callback function keyPressFunc detects and implements the virtual key press function, including single key release and combination key release functions. If a virtual key is pressed and the key is not in the m_multkey list, the virtual key is added to the m_multkey list. The virtual key release interrupt callback function keyReleaseFunc detects and implements the virtual key release function. If the m_multkey list contains the currently released key, the virtual key is removed from the m_multkey list.
[0029] The function to detect and implement the long press function of the virtual button is in the timer interrupt function. The long press configuration of the virtual button includes the following attributes: the configured long press time (longPresstime), the current waiting time (waittime), the current remaining execution count (reserveCount), the total execution count limit (totalCount), and the specific execution function (func).
[0030] The beneficial effects of this invention are:
[0031] 1) This invention achieves significant technical benefits by uniformly mapping buttons on different physical interfaces to virtual buttons and decoupling functions from drivers. This method enables unified access and driver management for physical buttons on various interfaces such as GPIO, USB, PS2, serial port, network, and CAN. It eliminates the need to develop separate functional logic for each interface, greatly reducing the complexity of system development and maintenance costs, and improving the scalability and compatibility of the system. Through the virtual button function configuration mechanism, users can flexibly define the press, release, and long press functions of single buttons or any combination of buttons on different configuration pages according to actual needs. It also supports configuring differentiated functions for the same button on different pages and customizing multi-level long press times, greatly enriching the interaction dimensions of physical buttons and significantly improving the operational flexibility and user experience of HMI devices in complex industrial environments.
[0032] 2) This invention achieves accurate identification and function triggering of combination keys through the collaborative design of key press event queue, release event queue, and real-time combination key list, avoiding key conflicts and false triggers, and improving the reliability and security of the system. This integrated configuration method separates driver configuration from function configuration. When hardware interfaces change or function requirements are adjusted, only the mapping table or function configuration needs to be modified without changing the underlying driver code, which greatly shortens the development cycle and reduces maintenance difficulty, providing an efficient and flexible technical solution for intelligent transformation in the field of industrial automation. Attached Figure Description
[0033] Figure 1 This is a schematic diagram of the framework of the button function configuration module and the button function implementation module of the present invention;
[0034] Figure 2 This is a flowchart of the virtual button registration process of the present invention;
[0035] Figure 3 This is a flowchart of the GPIO button interface conversion process of the present invention;
[0036] Figure 4 This is a flowchart illustrating the serial port / USB / PS2 / network button interface conversion process of this invention.
[0037] Figure 5 Here is a flowchart of the keyPressFunc interrupt callback function of this invention;
[0038] Figure 6 This is a flowchart of the keyReleaseFunc interrupt callback function for the button release in this invention;
[0039] Figure 7 This is a flowchart of the long-press function for the button in this invention. Detailed Implementation
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] Example 1, as Figure 1 As shown, this embodiment provides a method for driving and configuring the integrated function of a multi-function button in configuration software, including a button function configuration module and a button function implementation module.
[0042] The button function configuration module performs unified virtual button driver mapping and virtual button function configuration for buttons on different interfaces. Specifically:
[0043] First, the button configuration is configured for different interfaces through button driver mapping. For example, GPIO buttons can be mapped to a virtual button, USB keyboard buttons can be mapped to a virtual button, virtual buttons corresponding to serial port button protocols can be mapped, virtual buttons corresponding to network button protocols can be mapped, and the mapped virtual buttons can be custom buttons. For example, the range of virtual buttons can be specified as 0~99, supporting a total of 100 different buttons.
[0044] Next, configure the functions of the virtual buttons. You can configure the functions of one or more virtual buttons. Each button function configuration includes: button name, specific virtual button components, configuration pages supported by the button, button press function, button release function, and button long press function.
[0045] The button function implementation module is used to implement virtual button driver registration, button interface and protocol conversion, and the configuration of virtual button functions. Specifically:
[0046] First, implement the registration of a virtual button driver, including a global key press event queue pressKeyQueue and a key release event queue releaseKeyQueue, as well as the registration of two interrupt functions keyPressFunc (key press function) and keyReleaseFunc (key release function);
[0047] Then, interface and protocol conversion is performed for different physical buttons. For example, the configured GPIO buttons are cyclically detected. When the state of a certain configured GPIO button changes, the button signal mapped to this GPIO is sent to the corresponding pressKeyQueue or releaseKeyQueue. Other interface keyboards are similar. When the queue changes, the registered interrupt function will be triggered.
[0048] Finally, the virtual button functions configured are implemented in the interrupt functions keyPressFunc and keyReleaseFunc, including press, release, and long press functions.
[0049] This driver and function integrated configuration method:
[0050] First: Define a list of virtual buttons and configure virtual button mapping tables for different button interfaces.
[0051] The virtual key list is defined as follows: 100 virtual keys ranging from Key1 to Key100;
[0052] Configuring the virtual button mapping table corresponding to different button interfaces specifically includes: configuring the physical buttons of the GPIO interface, the key codes of the USB / PS2 keyboard, the key codes in the serial port protocol, and the key codes in the network or CAN interface protocol to correspond to a certain virtual button in the virtual button list, so as to realize the press or release event of the corresponding virtual button when the physical button is pressed or released.
[0053] Second: Virtual button function configuration, configure the function of single keys or combination keys.
[0054] The virtual button function configuration specifically includes: configuring one or more button function records, wherein the button function record includes button name, enable status, virtual button composition, single button or multiple combination buttons, configuration page supported by virtual button, virtual button press function, virtual button release function and virtual button long press function;
[0055] The configuration page for virtual buttons can be configured to allow the same button to have different functions on different pages;
[0056] The virtual button long press function can be configured to support multiple long press durations, each long press duration corresponds to a different operation function, and each virtual button long press function needs to be configured with long press duration, long press function configuration, number of long press executions, and total number of executions.
[0057] Third: Register the virtual button driver.
[0058] Once a set of virtual button drivers is registered, the status of the button queue is monitored in real time, and the press and release events of the virtual buttons are triggered. The registration process specifically includes:
[0059] Define a key press event queue keyPressQueue and a key release event queue keyReleaseQueue to store keyboard press and release events of the virtual key driver;
[0060] Initialize the key table from key1 to key100. Each key includes the key state of press and release. The initial state is release.
[0061] Register the virtual button press interrupt callback function keyPressFunc and the virtual button release interrupt callback function keyReleaseFunc;
[0062] Check if there are any events in the key press event queue. If so, take a key press event from the tail of the queue and call the key press interrupt callback function keyPressFunc to execute the key press function.
[0063] Check if there are any events in the key release event queue. If so, retrieve a release event key from the tail of the queue and call the key release interrupt callback function keyReleaseFunc to execute the key release function.
[0064] The virtual button driver repeatedly checks whether there are events in the button press event queue and whether there are events in the button release event queue, and performs corresponding operations.
[0065] Fourth: Interface and protocol conversion between physical buttons and virtual buttons.
[0066] The interface and protocol conversion between physical and virtual buttons is used to provide a unified virtual button interface conversion for buttons with different interfaces. It supports buttons with any interface, including GPIO buttons, USB keyboard buttons, PS / 2 keyboard buttons, serial keyboard buttons, and network keyboard buttons. The specific interface conversion approach includes:
[0067] Detect the button status of different interfaces. When a configured button is detected to be pressed, send a button press event to the button press event queue keyPressQueue.
[0068] When a key release is detected, a key release event is sent to the key release event queue keyReleaseQueue;
[0069] The virtual button driver module is used to uniformly handle the press and release events of all different interface buttons.
[0070] Fifth: Virtual button detection and implementation.
[0071] Virtual key detection and implementation involves implementing the virtual key press interrupt callback function `keyPressFunc` and the release interrupt callback function `keyReleaseFunc`, specifically including:
[0072] The virtual key press function `keyPressFunc` implements the configuration function for key presses, including single key presses and combination key presses. It defines a global real-time combination key list `m_multkey` to represent all keys pressed in real time, and is used to store the virtual keys that have been pressed in real time.
[0073] The virtual key press interrupt callback function keyPressFunc detects and implements the virtual key press function, including single key release and combination key release functions. If a virtual key is pressed and the key is not in the m_multkey list, the virtual key is added to the m_multkey list. The virtual key release interrupt callback function keyReleaseFunc detects and implements the virtual key release function. If the m_multkey list contains the currently released key, the virtual key is removed from the m_multkey list.
[0074] The function to detect and implement the long press function of the virtual button is in the timer interrupt function. The long press configuration of the virtual button includes the following attributes: the configured long press time (longPresstime), the current waiting time (waittime), the current remaining execution count (reserveCount), the total execution count limit (totalCount), and the specific execution function (func).
[0075] Example 2: This example describes the driving method and integrated configuration method of the multi-function button in two parts.
[0076] I. Button function configuration method.
[0077] (1) Define 100 virtual buttons, Key1~Key100;
[0078] (2) Configure virtual buttons for different interface key codes as follows:
[0079] a. If there are 5 GPIO buttons: GPIO_6~GPIO_10, they can be configured as Key1~Key5, or any other 5 virtual buttons. When GPIO_6 is pulled low, it means that Key1 is pressed, and when GPIO_6 is pulled high, it means that Key1 is released.
[0080] b. If there are 5 USB keyboard keys: numbers 0 to 5, they can be configured as Key1 to Key5, or any other 5 virtual keys. When number 0 is pressed, it means that Key1 is pressed, and when number 0 is released, it means that Key1 is released.
[0081] c. If there are 5 buttons with serial port protocol, the button codes are: 0xA1~0xA5, which can be configured as Key1~Key5. When the button code A1 is received, it means that Key1 is pressed. When A1 is not received, it means that Key1 is released.
[0082] d. Other interface button configurations are similar to those described above.
[0083] (3) Configure the virtual buttons. You can configure one or more button functions. The configuration content is as follows:
[0084] a. Button name, unique identifier;
[0085] b. Virtual buttons can be configured, either as a single button or a combination of buttons. For example, configuring key1 indicates the function of button key1, and configuring key1 and key3 indicates the function of the combination of key1 and key3.
[0086] c. Configure the permissions of the button on the configuration page. For example, you can configure the button to be effective on a certain page or several pages, or you can configure the same button to support different functions on different pages.
[0087] d. Configure the specific operation function of each button press;
[0088] e. Configure the specific operation functions of the buttons;
[0089] f. Configure button long press function. Long press supports multiple long press durations. Each long press function can be configured with different operations, the time interval between operations during the long press, and the limit on the number of times the long press operation can be performed.
[0090] II. The implementation of button functions is divided into three parts: virtual button registration, button interface conversion, and button function implementation.
[0091] (1) Virtual button registration mainly completes a set of virtual button drivers, detects the status of the button queue in real time, and triggers the press and release events of virtual buttons. The virtual button driver registration process is as follows: Figure 2 As shown:
[0092] a. Define a key press event queue (keyPressQueue) and a key release event queue (keyReleaseQueue) to store keyboard press and release events from the virtual key driver;
[0093] b. Initialize the key table from key1 to key100. Each key includes the key state: press and release. The initial state is release.
[0094] c. Register the virtual key press interrupt callback function keyPressFunc and the virtual key release interrupt callback function keyReleaseFunc;
[0095] d. Check if there are any events in the key press event queue. If so, take a key press event key from the tail of the queue and call the key press interrupt callback function keyPressFunc(key) to execute the key press function.
[0096] e. Check if there are any events in the key release event queue. If so, take a release event key from the tail of the queue and call the key release interrupt callback function keyReleaseFunc(key) to execute the key release function.
[0097] f. The virtual button driver repeatedly executes the judgment and corresponding operation of d and e.
[0098] (2) Button Interface Conversion: This function provides a unified virtual button interface conversion for buttons on different interfaces. It supports buttons on any interface, including GPIO buttons, USB keyboard buttons, PS / 2 keyboard buttons, serial keyboard buttons, and network keyboard buttons. The interface conversion logic is to detect the button status of different interfaces. When a configured button is pressed, a button press event is sent to the button press event queue keyPressQueue. When a button is released, a button release event is sent to the button release event queue keyReleaseQueue. The virtual button driver module then handles all button press and release events from different interfaces in a unified manner.
[0099] GPIO button interface conversion such as Figure 3 As shown, the GPIO pin group is first initialized, and the mapping table between the GPIO pins configured for the button function and the configured mapping table is initialized. Then, the GPIO state is checked in a loop. If the GPIO button is pressed, it is low level; if it is released, it is high level. When a GPIO button is detected to be low level, it means that the button is pressed. The button value corresponding to the current pin is obtained, and the button value corresponding to the current button value is sent to the keyPressQueue. If the GPIO button value is high, and the previous state of the GPIO was low, it means that the button is released. The button value corresponding to the current pin is obtained, and the button value corresponding to the current button value is sent to the keyReleaseQueue.
[0100] Other button interfaces, such as USB / PS2 / serial / network, have similar virtual button interface conversions to GPIO button interface conversions. Figure 4As shown. First, initialize the USB / PS2 / serial port / network interfaces, initialize the protocol and mapping table of the button function configuration, and then start loop detection. When a button is detected as pressed, obtain the button value corresponding to the current pin, and send the button value corresponding to the current button value to the keyPressQueue. When a button is detected as released, and the button's last detected state was pressed, it means the button is released. Obtain the button value corresponding to the current pin, and send the button value corresponding to the current button value to the keyReleaseQueue.
[0101] (3) Key function implementation, mainly to implement the functions of the virtual key press interrupt callback function keyPressFunc and the release interrupt callback function keyReleaseFunc.
[0102] a. The `keyPressFunc` function implements the configuration functionality for virtual key presses, including single-key presses and combination key presses. It defines a global list of real-time combination keys, `m_multkey`, representing all keys pressed in real-time. The flowchart of the `keyPressFunc` function is as follows: Figure 5 As shown. First, the current key value (key) is obtained and added to the real-time combination key (m_multkey) list. If the length of the m_multkey list is 1, it means that only one key has been pressed. Then, it checks if this key is configured in the function configuration. If so, it checks if the current page is supported by the key configuration. If so, it checks if the current key is enabled. If enabled, the function configured for the current key is executed; otherwise, the current function ends under other conditions. If the length of the m_multkey list is greater than 1, and it matches the combination key configured in the function configuration, the page matches the configuration page, and the key is enabled, the function configured for the current key is executed; otherwise, the current function ends under other conditions.
[0103] b. The virtual key release function `keyReleaseFunc` implements the configuration functionality for key release, including single-key release and combination key release functions. The flowchart of the `keyPressFunc` function is as follows: Figure 6 As shown, the implementation function and method are similar to the virtual button press function keyPressFunc. Referring to the implementation process of the keyPressFunc function, the m_multkey list is used to remove buttons in this function.
[0104] c. The virtual button long-press configuration includes the following attributes: the configured long-press duration (longPresstime), the current wait time (waittime), the remaining execution count (reserveCount), the total execution count limit (totalCount), and the specific execution function (func). A 500ms timer is used to detect and implement the long-press function. The detection and implementation of the long-press button are carried out within the timer, as follows: Figure 7 As shown. If the current key combination `m_multkey` equals the configured key combination, then the `waittime` value configured for that long-press key is incremented by 500, and it is checked whether `waittime` is not less than `longPresstime`. If so, it is checked whether the remaining execution count `reserveCount` is greater than 0 and whether the total execution count `totalCount` is greater than 0. If so, it is checked whether the current page is a page supported by the key configuration. If so, it is checked whether the current key is enabled. If it is enabled, the function configured for the current long-press key is executed; otherwise, the current function ends under other conditions. The parameters configured for the virtual key long press are cleared in the virtual key release function `keyReleaseFunc`.
[0105] Working Principle and Process: The system achieves unified management and multi-functional definition of buttons across different physical interfaces through the collaborative work of two main modules: function configuration and function implementation. In the function configuration phase, a set of virtual buttons is first defined, and a one-to-one correspondence is established between the buttons of various physical interfaces (such as GPIO, USB, PS2, serial port, network, etc.) and these virtual buttons using a mapping table. Then, each virtual button (supporting single keys or arbitrary key combinations) is configured, including button name, enable state, effective configuration page, operation when pressed, operation when released, and long-press function (multiple long-press durations and corresponding operations can be configured). In the function implementation phase, the system registers virtual button drivers, creates button press event queues and release event queues, and registers corresponding interrupt callback functions. Simultaneously, the interface conversion module monitors the button state changes of each physical interface in real time, converting the physical button press or release events into corresponding virtual button events and sending them to the appropriate event queues. The virtual button driver continuously detects the queue. Once an event occurs, the registered interrupt callback function is called. In the callback function, the configured press or release function is executed based on the current real-time combination key list, the current configuration page, and the button enable state. In addition, the system continuously detects long press conditions through timer interrupts. When the configured long press time, execution count, and page permissions are met, the long press function is executed, and the relevant timing parameters are reset when the button is released. This achieves unified driver and integrated function configuration from physical buttons to virtual buttons.
[0106] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0107] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A method for integrating the driving and function configuration of multi-function buttons in configuration software, characterized in that: It includes a button function configuration module and a button function implementation module; wherein, the button function configuration module performs unified virtual button driver mapping and virtual button function configuration for buttons with different interfaces, and the button function implementation module is used to implement virtual button driver registration, button interface and protocol conversion, and the implementation of configured virtual button functions; The configuration method includes the following steps: Step 1: Define the virtual button list and configure the virtual button mapping table corresponding to different button interfaces; Step 2: Configure virtual button functions, and configure the functions of single keys or combination keys; Step 3: Register the virtual button driver; Step 4: Interface and protocol conversion between physical buttons and virtual buttons; Step 5: Virtual button detection and implementation.
2. The integrated configuration method for drivers and functions according to claim 1, characterized in that, In step one: The virtual key list is defined as follows: 100 virtual keys ranging from Key1 to Key100; Configuring the virtual button mapping table corresponding to different button interfaces specifically includes: configuring the physical buttons of the GPIO interface, the key codes of the USB / PS2 keyboard, the key codes in the serial port protocol, and the key codes in the network or CAN interface protocol to correspond to a certain virtual button in the virtual button list, so as to realize the press or release event of the corresponding virtual button when the physical button is pressed or released.
3. The integrated configuration method for drivers and functions according to claim 1, characterized in that, In step two: The virtual button function configuration specifically includes: configuring one or more button function records, wherein the button function record includes button name, enable status, virtual button composition, single button or multiple combination buttons, configuration page supported by virtual button, virtual button press function, virtual button release function and virtual button long press function; The virtual button supports configuration page settings that allow the same button to be configured with different functions on different pages; The virtual button long press function configuration supports multiple long press durations, each long press duration corresponds to a different operation function, and each virtual button long press function needs to be configured with long press duration, long press function configuration, number of long press executions, and total number of executions.
4. The integrated configuration method for drivers and functions according to claim 1, characterized in that, In step three: after registering a set of virtual button drivers, the status of the button queue is monitored in real time, and the press and release events of the virtual buttons are triggered. The registration process specifically includes: Define a key press event queue keyPressQueue and a key release event queue keyReleaseQueue to store keyboard press and release events of the virtual key driver; Initialize the key table from key1 to key100. Each key includes the key state of press and release. The initial state is release. Register the virtual button press interrupt callback function keyPressFunc and the virtual button release interrupt callback function keyReleaseFunc; Check if there are any events in the key press event queue. If so, take a key press event from the tail of the queue and call the key press interrupt callback function keyPressFunc to execute the key press function. Check if there are any events in the key release event queue. If so, retrieve a release event key from the tail of the queue and call the key release interrupt callback function keyReleaseFunc to execute the key release function. The virtual button driver repeatedly checks whether there are events in the button press event queue and whether there are events in the button release event queue, and performs corresponding operations.
5. The integrated configuration method for drivers and functions according to claim 1, characterized in that, In step four: The interface and protocol conversion between physical buttons and virtual buttons is used to perform unified virtual button interface conversion for buttons with different interfaces, supporting buttons with any interface such as GPIO buttons, USB keyboard buttons, PS / 2 keyboard buttons, serial keyboard buttons, and network keyboard buttons; The specific interface conversion approach includes: Detect the button status of different interfaces. When a configured button is detected to be pressed, send a button press event to the button press event queue keyPressQueue. When a key release is detected, a key release event is sent to the key release event queue keyReleaseQueue; The virtual button driver module is used to uniformly handle the press and release events of all different interface buttons.
6. The integrated configuration method for drivers and functions according to claim 1, characterized in that, In step five: Virtual key detection and implementation involves implementing the virtual key press interrupt callback function `keyPressFunc` and the release interrupt callback function `keyReleaseFunc`, specifically including: The virtual key press function `keyPressFunc` implements the configuration function for key presses, including single key presses and combination key presses. It defines a global real-time combination key list `m_multkey` to represent all keys pressed in real time, and is used to store the virtual keys that have been pressed in real time. The virtual key press interrupt callback function keyPressFunc detects and implements the virtual key press function, including single key release and combination key release functions. If a virtual key is pressed and the key is not in the m_multkey list, the virtual key is added to the m_multkey list. The virtual key release interrupt callback function keyReleaseFunc detects and implements the virtual key release function. If the m_multkey list contains the currently released key, the virtual key is removed from the m_multkey list. The function to detect and implement the long press function of the virtual button is in the timer interrupt function. The long press configuration of the virtual button includes the following attributes: the configured long press time (longPresstime), the current waiting time (waittime), the current remaining execution count (reserveCount), the total execution count limit (totalCount), and the specific execution function (func).