Keyboard control method and device, equipment and storage medium
By obtaining the configuration information of the DMA control register, determining the lighting effect update mode and rate, and using DMA and lighting controller to optimize the keyboard lighting effect, the performance loss problem of the keyboard in different scenarios is solved, and efficient control and response are achieved.
Patent Information
- Application Number
- CN202510632055.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-05
AI Technical Summary
In the prior art, the hardware design of the keyboard cannot be effectively optimized in different application scenarios, resulting in poor performance losses and poor soft and hard coordination capabilities.
By obtaining the configuration information of the DMA control register, the lighting effect update mode and update rate are determined, and the keyboard lighting effect is controlled by using the DMA controller and the lighting controller, including the color data independent mode and consistent mode, the column update rate, the frame update rate and the flash update rate, etc.
It realizes efficient control and response of the keyboard in different application scenarios, optimizes performance, and reduces memory usage and bus resource consumption.
Smart Images

Figure CN120429022A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a keyboard control method, apparatus, device, and storage medium. Background Art
[0002] Keyboard drivers can be categorized as software-driven or hardware-plus-software-driven. Software-driven keyboards are completely controlled by application software, resulting in a complex workflow and significantly lower performance than hardware-plus-software-driven keyboards. Hardware-plus-software-driven keyboards rely on hardware to detect keystrokes and control lighting, while the software only needs to respond to keystrokes, offering higher performance.
[0003] In related technologies, in the hardware design of keyboards, most of them apply general functions to different application scenarios. The hardware design is not good enough to match various application environments, and the hardware operation is complex. In this way, the keyboard performance cannot be better optimized in specific scenarios, resulting in more performance losses in different scenarios and poor software and hardware coordination capabilities. Summary of the Invention
[0004] The embodiments of the present application provide a keyboard control method, apparatus, device and storage medium, which solve the problem in the prior art that the keyboard performance cannot be better optimized in specific scenarios, resulting in a large amount of performance loss in different scenarios and poor software and hardware coordination capabilities. It can achieve efficient control and response of the keyboard and optimize the performance in different application scenarios.
[0005] In a first aspect, an embodiment of the present application provides a keyboard control method, comprising:
[0006] When the lighting effect setting data is written into the first DMA control register by the external DMA module, configuration information of the second DMA control register is obtained, and a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information;
[0007] Accessing the lighting effect register based on the lighting effect update mode in the DMA controller, and updating the lighting effect data in the lighting effect register according to the lighting effect setting data;
[0008] Controlling the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data by a lighting controller;
[0009] Among them, the lighting effect update mode includes a color data independent mode and a color data consistent mode, the lighting effect update rate includes a column update rate, a frame update rate and a flashing update rate, and the lighting effect data includes lighting effect color data and lighting effect brightness data.
[0010] Optionally, the accessing the lighting effect register based on the lighting effect update mode by the DMA controller includes:
[0011] When the lighting effect update mode is the color data independent mode, linking the first DMA control register to the lighting effect register according to the DMA pointer of the second DMA control register through a DMA controller, wherein the number of links is the number of rows of the keyboard; and / or
[0012] When the lighting effect update mode is the color data consistent mode, the first DMA control register is linked to the lighting effect register according to the DMA pointer of the second DMA control register through the DMA controller, wherein the number of links is 1.
[0013] Optionally, when the lighting effect register is a color register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the PWM unit mask value configured in the color register.
[0014] Optionally, when the lighting effect register is a color register and a dead zone register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the dead zone length configured in the dead zone register.
[0015] Optionally, before the external DMA module writes the lighting effect setting data into the first DMA control register, the method further includes:
[0016] Determine the DMA request initiation time based on the lighting effect update rate determined by the configuration information of the second DMA control register;
[0017] Initiate access to the external DMA module at the DMA request initiation time, so that the external DMA module can feed back lighting effect setting data.
[0018] Optionally, determining the lighting effect update rate based on the configuration information of the second DMA control register and determining the DMA request initiation time includes:
[0019] When the lighting effect update rate determined based on the configuration information of the second DMA control register is the column update rate, the time when the dead zone starts after the column scan of each column of the keyboard is completed is determined as the DMA request initiation time;
[0020] When the lighting effect update rate determined based on the configuration information of the second DMA control register is the frame update rate, determining the time when the dead zone starts after the column scan of the last column of the keyboard is completed as the DMA request initiation time;
[0021] In a case where the lighting effect update rate determined based on the configuration information of the second DMA control register is a flickering update rate, the time when the flicker-off frame of the keyboard light starts is determined to be the DMA request initiation time.
[0022] Optionally, the method further includes:
[0023] The key state of the keyboard key is determined based on the key state capture time, and key response processing is performed according to the key state. The key state capture time is a time period after a preset time length after the column scan time of the key starts.
[0024] Optionally, determining the key state of a keyboard key based on the key state capture time includes:
[0025] In the case where it is detected during the key state capture time that all key outputs are valid levels, determining that the key state of the keyboard key is a valid keystroke;
[0026] When it is detected during the key state capture time that the key output has both a valid level and an invalid level, determining that the key state of the keyboard key is key hold;
[0027] When it is detected during the key state capture time that all key outputs are invalid levels, it is determined that the key state of the keyboard key is key release.
[0028] Optionally, performing key response processing according to the key state includes:
[0029] When the key state is a valid keystroke and / or a key maintenance state, executing key processing action control logic;
[0030] When the key state is key release, the key processing action control logic is not executed.
[0031] In a second aspect, an embodiment of the present application further provides a keyboard control device, comprising:
[0032] an acquisition module configured to acquire configuration information of a second DMA control register based on a situation in which the lighting effect setting data is written into the first DMA control register by an external DMA module;
[0033] a determination module configured to determine a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display according to the configuration information, wherein the lighting effect update mode includes a color data independent mode and a color data consistent mode, and the lighting effect update rate includes a column update rate, a frame update rate, and a flashing update rate;
[0034] An access module configured to access the lighting effect registers in the lighting effect update mode based on the DMA controller;
[0035] an updating module configured to update the lighting effect data in the lighting effect register according to the lighting effect setting data, wherein the lighting effect data includes lighting effect color data and lighting effect brightness data;
[0036] The control module is configured to control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0037] In a third aspect, an embodiment of the present application further provides a keyboard control device, the device comprising:
[0038] one or more processors;
[0039] a storage device for storing one or more programs,
[0040] When the one or more programs are executed by the one or more processors, the one or more processors implement the keyboard control method described in the embodiment of the present application.
[0041] In a fourth aspect, an embodiment of the present application further provides a storage medium storing computer-executable instructions, which, when executed by a computer processor, are used to execute the keyboard control method described in the embodiment of the present application.
[0042] In an embodiment of the present application, based on the case where the lighting effect setting data is written to the first DMA control register by an external DMA module, the configuration information of the second DMA control register is obtained, and the lighting effect update mode and lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information. The DMA controller accesses the lighting effect register based on the lighting effect update mode, and updates the lighting effect data of the lighting effect register according to the lighting effect setting data. The lighting effect of the keyboard is controlled by the lighting controller based on the lighting effect update rate and the updated lighting effect data, wherein the lighting effect update mode includes a color data independent mode and a color data consistent mode, the lighting effect update rate includes a column update rate, a frame update rate and a flashing update rate, and the lighting effect data includes lighting effect color data and lighting effect brightness data. This solution solves the problem in the prior art that the keyboard performance cannot be better optimized in specific scenarios, resulting in a large amount of performance loss in different scenarios and poor software and hardware coordination capabilities. It can achieve efficient control and response of the keyboard and optimize performance in different application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A flowchart of a keyboard control method provided in an embodiment of the present application;
[0044] Figure 2 A flowchart of a keyboard control method including a method for accessing a lighting effect register provided in an embodiment of the present application;
[0045] Figure 3 A flowchart of a keyboard control method including accessing color registers and updating lighting effect data provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of a PWM unit shielding condition of a column of keyboard keys provided in an embodiment of the present application;
[0047] Figure 5 A flowchart of a keyboard control method including accessing color registers and dead zone registers and updating lighting effect data provided in an embodiment of the present application;
[0048] Figure 6 A schematic diagram of the dead zone length of a column of keyboard keys provided in an embodiment of the present application;
[0049] Figure 7 A flowchart of a keyboard control method including determining a DMA request initiation time provided in an embodiment of the present application;
[0050] Figure 8 A flowchart of a keyboard control method including determining the key status and key response of a keyboard key provided in an embodiment of the present application;
[0051] Figure 9A module structure block diagram of a keyboard control device provided in an embodiment of the present application;
[0052] Figure 10 A schematic structural diagram of a keyboard control device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] The following is a further detailed description of the embodiments of the present application in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the embodiments of the present application, and are not intended to limit the embodiments of the present application. It should also be noted that, for ease of description, the accompanying drawings only show portions of the embodiments of the present application, rather than all structures.
[0054] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.
[0055] A keyboard control method provided in an embodiment of the present application can be applied to control scenarios of keyboards such as mechanical keyboards, gaming keyboards, and wireless keyboards.
[0056] Figure 1 A flowchart of a keyboard control method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, specifically including:
[0057] Step S101: Based on the lighting effect setting data being written into the first DMA control register by the external DMA module, configuration information of the second DMA control register is obtained, and a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information.
[0058] DMA (Direct Memory Access) is a data transfer mechanism that doesn't require CPU involvement. It can independently transfer data between peripherals and memory / registers, saving CPU resources and increasing transmission speeds. The external DMA module is an independent hardware module that works in conjunction with the DMA controller. The external DMA module is primarily responsible for bus operations and physical data transfer, while the DMA controller is primarily responsible for logical control. Through this external DMA module, the first DMA control register can be accessed and lighting effect setting data can be written to it. Based on the lighting effect setting data being written to the first DMA control register by the external DMA module, the configuration information of the second DMA control register can be obtained. The lighting effect setting data can be data information about the lighting effect setting that has been pre-written by software to any continuous address storage space accessible to the external DMA module. The first DMA control register and the second DMA control register are registers used to control and manage various parameters and states of DMA transfers. The first DMA control register is primarily used to manage the lighting effect setting data written by the external DMA module, while the second DMA control register is primarily used to store DMA configuration information. The configuration information of the second DMA control register can be used to determine the lighting effect update mode and lighting effect update rate of the keyboard lighting effect display. The lighting effect update mode is used to characterize the mode in which the keyboard's lighting effects are updated, and may include the color data independent mode and the color data consistent mode. The color data independent mode may refer to a mode in which the color data updated for each keyboard key is different. The color data consistent mode may refer to an update mode in which the color data updated for each column of keyboard keys is the same. The lighting effect update rate is used to characterize the update speed of the keyboard's lighting effects, and may include the column update rate, the frame update rate, and the flashing update rate. The column update rate refers to the lighting effect update after the effective scan of each column of keyboard keys is completed. The frame update rate refers to the lighting effect update after the effective scan of all columns of keyboard keys is completed. The flashing update rate refers to the lighting effect update after the keyboard keys have finished flashing.
[0059] For example, when the external DMA module accesses the first DMA control register to write lighting effect setting data, the configuration information of the second DMA control register is obtained as the color data independent mode and the column update rate, then the lighting effect update mode of the keyboard lighting effect display is determined to be the color data independent mode, and the lighting effect update rate is the column update rate.
[0060] Step S102: The DMA controller accesses the lighting effect register based on the lighting effect update mode, and updates the lighting effect data in the lighting effect register according to the lighting effect setting data.
[0061] Among them, after determining the lighting effect update mode and lighting effect update rate of the keyboard lighting effect display, the lighting effect register can be accessed based on the lighting effect update mode through the DMA controller, and the lighting effect data of the lighting effect register can be updated using the lighting effect setting data written in the first DMA control register. The DMA controller refers to a controller responsible for performing high-speed data transmission operations independently of the CPU in the system, and interacts with the external DMA module through the DMA request signal. The lighting effect register is used to represent the register that stores data related to the lighting effect of the keyboard keys. The lighting effect data refers to the relevant data for controlling the lighting effect displayed on the keyboard keys. The lighting effect data includes lighting effect color data and lighting effect brightness data. Among them, the lighting effect color data refers to the relevant data for controlling the color of the keyboard keys. The lighting effect brightness data refers to the relevant data for controlling the brightness of the keyboard keys. In one embodiment, a lighting effect register access method may be: when the lighting effect update mode is the color data independent mode, the first DMA control register is linked to the lighting effect register by the DMA controller according to the DMA pointer of the second DMA control register, wherein the number of links is the number of keyboard rows; when the lighting effect update mode is the color data consistent mode, the first DMA control register is linked to the lighting effect register by the DMA controller according to the DMA pointer of the second DMA control register, wherein the number of links is 1, and the color data consistent mode refers to an update mode in which the color data updated for each row of keyboard keys is the same. By adopting a configurable DMA pointer linking mechanism, differentiated lighting effect configurations can be implemented based on the color data independent mode, while the full keyboard lighting effect synchronous update is completed through the color data consistent mode, reducing repeated data transmission and register access operations, and significantly reducing memory usage and bus resource consumption.
[0062] Step S103: Control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0063] Among them, after completing the update of the lighting effect data of the lighting effect register, the lighting effect of the keyboard can be controlled by the lighting controller based on the lighting effect update rate and the updated lighting effect data. The lighting controller is a controller that controls the lighting display of the keyboard. The lighting controller can be responsible for the PWM control output of each row of RGB lights in the keyboard. Each row of RGB lights has three PWM wave outputs. The PWM wave output is composed of a PWM unit. A PWM unit is an RGB unit. The RGB unit refers to the color unit of an RGB lamp, that is, the three PWM waveforms of R (red), G (green), and B (blue) are mixed within a period of time to obtain a color unit. Exemplarily, the lighting effect update rate is updated per column, and the lighting effect data is the PWM output control data of each row of keyboard keys. After the current keyboard column key scan is completed and the lighting effect data update is completed, the lighting controller controls the PWM output of each keyboard key according to the updated PWM output control data of each row of keyboard keys to display the keyboard lighting effect.
[0064] From the above, it can be seen that by accessing the first DMA control register to write the lighting effect setting data through the external DMA module, the configuration information of the second DMA control register is obtained, and the lighting effect update mode and lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information. The lighting effect update mode includes the color data independent mode and the color data consistent mode. The lighting effect update rate includes the column update rate, the frame update rate and the flashing update rate. The lighting effect register is accessed based on the lighting effect update mode through the DMA controller, and the lighting effect data of the lighting effect register is updated according to the lighting effect setting data. The lighting effect data includes the lighting effect color data and the lighting effect brightness data. The lighting effect of the keyboard is controlled based on the lighting effect update rate and the updated lighting effect data through the lighting controller. This solution solves the problem in the prior art that the keyboard performance cannot be better optimized in specific scenarios, resulting in more performance losses in different scenarios and poor software and hardware coordination capabilities. It can achieve efficient control and response of the keyboard and optimize the performance in different application scenarios.
[0065] Figure 2 A flowchart of a keyboard control method including a lighting effect register access method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, specifically including:
[0066] Step S201: Based on the lighting effect setting data being written into the first DMA control register by the external DMA module, obtain configuration information of the second DMA control register, and determine the lighting effect update mode and lighting effect update rate of the keyboard lighting effect display according to the configuration information.
[0067] Step S202: When the lighting effect update mode is the color data independent mode, the first DMA control register is linked to the lighting effect register via the DMA controller according to the DMA pointer of the second DMA control register, wherein the number of links is the number of rows of the keyboard.
[0068] Wherein, the DMA pointer is used to represent an address value stored in the second DMA control register, and is used to guide the DMA controller to the target location for data transmission. In one embodiment, when the lighting effect update mode is the color data independent mode, the first DMA control register can be linked to the lighting effect register corresponding to each keyboard row according to the DMA pointer of the second DMA control register through the DMA controller, wherein one lighting effect register is used to store the lighting effect data of a row of keyboard keys. Exemplarily, the lighting effect update mode is the color data independent mode, that is, the lighting effect data of each keyboard key is different. The current DMA pointer of the second DMA control register is 0x00, which points to the lighting effect register 0 corresponding to the first row of keyboard keys. Then, the first DMA control register is linked to the lighting effect register 0 through the DMA controller. After the link is completed and the lighting effect setting data corresponding to the lighting effect register 0 is completed, the DMA pointer of the second DMA control register is automatically updated to 0x01, which points to the lighting effect register 1 corresponding to the second row of keyboard keys. And so on, until the lighting effect registers corresponding to the keyboard keys of all rows are linked to the first DMA control register.
[0069] Step S203: When the lighting effect update mode is the color data consistent mode, the first DMA control register is linked to the lighting effect register according to the DMA pointer of the second DMA control register through the DMA controller, wherein the number of links is 1.
[0070] In one embodiment, when the lighting effect update mode is the color data consistency mode, the first DMA control register is linked to the lighting effect register corresponding to any keyboard row according to the DMA pointer of the second DMA control register through the DMA controller, and after the lighting effect register completes the update of the lighting effect data, the lighting effect data after the lighting effect register is updated is updated to the lighting effect registers corresponding to other keyboard rows. Exemplarily, the lighting effect update mode is the color data consistency mode, that is, the lighting effect data of each column of keyboard keys is the same, and the DMA pointer of the second DMA control register points to the lighting effect register corresponding to the first keyboard row. Then, the first DMA control register is linked to the lighting effect register corresponding to the first keyboard row through the DMA controller, and after completing the transmission of the lighting setting data between the first DMA control register and the lighting effect register corresponding to the first keyboard row, the updated lighting effect data in the lighting effect register corresponding to the first keyboard row is updated to the lighting effect registers corresponding to other keyboard rows. During this period, the first DMA control register is linked to the lighting effect register only once.
[0071] Step S204: Update the lighting effect data in the lighting effect register according to the lighting effect setting data.
[0072] Step S205: Control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0073] As can be seen from the above, when the lighting effect update mode is the color data independent mode, the DMA controller links the first DMA control register to the lighting effect register according to the DMA pointer of the second DMA control register, where the number of links is the number of keyboard rows. When the lighting effect update mode is the color data consistent mode, the DMA controller links the first DMA control register to the lighting effect register according to the DMA pointer of the second DMA control register, where the number of links is 1. This solution uses a configurable DMA pointer linking mechanism to achieve differentiated lighting effect configuration based on the color data independent mode, while completing full keyboard lighting effect synchronous updates through the color data consistent mode, reducing repeated data transmission and register access operations, and significantly reducing memory usage and bus resource consumption.
[0074] Figure 3 A flowchart of a keyboard control method including access to a color register and updating lighting effect data is provided in an embodiment of the present application, such as Figure 3 As shown, specifically including:
[0075] Step S301: Based on the lighting effect setting data being written into the first DMA control register by the external DMA module, configuration information of the second DMA control register is obtained, and a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information.
[0076] Step S302: The DMA controller accesses the color register based on the lighting effect update mode, and updates the lighting effect data in the color register according to the lighting effect setting data.
[0077] Among them, when the lighting effect register is a color register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the PWM unit mask value configured in the color register. The PWM output duty cycle of each color channel refers to the PWM (pulse width modulation) signal duty cycle of the corresponding color channel (red, green, blue), which represents the proportion of the on-time of the color channel in one cycle. By adjusting the duty cycle combination of the three color channels, a variety of different RGB lamp colors can be generated. For example, the PWM output duty cycle of the blue channel, green channel and red channel is 100%, and the mixed color is white.
[0078] The PWM unit shield value is used to represent the shielded value in the PWM unit output of the RGB light when the keyboard key is scanned in the column. The brightness of the keyboard key can be adjusted by using the PWM unit shield value. The smaller the PWM unit shield value, the brighter the corresponding keyboard key brightness. For example, Figure 4 As shown, Figure 4 A schematic diagram of the PWM unit shielding situation of a column of keyboard keys provided in an embodiment of the present application, wherein the column length is the time length for scanning a column of keyboards, the scan length is the time length for valid scanning in the column length, that is, the time length for applying the scanning voltage, and the dead zone is the time length for invalid scanning in the column length, that is, the time length for not applying the scanning voltage. The keyboard has a total of 4 rows of keys, and each PWM module represents the PWM unit output by the RGB light of the keyboard key. The scan length is 8 PWM units. The PWM unit output in the first row is the same as the scan length, and its brightness is the brightest. The PWM unit value output in the second row is 7, the PWM unit shielding value is 1, and its brightness is less than that of the keys in the first row. The PWM unit value output in the third row is 6, the PWM unit shielding value is 2, and its brightness is less than that of the keys in the second row. No PWM unit value is output in the fourth row, and the PWM unit shielding value is 8, which is equal to the scan length. The RGB light of the keyboard key is off.
[0079] Step S303: Control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0080] As can be seen above, when the lighting effect register is a color register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle, and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the PWM unit mask value configured in the color register. This solution can adjust the brightness of each RGB light individually by adjusting the PWM output duration of each RGB light.
[0081] Figure 5A flowchart of a keyboard control method including access to a color register and a dead zone register and updating lighting effect data is provided in an embodiment of the present application, such as Figure 5 As shown, specifically including:
[0082] Step S401: Based on the lighting effect setting data being written into the first DMA control register by the external DMA module, configuration information of the second DMA control register is obtained, and a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information.
[0083] Step S402: The DMA controller accesses the color register and the dead zone register based on the lighting effect update mode, and updates the lighting effect data of the color register and the dead zone register according to the lighting effect setting data.
[0084] Among them, when the lighting effect register is a color register and a dead zone register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the dead zone length configured in the dead zone register. The dead zone register is a register for storing relevant data of the dead zone. The dead zone is the time length of invalid scanning in the keyboard column scan length, that is, the time length when the scanning voltage is not applied. It is used to wait for the output status output of the current column to be invalid before scanning the next column. It can prevent the key (scan) input of the previous column from affecting the state output of the key of the next column when the two columns are switched. The dead zone length is used to characterize the time length of the dead zone. The dead zone length can adjust the proportion of light in the column length time to achieve the purpose of adjusting the brightness. The shorter the dead zone length, the brighter the corresponding light. For example, Figure 6 As shown, Figure 6 A schematic diagram of the dead zone length of a column of keyboard keys provided in an embodiment of the present application, wherein the keyboard has a total of 4 rows of keys, DTL=1 corresponding to the dead zone outputted by the first row indicates that the dead zone length is 1 PWM unit length, DTL=3 corresponding to the dead zone outputted by the second row indicates that the dead zone length is 3 PWM unit lengths, DTL=5 corresponding to the dead zone outputted by the third row indicates that the dead zone length is 5 PWM unit lengths, and DTL=2 corresponding to the dead zone outputted by the fourth row indicates that the dead zone length is 2 PWM unit lengths. The light brightness is arranged according to the dead zone length of each row, and the brightness of the keys on the first row of keyboards is > the brightness of the keys on the fourth row of keyboards > the brightness of the keys on the second row of keyboards > the brightness of the keys on the third row of keyboards.
[0085] Step S403: Control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0086] As can be seen above, when the lighting effect registers are color registers and dead zone registers, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle, and red channel PWM output duty cycle configured in the color registers, and the lighting effect brightness data is the dead zone length configured in the dead zone registers. This solution can adjust the keyboard key lighting by updating the dead zone length in the dead zone registers.
[0087] Figure 7 A flowchart of a keyboard control method including determining a DMA request initiation time is provided in an embodiment of the present application, such as Figure 7 As shown, specifically including:
[0088] Step S501: Determine the lighting effect update rate based on the configuration information of the second DMA control register, determine the DMA request initiation time, and initiate access to the external DMA module at the DMA request initiation time, so that the external DMA module can feed back lighting effect setting data.
[0089] The DMA request is a signal requesting access to the external DMA module and feedback of lighting effect setting data. Different lighting effect update rates correspond to different DMA request initiation times. Optionally, the DMA request initiation time can be determined based on the lighting effect update rate determined by the configuration information of the second DMA control register. One method for determining the DMA request initiation time can be to, when the lighting effect update rate is the column update rate, determine the DMA request initiation time as the start of the dead zone after the column scan of each keyboard column completes; when the lighting effect update rate is the frame update rate, determine the DMA request initiation time as the start of the dead zone after the column scan of the last keyboard column completes; and when the lighting effect update rate is the blinking update rate, determine the DMA request initiation time as the start of the blinking-off frame of the keyboard lights. For example, if the lighting effect update rate is the column update rate and the column scan of the current nth keyboard column has completed, a DMA request is initiated to the external DMA module at the start of the dead zone of the keyboard column scan of the nth keyboard column. By initiating the DMA request at the start of the dead zone, the normal output of new data from the PWM unit is not affected, while also avoiding the increase of cached data.
[0090] In another embodiment, a method for determining the initiation time of a DMA request may be: when the DMA pointer in the configuration information of the second DMA control register points to the dead zone register and the lighting effect update rate is the column update rate, the start time of the output of the first PWM unit of the next column after the column scan of each keyboard column is completed is determined as the DMA request time; when the DMA pointer in the configuration information of the second DMA control register points to the dead zone register and the lighting effect update rate is the frame update rate, the start time of the output of the first PWM unit after the column scan of all keyboard columns is completed is determined as the DMA request time; when the DMA pointer in the configuration information of the second DMA control register points to the dead zone register and the lighting effect update rate is the flashing update rate, the start time of the output of the first PWM unit after the flashing off frame of the keyboard light is determined as the DMA request initiation time. By delaying the initiation and completion of the DMA request corresponding to the dead zone register to the first PWM unit, the possibility of DMA underflow exception can be reduced. Since the dead zone update data will take effect at the end of the first PWM unit (the scan length is determined by the column length and the dead zone length and is at least 1 PWM unit), there is more time left for the normal operation of DMA. It is only required to complete at least the DMA access process of all keyboard rows and one DMA access process in the first PWM unit within the dead zone, and it is not required to complete all DMA access processes within the dead zone.
[0091] Step S502: Based on the lighting effect setting data being written into the first DMA control register by the external DMA module, obtain configuration information of the second DMA control register, and determine the lighting effect update mode and lighting effect update rate of the keyboard lighting effect display according to the configuration information.
[0092] Step S503: The DMA controller accesses the lighting effect register based on the lighting effect update mode, and updates the lighting effect data in the lighting effect register according to the lighting effect setting data.
[0093] Step S504: Control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0094] As can be seen above, before the external DMA module accesses the first DMA control register to write the lighting effect setting data, the lighting effect update rate determined based on the configuration information of the second DMA control register is used to determine the DMA request initiation time. At this DMA request initiation time, access to the external DMA module is initiated, allowing the external DMA module to feedback the lighting effect setting data. This solution determines the initiation time of the DMA request by configuring the lighting effect update rate, establishing a precise coordination mechanism between hardware timing and software control, taking into account performance, real-time performance, and energy efficiency, providing an underlying guarantee for the smooth operation of complex keyboard lighting effects.
[0095] Figure 8 A flowchart of a keyboard control method including determining the key state and key response of a keyboard key is provided in an embodiment of the present application, such as Figure 8 As shown, specifically including:
[0096] Step S601: Based on the lighting effect setting data being written into the first DMA control register by the external DMA module, configuration information of the second DMA control register is obtained, and a lighting effect update mode and lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information.
[0097] Step S602: The DMA controller accesses the lighting effect register based on the lighting effect update mode, and updates the lighting effect data in the lighting effect register according to the lighting effect setting data.
[0098] Step S603: Control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0099] Step S604: determine the key state of the keyboard key based on the set key state capture time, and perform corresponding key response processing according to the key state, wherein the key state capture time is a time period after a preset length of time after the start of the column scan time of the set key.
[0100] Among them, the key state capture time is used to represent the time for detecting the key state of a keyboard key during column scanning. The key state capture time is the time period after the preset length of time after the column scanning time of the set key starts. Corresponding key response processing can be performed based on the determined key state of the keyboard key. Optionally, a key state determination method can be that when it is detected that the key outputs are all valid levels during the key state capture time, the key state of the keyboard key is determined to be a keystroke valid; when it is detected that the key outputs have both valid levels and invalid levels during the key state capture time, the key state of the keyboard key is determined to be a key hold; when it is detected that the key outputs are all invalid levels during the key state capture time, the key state of the keyboard key is determined to be a key release. Exemplarily, the column scanning time of the key is set to 20ms, and the preset duration is 10ms, that is, the key state capture time is the last 10ms of the column scanning time, the valid level value is 1, and the invalid level value is 0. In the last 10ms of the column scanning time, it is detected that the output of key a is all 1, that is, the key state of key a is valid keystroke, and in the last 10ms of the column scanning time, it is detected that the output of key b is all 0, that is, the key state of key b is key release, and in the last 10ms of the column scanning time, it is detected that the output of key c is both 1 and 0, that is, the key state of key c is key maintenance, wherein keys a, b, and c are keys in the same column.
[0101] In another embodiment, a method for determining the key state may be to perform multiple sampling of the key output within the same column scanning cycle within the key state capture time. If the proportion of valid levels in N consecutive samples exceeds a preset threshold, the key state of the keyboard key is determined to be a valid keystroke. If the proportion of invalid levels in N consecutive samples exceeds a preset threshold, the key state of the keyboard key is determined to be a key release. In other cases, the key state of the keyboard key is determined to be a key maintenance, where N is an integer greater than 1, and the time interval between the multiple samplings is less than the preset duration.
[0102] In one embodiment, the specific process of key response processing according to the key state can be: when the key state is a valid keystroke and / or a key is maintained, the key processing action control logic is executed, and when the key state is a key release, the key processing action control logic is not executed. The specific key processing action control logic is based on different software and hardware function settings. Taking the numeric keypad lock button set in the keyboard as an example, when the keystroke is detected to be valid, the corresponding numeric keypad lock or unlock control logic is executed. Of course, the key response processing process described above can also be reversed. For example, when the key state is a valid keystroke and / or a key is maintained, the key processing action control logic is not executed, and when the key state is a key release, the key processing action control logic is executed.
[0103] As can be seen from the above, the key state of a keyboard key is determined based on the set key state capture time, and the corresponding key response processing is performed according to the key state. The key state capture time is the period after the preset length of time after the start of the key column scan time. By designing that key state capture is not performed during the first period of the column scan, the key state is determined by the last period of the column scan. This can avoid obtaining an incorrect key state and improve the accuracy of the key state.
[0104] Figure 9 This is a module structure diagram of a keyboard control device provided in an embodiment of the present application. The device is used to execute a keyboard control method provided in the above embodiment and has the corresponding functional modules and beneficial effects of the execution method. Figure 9 As shown, the system specifically includes:
[0105] The acquisition module 101 is configured to acquire configuration information of the second DMA control register when the lighting effect setting data is written into the first DMA control register by the external DMA module;
[0106] a determination module 102 configured to determine a lighting effect update mode and a lighting effect update rate for the keyboard lighting effect display according to the configuration information, wherein the lighting effect update mode includes a color data independent mode and a color data consistent mode, and the lighting effect update rate includes a column update rate, a frame update rate, and a flashing update rate;
[0107] An access module 103 is configured to access the lighting effect registers in the lighting effect update mode based on the DMA controller;
[0108] An updating module 104 is configured to update the lighting effect data in the lighting effect register according to the lighting effect setting data, wherein the lighting effect data includes lighting effect color data and lighting effect brightness data;
[0109] The control module 105 is configured to control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through a lighting controller.
[0110] It can be seen from the above scheme that, based on the case where the lighting effect setting data is written to the first DMA control register by the external DMA module, the configuration information of the second DMA control register is obtained, and the lighting effect update mode and lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information. The DMA controller accesses the lighting effect register based on the lighting effect update mode, and updates the lighting effect data of the lighting effect register according to the lighting effect setting data. The lighting effect of the keyboard is controlled by the lighting controller based on the lighting effect update rate and the updated lighting effect data, wherein the lighting effect update mode includes a color data independent mode and a color data consistent mode, the lighting effect update rate includes a column update rate, a frame update rate and a flashing update rate, and the lighting effect data includes lighting effect color data and lighting effect brightness data. This scheme solves the problem in the prior art that the keyboard performance cannot be better optimized in specific scenarios, resulting in more performance losses in different scenarios and poor software and hardware coordination capabilities. It can achieve efficient control and response of the keyboard and optimize the performance in different application scenarios.
[0111] In a possible embodiment, the access module is specifically configured as follows:
[0112] When the lighting effect update mode is the color data independent mode, linking the first DMA control register to the lighting effect register according to the DMA pointer of the second DMA control register through a DMA controller, wherein the number of links is the number of rows of the keyboard; and / or
[0113] When the lighting effect update mode is the color data consistent mode, the first DMA control register is linked to the lighting effect register according to the DMA pointer of the second DMA control register through the DMA controller, wherein the number of links is 1.
[0114] Optionally, when the lighting effect register is a color register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the PWM unit mask value configured in the color register.
[0115] Optionally, when the lighting effect register is a color register and a dead zone register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the dead zone length configured in the dead zone register.
[0116] Optionally, the device further includes a request sending module configured to:
[0117] Before the lighting effect setting data is written into the first DMA control register by the external DMA module, the DMA request initiation time is determined based on the lighting effect update rate determined by the configuration information of the second DMA control register;
[0118] Initiate access to the external DMA module at the DMA request initiation time, so that the external DMA module can feed back lighting effect setting data.
[0119] Optionally, the request sending module is specifically configured as follows:
[0120] When the lighting effect update rate determined based on the configuration information of the second DMA control register is the column update rate, the time when the dead zone starts after the column scan of each column of the keyboard is completed is determined as the DMA request initiation time;
[0121] When the lighting effect update rate determined based on the configuration information of the second DMA control register is the frame update rate, determining the time when the dead zone starts after the column scan of the last column of the keyboard is completed as the DMA request initiation time;
[0122] In a case where the lighting effect update rate determined based on the configuration information of the second DMA control register is a flickering update rate, the time when the flicker-off frame of the keyboard light starts is determined to be the DMA request initiation time.
[0123] Optionally, the device further includes a key processing module configured to:
[0124] The key state of the keyboard key is determined based on the key state capture time, and key response processing is performed according to the key state. The key state capture time is a time period after a preset time length after the column scan time of the key starts.
[0125] Optional, key processing module, specific configuration is as follows:
[0126] In the case where it is detected during the key state capture time that all key outputs are valid levels, determining that the key state of the keyboard key is a valid keystroke;
[0127] When it is detected during the key state capture time that the key output has both a valid level and an invalid level, determining that the key state of the keyboard key is key hold;
[0128] When it is detected during the key state capture time that all key outputs are invalid levels, it is determined that the key state of the keyboard key is key release.
[0129] Optional, key processing module, specific configuration is as follows:
[0130] When the key state is a valid keystroke and / or a key maintenance state, executing key processing action control logic;
[0131] When the key state is key release, the key processing action control logic is not executed.
[0132] Figure 10 A schematic diagram of the structure of a keyboard control device provided in an embodiment of the present application is shown in FIG. Figure 10 As shown, the device includes a processor 201, a memory 202, an input device 203 and an output device 204; the number of processors 201 in the device can be one or more. Figure 10 In the embodiment, a processor 201 is used as an example; the processor 201, the memory 202, the input device 203 and the output device 204 in the device can be connected by a bus or other means. Figure 10 The example of the connection via bus is taken. The memory 202, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions or modules corresponding to a keyboard control method in an embodiment of the present application. The processor 201 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 202, that is, implements the above-mentioned keyboard control method. The input device 203 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the device. The output device 204 may include a display device such as a display screen.
[0133] An embodiment of the present application further provides a storage medium containing computer-executable instructions. When the computer-executable instructions are executed by a computer processor, the computer-executable instructions are used to perform a keyboard control method, the method comprising:
[0134] When the lighting effect setting data is written into the first DMA control register by the external DMA module, configuration information of the second DMA control register is obtained, and a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information;
[0135] Accessing the lighting effect register based on the lighting effect update mode in the DMA controller, and updating the lighting effect data in the lighting effect register according to the lighting effect setting data;
[0136] Controlling the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data by a lighting controller;
[0137] Among them, the lighting effect update mode includes a color data independent mode and a color data consistent mode, the lighting effect update rate includes a column update rate, a frame update rate and a flashing update rate, and the lighting effect data includes lighting effect color data and lighting effect brightness data.
[0138] It is worth noting that in the embodiment of the above-mentioned keyboard control method system, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of this application.
[0139] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the embodiments of the present application are described in more detail through the above embodiments, the embodiments of the present application are not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the embodiments of the present application, and the scope of the embodiments of the present application is determined by the scope of the appended claims.
Claims
1. A keyboard control method, characterized in that: include: When the lighting effect setting data is written into the first DMA control register by the external DMA module, configuration information of the second DMA control register is obtained, and a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display are determined according to the configuration information; Accessing the lighting effect register based on the lighting effect update mode in the DMA controller, and updating the lighting effect data in the lighting effect register according to the lighting effect setting data; Controlling the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data by a lighting controller; Among them, the lighting effect update mode includes a color data independent mode and a color data consistent mode, the lighting effect update rate includes a column update rate, a frame update rate and a flashing update rate, and the lighting effect data includes lighting effect color data and lighting effect brightness data.
2. The keyboard control method according to claim 1, wherein: The accessing of the lighting effect register by the DMA controller based on the lighting effect update mode includes: When the lighting effect update mode is the color data independent mode, linking the first DMA control register to the lighting effect register according to the DMA pointer of the second DMA control register through a DMA controller, wherein the number of links is the number of rows of the keyboard; and / or When the lighting effect update mode is the color data consistent mode, the first DMA control register is linked to the lighting effect register according to the DMA pointer of the second DMA control register through the DMA controller, wherein the number of links is 1.
3. The keyboard control method according to claim 1 or 2, characterized in that: When the lighting effect register is a color register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the PWM unit mask value configured in the color register.
4. The keyboard control method according to claim 1 or 2, characterized in that: In the case where the lighting effect register is a color register and a dead zone register, the lighting effect color data is the blue channel PWM output duty cycle, green channel PWM output duty cycle and red channel PWM output duty cycle configured in the color register, and the lighting effect brightness data is the dead zone length configured in the dead zone register.
5. The keyboard control method according to any one of claims 1 to 4, characterized in that: Before the external DMA module writes the lighting effect setting data into the first DMA control register, the method further includes: Determine the DMA request initiation time based on the lighting effect update rate determined by the configuration information of the second DMA control register; Initiate access to the external DMA module at the DMA request initiation time, so that the external DMA module can feed back lighting effect setting data.
6. The keyboard control method according to claim 5, characterized in that: The step of determining the lighting effect update rate based on the configuration information of the second DMA control register and determining the DMA request initiation time includes: When the lighting effect update rate determined based on the configuration information of the second DMA control register is the column update rate, the time when the dead zone starts after the column scan of each column of the keyboard is completed is determined as the DMA request initiation time; When the lighting effect update rate determined based on the configuration information of the second DMA control register is the frame update rate, determining the time when the dead zone starts after the column scan of the last column of the keyboard is completed as the DMA request initiation time; In a case where the lighting effect update rate determined based on the configuration information of the second DMA control register is a flickering update rate, the time when the flicker-off frame of the keyboard light starts is determined to be the DMA request initiation time.
7. The keyboard control method according to claim 1, wherein: The method further comprises: The key state of the keyboard key is determined based on the key state capture time, and key response processing is performed according to the key state. The key state capture time is a time period after a preset time length after the column scan time of the key starts.
8. The keyboard control method according to claim 7, wherein: The determining of the key state of a keyboard key based on the key state capture time includes: In the case where it is detected during the key state capture time that all key outputs are valid levels, determining that the key state of the keyboard key is a valid keystroke; When it is detected during the key state capture time that the key output has both a valid level and an invalid level, determining that the key state of the keyboard key is key hold; When it is detected during the key state capture time that all key outputs are invalid levels, it is determined that the key state of the keyboard key is key release.
9. The keyboard control method according to claim 7, wherein: The performing key response processing according to the key state includes: When the key state is a valid keystroke and / or a key maintenance state, executing key processing action control logic; When the key state is key release, the key processing action control logic is not executed.
10. A keyboard control device, characterized in that: include: an acquisition module configured to acquire configuration information of a second DMA control register based on a situation in which the lighting effect setting data is written into the first DMA control register by an external DMA module; a determination module configured to determine a lighting effect update mode and a lighting effect update rate of the keyboard lighting effect display according to the configuration information, wherein the lighting effect update mode includes a color data independent mode and a color data consistent mode, and the lighting effect update rate includes a column update rate, a frame update rate, and a flashing update rate; An access module configured to access the lighting effect registers in the lighting effect update mode based on the DMA controller; an updating module configured to update the lighting effect data in the lighting effect register according to the lighting effect setting data, wherein the lighting effect data includes lighting effect color data and lighting effect brightness data; The control module is configured to control the lighting effect of the keyboard based on the lighting effect update rate and the updated lighting effect data through the lighting controller.
11. A keyboard control device, comprising: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the one or more processors to implement the keyboard control method according to any one of claims 1 to 9.
12. A storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to perform the keyboard control method according to any one of claims 1 to 9 when executed by a computer processor.