Automatic calibration methods, equipment, software products, and storage media for magnetic keyboard switches
By automating the calibration process, the system acquires the working status information of the magnetic keyboard, determines the calibration time window, collects environmental and operating parameters, and performs point-by-point calibration measurements and corrects characteristic data. This solves the problem of trigger characteristic deviation caused by environmental interference and performance degradation during the use of magnetic keyboards, thereby improving trigger accuracy and calibration reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-23
- Publication Date
- 2026-04-03
AI Technical Summary
During use, magnetic axis keyboards suffer from key trigger characteristics shift due to factors such as external magnetic field interference, keyboard PCB board deformation, and the performance decay of the switch magnets, which affects the user experience. Existing manual calibration methods are difficult to adapt to the dynamic changes in the actual environment.
By acquiring the working status information of the magnetic axis keyboard, determining the keyboard calibration time window, collecting the ambient magnetic field and keyboard operating parameters, determining the calibration mode, and calibrating and measuring point by point under a preset scanning sequence, characteristic data is generated. The calibration parameters are then calculated by combining the threshold correction, thus achieving automated calibration.
It improves the trigger accuracy of magnetic axis keyboards, overcomes the effects of external environmental interference and the performance decay of the axis magnets, and ensures the reliability and real-time performance of calibration results.
Smart Images

Figure CN121580682B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of keyboard calibration technology, specifically to an automatic calibration method, device, program product, and storage medium for magnetic axis keyboard switches. Background Technology
[0002] With the development of e-sports and office needs, mechanical keyboards are gradually evolving towards high performance and personalization. Among them, magnetic switch keyboards occupy an important position in the high-end keyboard market due to their advantages such as contactless design, long lifespan, and fast response speed. Magnetic switch keyboards use Hall effect sensors to detect changes in the magnetic field generated by the key displacement to trigger the key, thus avoiding the mechanical wear problems of traditional mechanical switches.
[0003] In existing technology, magnetic axis keyboards undergo trigger threshold calibration for each switch at the factory to ensure key actuation accuracy. However, during actual use, factors such as external magnetic field interference, keyboard PCB deformation, and the degradation of switch magnet performance can cause the switch actuation characteristics to shift. This shift can lead to problems such as unresponsive key actuation, false triggers, or inconsistent actuation positions, affecting the user experience. A common solution is to manually recalibrate the switches. However, this method requires active user intervention, and manual calibration typically requires specific environmental conditions, making it difficult to adapt to dynamic changes in the actual usage environment, thus reducing the actuation accuracy of the magnetic axis keyboard. Summary of the Invention
[0004] In view of this, this application provides an automatic calibration method, device, program product, and storage medium for magnetic keyboard switches.
[0005] Firstly, this application provides an automatic calibration method for magnetic axis keyboard switches, the method comprising:
[0006] Acquire the working status information of the magnetic axis keyboard, and determine the keyboard calibration time window based on the working status information. The working status information includes key status data and auxiliary behavior data.
[0007] During the keyboard calibration time window, ambient magnetic field parameters and keyboard operating parameters are collected, and the calibration mode is determined based on the ambient magnetic field parameters and the keyboard operating parameters.
[0008] In the calibration mode, the keyboard switches are calibrated and measured point by point according to a preset scanning sequence to generate characteristic data of each switch.
[0009] Threshold correction calculations are performed on the feature data of each shaft to obtain the calibration parameters of each shaft.
[0010] The calibration parameters are verified and stored hierarchically, and the magnetic axis keyboard master controller is switched to the calibrated working mode.
[0011] By adopting the above technical solution, the calibration process can be initiated at an appropriate time by acquiring the working status information of the magnetic axis keyboard and determining the keyboard calibration time window based on this information. Within the determined calibration time window, the calibration mode is determined by collecting environmental magnetic field parameters and keyboard operating parameters, enabling the calibration process to adapt to different usage environments. Furthermore, under the determined calibration mode, the keyboard switches are calibrated and measured point by point according to a preset scanning sequence, generating feature data. The calibration parameters are calculated by combining the threshold correction of the feature data, thereby achieving precise calibration of the switch triggering characteristics. Finally, by verifying and storing the calibration parameters in layers, and controlling the magnetic axis keyboard main controller to switch to the post-calibration working mode, the reliability and real-time performance of the calibration results are ensured. This solution overcomes the influence of external environmental magnetic field interference, keyboard PCB board deformation, and switch magnet performance decay on triggering characteristics through an automated calibration process, improving the triggering accuracy of the magnetic axis keyboard.
[0012] Optionally, in the calibration mode, the keyboard switches are calibrated point by point according to a preset scanning order to generate characteristic data for each switch, including:
[0013] Based on the physical layout of the magnetic axis keyboard, the switches are divided into multiple calibration units, each calibration unit contains a preset number of adjacent switches, and the magnetic field coupling between the adjacent switches meets a preset threshold requirement.
[0014] Select a reference shaft in each calibration unit, and collect the output voltage of the Hall element to obtain the static voltage value when the reference shaft is not pressed. Compare the static offset value with the preset factory reference voltage value.
[0015] By combining the static offset and performing standard displacement simulation using a miniature calibration electromagnet within the magnetic shaft driving the reference shaft, a magnetic field interference compensation coefficient between shafts in each calibration unit is established.
[0016] Based on the magnetic field interference compensation coefficient, each axis in each calibration unit is calibrated and measured sequentially to generate characteristic data of each axis in each calibration unit.
[0017] Optionally, the step of sequentially calibrating and measuring each axis within each calibration unit based on the magnetic field interference compensation coefficient to generate characteristic data for each axis within each calibration unit includes:
[0018] Each shaft in each calibration unit is sampled and measured a preset number of times in sequence. The first characteristic voltage and the corresponding first stroke data when each shaft reaches the conduction condition from the static position are recorded, as well as the second characteristic voltage and the corresponding second stroke data when it first reaches the de-conduction condition from the conduction position.
[0019] For all sampled first characteristic voltage, first stroke data, second characteristic voltage and second stroke data, outliers exceeding the preset range are removed using preset statistical rules;
[0020] The first characteristic voltage, first stroke data, second characteristic voltage, and second stroke data after removing outliers are compensated based on the magnetic field interference compensation coefficient to generate characteristic data representing the conduction and disconnection states of the shaft.
[0021] Optionally, the step of performing threshold correction calculations on the feature data of each shaft to obtain calibration parameters for each shaft includes:
[0022] Based on the first and second characteristic voltages in the characteristic data of each axis, calculate the conduction threshold offset and disconnection threshold offset of each axis;
[0023] When there is a first shaft with an absolute value of the conduction threshold offset less than or equal to the first offset threshold, and / or when there is a first shaft with an absolute value of the disconnection threshold offset less than or equal to the second offset threshold, the sum of the preset reference conduction threshold and the conduction threshold offset corresponding to the first shaft is used as the conduction threshold correction value, and / or the sum of the preset reference disconnection threshold and the disconnection threshold offset corresponding to the first shaft is used as the disconnection threshold correction value.
[0024] When there is a second shaft with an absolute value greater than the first offset threshold and / or when there is a second shaft with an absolute value greater than the second offset threshold, the conduction threshold offset and / or disconnection threshold offset are corrected based on the first stroke data and / or the second stroke data corresponding to the second shaft to obtain the conduction threshold correction value and / or disconnection threshold correction value of the second shaft; wherein, the disconnection threshold correction value of each shaft is less than the corresponding conduction threshold correction value and remains within a preset voltage difference range;
[0025] The conduction threshold correction value and / or disconnection threshold correction value of each shaft are used as calibration parameters.
[0026] Optionally, the step of performing data verification and hierarchical storage of the calibration parameters, and controlling the magnetic axis keyboard main controller to switch to the calibrated working mode, includes:
[0027] Perform integrity verification on the calibration parameters of each shaft;
[0028] The calibration parameters after verification are stored in a hierarchical manner, divided into temporary storage and persistent storage.
[0029] The temporary storage writes the verified calibration parameters into the main controller's random storage area for real-time key response after calibration; the persistent storage writes the verified calibration parameters into the keyboard flash calibration area and supports storing the calibration results of the most recent preset number of times for loading data on the next boot and for abnormal recovery.
[0030] Based on the calibration parameters in the random storage area, the magnetic axis keyboard master controller switches to the calibrated working mode, including turning off calibration-related function modules, judging key triggers according to the verified calibration parameters, and automatically switching to normal standby mode when no operation is detected within a preset time.
[0031] Optionally, determining the keyboard calibration time window based on the working status information includes:
[0032] Acquire key status data and axis signals within a preset time period, and calculate the time interval between two adjacent key presses in the key status data;
[0033] The system determines whether the time interval continuously exceeds a first preset duration, whether the trend of the time interval meets a preset growth condition, and whether the signals of each axis are abnormal. The first preset duration is determined by the user's historical behavior data.
[0034] When the time interval continuously exceeds the first preset duration, the change trend meets the preset growth condition, and there is no abnormality in any axis signal, it is determined whether the auxiliary behavior data all meet the corresponding preset calibration conditions. The auxiliary behavior data includes at least the lighting effect status, communication status, and power status of the magnetic axis keyboard.
[0035] When all the auxiliary behavior data meet the corresponding preset calibration conditions, the preset time period after the current time is determined as the keyboard calibration time window.
[0036] Optionally, the step of acquiring ambient magnetic field parameters and keyboard operating parameters within the keyboard calibration time window, and determining the calibration mode based on the ambient magnetic field parameters and the keyboard operating parameters, includes:
[0037] Within the keyboard calibration time window, keyboard operating parameters are acquired, and multiple sets of ambient magnetic field strength data are obtained by multi-stage sampling through the auxiliary Hall sensor on the main control board of the magnetic axis keyboard. The auxiliary Hall sensor is in a sleep state in non-calibration mode.
[0038] The multiple sets of environmental magnetic field strength data are filtered, and the average environmental magnetic field strength after filtering is determined.
[0039] The voltage ripple characteristics of the power supply voltage are determined based on the keyboard operating parameters, and the voltage stability coefficient is determined based on the voltage ripple characteristics.
[0040] When the average strength of the ambient magnetic field is less than a first magnetic field strength threshold and the voltage stability coefficient is less than a first voltage threshold, the first calibration mode is determined to be used.
[0041] When the average strength of the ambient magnetic field is greater than or equal to the first magnetic field strength threshold and less than the second magnetic field strength threshold, and the voltage stability coefficient is greater than or equal to the first voltage threshold and less than the second voltage threshold, the second calibration mode is adopted, wherein both the first calibration mode and the second calibration mode are performed under preset low power calibration conditions.
[0042] Otherwise, after a preset delay, the environmental magnetic field parameters and keyboard operation parameters will be collected again. If the number of retries exceeds the preset limit, it will be recorded in the error log.
[0043] A second aspect of this application provides an electronic device for automatic calibration of magnetic keyboard switches, the electronic device comprising: one or more processors and a memory; the memory being coupled to the one or more processors, the memory being used to store computer program code including computer instructions, the one or more processors calling the computer instructions to cause the electronic device for automatic calibration of magnetic keyboard switches to perform the method described in the first aspect and any possible implementation thereof.
[0044] A third aspect of this application provides a computer program product containing instructions that, when run on an electronic device for automatic calibration of magnetic key switches, causes the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0045] A fourth aspect of this application provides a computer-readable storage medium including instructions that, when executed on an electronic device for automatic calibration of magnetic key switches, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0046] In summary, one or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:
[0047] This application acquires the working status information of the magnetic axis keyboard and determines the keyboard calibration time window based on this information, allowing the calibration process to be initiated at an appropriate time. Within the determined calibration time window, the calibration mode is determined by collecting environmental magnetic field parameters and keyboard operating parameters, enabling the calibration process to adapt to different usage environments. Furthermore, under the determined calibration mode, the keyboard switches are calibrated point by point according to a preset scanning sequence, generating feature data. Calibration parameters are calculated by combining threshold corrections of the feature data, thereby achieving precise calibration of the switch triggering characteristics. Finally, by verifying and storing the calibration parameters in layers, and controlling the magnetic axis keyboard's main controller to switch to the post-calibration working mode, the reliability and real-time nature of the calibration results are ensured. This solution, through an automated calibration process, overcomes the influence of external environmental magnetic field interference, keyboard PCB board deformation, and switch magnet performance decay on triggering characteristics, improving the triggering accuracy of the magnetic axis keyboard. Attached Figure Description
[0048] Figure 1 This is a flowchart illustrating an automatic calibration method for magnetic axis keyboard switches provided in an embodiment of this application;
[0049] Figure 2 This is a schematic diagram of the calibration unit division of a magnetic axis keyboard provided in an embodiment of this application;
[0050] Figure 3 This is a schematic diagram of an exemplary hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0051] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0052] In the description of the embodiments of this application, the words "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design that is described as "for example" or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design options. Rather, the use of the words "for example" or "for instance" is intended to present the relevant concepts in a specific manner.
[0053] In the description of the embodiments of this application, the term "multiple" means two or more. For example, multiple systems means two or more systems, and multiple screen terminals means two or more screen terminals. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0054] Please refer to Figure 1 A flowchart illustrating an automatic calibration method for magnetic keyboard switches is presented. This method can be implemented using a computer program, a microcontroller, or run within a device for automatic calibration of magnetic keyboard switches. The computer program can be integrated into the computer device or run as a standalone application. Specifically, the method includes steps 10 to 50, as follows:
[0055] Step 10: Obtain the working status information of the magnetic axis keyboard, and determine the keyboard calibration time window based on the working status information. The working status information includes key status data and auxiliary behavior data.
[0056] In this embodiment, the working status information refers to various operational data used to determine the timing of magnetic axis keyboard calibration, including key status data characterizing keyboard key operation and auxiliary behavior data characterizing keyboard function operation. Key status data includes key trigger time, time interval between adjacent keys, and switch signal information; auxiliary behavior data includes keyboard lighting status, communication status, and power status.
[0057] Specifically, the system first acquires key status data and switch signals within a preset time period. It then calculates the time interval between two consecutive key presses to determine if this interval continuously exceeds a first preset duration and if the trend of the time interval meets a preset growth condition. Simultaneously, it checks for any anomalies in the switch signals. The first preset duration can be determined based on the user's historical behavior data. If the time interval continuously exceeds the first preset duration, the trend meets the preset growth condition, and there are no switch signal anomalies, the system further checks if auxiliary behavior data meets corresponding preset calibration conditions. Auxiliary behavior data includes the lighting effect status, communication status, and power status of the magnetic switch keyboard. When all auxiliary behavior data meets the preset calibration conditions, a preset time period after the current time is determined as the keyboard calibration time window. This method allows the calibration process to automatically start when the user is not operating the keyboard and it is in a stable state, avoiding interference with normal use.
[0058] As an optional embodiment, the step of determining the keyboard calibration time window based on the working status information may further include the following steps:
[0059] Step 101: Obtain the key status data and each axis signal within a preset time period, and calculate the time interval between two adjacent key actions in the key status data.
[0060] Specifically, during the actual operation of a magnetic switch keyboard, the main control chip needs to monitor the working status of all switches in real time through a keyboard scanning matrix to provide a reliable data foundation for subsequent automatic calibration decisions. The main control chip continuously collects the Hall element output voltage signal of each switch on the keyboard at a scanning frequency of 100Hz. This scanning frequency ensures timely response to user key presses while achieving an ideal balance in power consumption control. During this continuous scanning process, the main control chip accurately determines whether a switch is pressed by comparing its current voltage signal with its preset on and off thresholds, thus forming a complete key status data record. To obtain the temporal characteristics of user operations, the main control chip needs to perform in-depth time series analysis on the key status data. When any switch is detected to transition from a non-pressed state to a pressed state, the main control chip records the precise timestamp of this key press action and stores it in a preset circular buffer. By calculating the continuously recorded key press timestamps, the main control chip can determine the time interval between two adjacent key presses. This time interval calculation method includes not only the time interval between consecutive key presses but also the time interval between different key presses, thus comprehensively reflecting the user's overall operating rhythm. Simultaneously, the main control chip needs to acquire detailed information on each switch signal to promptly detect any potential hardware anomalies. During normal scanning, the main control chip continuously monitors the stability of the voltage signal output by the Hall element of each switch. When the switch is not pressed, the output voltage of its Hall element should remain within a relatively stable range. If the voltage signal of a switch exhibits abnormal fluctuations exceeding ±50 millivolts, or high-frequency jitter, the main control chip will mark this as an abnormal switch signal and record the switch number and abnormal characteristic parameters. This comprehensive signal monitoring mechanism ensures that all switches involved in the calibration are in normal working condition before automatic calibration, thus providing crucial assurance for the accuracy of the calibration results.
[0061] Step 102: Determine whether the time interval continuously exceeds the first preset duration, whether the trend of the time interval meets the preset growth condition, and whether the signals of each axis are abnormal. The first preset duration is determined by the user's historical behavior data.
[0062] Specifically, the main control chip performs continuity analysis on the calculated time intervals between two adjacent key presses. It determines the user's activity level by checking if multiple recent consecutive time intervals exceed a first preset duration. This first preset duration is not a fixed value but a personalized parameter dynamically determined by analyzing the user's historical behavior data. The AI algorithm module built into the main control chip performs deep learning analysis on the user's past key press data, statistically analyzing the distribution characteristics of the user's operation interval duration in different usage scenarios. For example, for users who frequently input text, the AI algorithm will find that their pause times during normal typing are typically between 5 and 20 seconds, while for users who mainly engage in gaming, their operation intervals may be shorter and more irregular. Based on these statistical analysis results, the AI algorithm calculates a personalized first preset duration for each user, usually set at the 90th percentile of the user's normal operation interval distribution. This avoids accidental calibration triggering during short pauses and ensures timely calibration when the user actually stops operating.
[0063] In addition to checking the continuity of time intervals, the main control chip also needs to analyze whether the trend of time interval changes meets preset growth conditions. This analysis process is achieved by trend fitting of the most recent consecutive time interval data. The main control chip calculates the first and second differences of the time interval sequence to determine whether the interval duration shows a continuous increasing trend. When three or more consecutive time intervals show an increasing pattern and the increase exceeds a preset threshold, the system considers that the user is gradually reducing the operation frequency, which usually indicates that the user is about to stop using the keyboard, thus meeting the preset growth condition. At the same time, the main control chip performs anomaly checks on the signals of each switch, analyzing the stability and consistency of the output voltage of the Hall element of each switch to determine whether there are hardware-level problems. For switches with detected voltage fluctuations exceeding ±50 millivolts, the main control chip further analyzes the frequency characteristics and duration of the fluctuations to distinguish whether they are temporary fluctuations caused by environmental interference or persistent anomalies caused by hardware failure. Only when the signals of all switches remain within the normal range and no abnormal fluctuation patterns are detected will the system consider the hardware status to meet the calibration requirements.
[0064] Step 103: When the time interval continuously exceeds the first preset duration, the change trend meets the preset growth condition, and there is no abnormality in any axis signal, determine whether the auxiliary behavior data all meet the corresponding preset calibration conditions. The auxiliary behavior data includes at least the lighting effect status, communication status, and power status of the magnetic axis keyboard.
[0065] Specifically, once the main control chip confirms that the time interval continuously exceeds the first preset duration, the trend of change meets the preset growth conditions, and there is no abnormality in any switch signal, the system needs to further check the status of various auxiliary functions of the keyboard to ensure that the calibration process is not interfered with by other system activities. The main control chip checks whether the lighting effect status of the magnetic switch keyboard meets the preset calibration conditions. Since the RGB lighting system is one of the main power sources on the keyboard, the electromagnetic interference and power fluctuations generated during its operation may affect the measurement accuracy of the Hall element. The main control chip reads the status register of the lighting effect controller to confirm whether the current lighting effect mode is in a static state. Specifically, the system checks whether the lighting effect is set to a fixed color mode or completely off, rather than a dynamically changing mode such as breathing, flowing, or audio response. If the lighting effect is detected to be in a dynamically changing mode, the system will determine that the preset calibration conditions are not met, because the frequent changes in dynamic lighting effects will cause fluctuations in power load, thereby affecting the accuracy of ADC conversion. Next, the main control chip checks the communication status to ensure that the calibration process is not interfered with by data transmission activities. For magnetic switch keyboards supporting wireless connectivity, the main control chip queries the transmission status of the Bluetooth or 2.4G wireless module to confirm whether there are any ongoing data packet transmissions. By reading the wireless module's status register and buffer occupancy, the system can determine whether there are background communication activities such as device interactions triggered by shortcut keys, firmware updates, and configuration file synchronization. Simultaneously, for wired keyboards, the main control chip also checks the activity status of the USB communication interface to confirm that there are no ongoing HID report transmissions or other USB transactions. Only when the communication module is idle and no data transmission activity is detected within the preset monitoring time window will the system consider the communication status to meet the preset calibration conditions. Power supply status checks are equally crucial, as a stable power supply voltage is fundamental to ensuring calibration accuracy. The main control chip continuously monitors the stability of the power supply voltage through its built-in power monitoring circuit, including the average, peak, and valley values of the voltage, as well as characteristic parameters of voltage ripple. For wired keyboards, the system checks whether the 3.3V operating voltage output after the 5V power supply from the USB port is regulated by the voltage regulator circuit and remains stable within the preset range, typically requiring voltage fluctuations not exceeding ±50 millivolts. For wireless keyboards, the system also needs to check if the battery is sufficiently charged, typically requiring a remaining charge of at least 30% to ensure that the battery voltage does not drop significantly throughout the calibration process. In addition, the main control chip analyzes the power supply ripple characteristics by rapidly and continuously sampling the power supply voltage and performing frequency domain analysis to confirm that the ripple amplitude and frequency distribution are within acceptable ranges.
[0066] Once the lighting effects, communication, and power states all meet their respective preset calibration conditions, the system will proceed with a final environmental stability verification. This includes reconfirming that the ambient magnetic field strength remains within a safe range and verifying that the keyboard's physical position has not shifted during the test. Through this comprehensive status check mechanism, the system ensures that the upcoming calibration process takes place in an ideal, undisturbed environment, thereby maximizing the accuracy and reliability of the calibration results.
[0067] Step 104: When all auxiliary behavior data meet the corresponding preset calibration conditions, determine the preset time period after the current time as the keyboard calibration time window.
[0068] Specifically, once all auxiliary behavior data meets the corresponding preset calibration conditions, the system first calculates the estimated time required to complete the calibration of all switches based on the keyboard's specific configuration parameters. This calculation process comprehensively considers the total number of switches, the number of rapid samplings for each switch, and the data processing time. Considering the efficient processing capabilities and optimized scanning algorithms of modern MCUs, for a standard 104-key keyboard, 20-30 rapid samplings per switch are sufficient to obtain adequate statistical accuracy, and the entire calibration process is expected to take 2-5 minutes. The main control chip adds a 10-15 second system preparation buffer time to the current time as the starting point for calibration. This brief buffer period is specifically used to complete critical system state adjustments before calibration.
[0069] The main control chip determines a preset time period after the current time as the keyboard calibration time window based on the calculated estimated calibration time. Specifically, the system adds 10-15 seconds to the current timestamp as a system preparation buffer time, sets this time point as the calibration start time, and then dynamically sets the duration of the calibration time window to 3-8 minutes based on the total number of switches and the proportion of switches requiring recalibration determined through pre-detection. For cases requiring only partial calibration, the time window is shortened to 2-3 minutes, while for cases requiring full calibration, the time window is extended to 6-8 minutes. This determined time window, calculated from the start time, provides the system with a clear calibration execution time range.
[0070] Step 20: Collect ambient magnetic field parameters and keyboard operating parameters within the keyboard calibration time window, and determine the calibration mode based on the ambient magnetic field parameters and keyboard operating parameters.
[0071] The ambient magnetic field parameters refer to the ambient magnetic field data collected by the auxiliary Hall sensor pre-installed on the keyboard main control board, including but not limited to: the ambient magnetic field strength value (in microtesla), the fluctuation range of the magnetic field strength, and the stability of the magnetic field direction. This auxiliary Hall sensor is normally in a dormant state and is only activated during the calibration phase. It continuously collects magnetic field data 10 times, and the data is filtered to obtain these parameters. When the average ambient magnetic field strength does not exceed 50 microtesla, the ambient magnetic field conditions are considered suitable for calibration.
[0072] Keyboard operating parameters refer to various system indicators that reflect the current working status of a magnetic switch keyboard, including power supply voltage and its stability, the operating frequency and power consumption data of the main control MCU, the operating status of RGB lighting effects, wireless communication status, and the signal stability of each switch.
[0073] Specifically, the system first awakens the auxiliary Hall sensor (which is normally in sleep mode) on the keyboard's main control board and continuously collects magnetic field data 10 times. After filtering and analysis, the environmental magnetic field parameters are obtained. If the detected environmental magnetic field strength exceeds the 50 microtesla threshold, the system will record a "calibration failure" log and postpone the calibration task to the next cycle (try again after 30 minutes). At the same time, a pop-up window will be displayed to the user through the driver software, suggesting that the keyboard be kept away from the magnetic field source.
[0074] Simultaneously, the system collects keyboard operating parameters, specifically by measuring the VCC power supply voltage value through the MCU's internal power voltage monitor or ADC channel to determine if it is stable within the 3.2V-3.4V range. When the voltage exceeds this range, for wired keyboards, it may indicate insufficient power supply to the USB port or a cable problem. In this case, log the issue and try reducing the MCU's operating frequency to decrease power consumption before retesting. For wireless keyboards, it may indicate low battery power. In this case, calibration should be immediately canceled to prioritize normal use, and the user should be prompted to charge the keyboard via the driver or indicator lights.
[0075] The system will only enter calibration mode when both the ambient magnetic field parameters and the keyboard operating parameters meet the calibration conditions. In calibration mode, the system first disables non-core functional modules such as the RGB lighting system (the main source of power consumption) and the wireless communication module (disabling the RF transmitter), and adjusts MCU parameters (reducing the core clock frequency, increasing ADC sampling accuracy, and enabling the internal reference voltage source) to put the system into a low-power, high-precision calibration state. Through this strict judgment mechanism based on real-time parameters and low-power mode switching, the calibration process can be ensured to be carried out under optimal conditions, improving calibration accuracy and avoiding unnecessary calibration attempts that may interfere with normal keyboard use.
[0076] In some embodiments, multiple calibration modes may be available. A calibration mode refers to the type of calibration strategy selected by the system based on the real-time status of ambient magnetic field parameters and keyboard operating parameters. These modes include a full calibration mode that performs complete calibration on all switches, a batch calibration mode that calibrates switches in groups, a single-point calibration mode that performs targeted calibration on individual switches, and an emergency calibration mode activated when a serious anomaly is detected. For example, when the average ambient magnetic field strength does not exceed 50 microtesla and the power supply voltage is stable, the full calibration mode is selected to perform complete calibration on all switches; when environmental conditions are basically met but not ideal, the batch calibration mode is selected to calibrate switches in groups; when a large offset is detected in individual switches, the single-point calibration mode is selected for targeted calibration; and when a serious anomaly such as severe fluctuations in switch signals occurs, the emergency calibration mode is activated.
[0077] As an optional embodiment, the step of acquiring ambient magnetic field parameters and keyboard operating parameters within the keyboard calibration time window, and determining the calibration mode based on the ambient magnetic field parameters and keyboard operating parameters, may further include the following steps:
[0078] Step 201: Obtain keyboard operating parameters within the keyboard calibration time window, and perform multi-stage sampling through the auxiliary Hall sensor on the main control board of the magnetic axis keyboard to obtain multiple sets of ambient magnetic field strength data. The auxiliary Hall sensor is in sleep mode in non-calibration mode.
[0079] Specifically, within the defined keyboard calibration time window, the power supply voltage of the keyboard is first collected by the power voltage monitor inside the MCU. Simultaneously, it checks whether the RGB lighting effects are in static mode, whether the wireless communication module is transmitting data, and whether the signals of each switch are stable. These data constitute the keyboard's operating parameters. At the same time, the system wakes up the auxiliary Hall sensor specifically reserved on the main control board (this sensor is in sleep mode in non-calibration mode to reduce power consumption). A time-segmented sampling strategy is used to acquire ambient magnetic field data: magnetic field strength data is continuously collected 10 times at a sampling frequency of 100Hz, ensuring that a complete magnetic field strength value is obtained in each sample. This sampling strategy can effectively monitor the stability of the ambient magnetic field.
[0080] Step 202: Filter the multiple sets of environmental magnetic field strength data and determine the average environmental magnetic field strength after filtering.
[0081] Specifically, to ensure data accuracy, the system filters the 10 sets of collected environmental magnetic field strength data, using the "3σ principle" to remove outliers (data exceeding the average ± 3 standard deviations). Then, a moving average filter is applied to the remaining data to calculate the average environmental magnetic field strength. This processing method effectively removes noise interference during the sampling process, resulting in more accurate environmental magnetic field parameters.
[0082] Step 203: Determine the voltage ripple characteristics of the power supply voltage based on the keyboard operating parameters, and determine the voltage stability coefficient based on the voltage ripple characteristics.
[0083] Specifically, the system continuously samples and monitors the VCC power supply voltage for 200ms at a sampling frequency of 1kHz using the MCU's internal power voltage monitor or ADC channel. For wired keyboards, the focus is on analyzing the voltage ripple characteristics generated by USB power supply: the collected voltage data is segmented into 20ms windows, and the difference between the maximum and minimum values within each window is calculated to obtain the peak-to-peak value of the ripple, while simultaneously recording the periodic variation characteristics of the ripple. For wireless keyboards, the focus is on the stability of battery power supply: the voltage drop slope and fluctuation amplitude are calculated. Based on the obtained voltage ripple characteristics, the system uses a weighted calculation method to determine the voltage stability coefficient. The specific calculation process is as follows: first, the ripple amplitude score is calculated, that is, the ratio of the peak-to-peak value of the ripple to the standard value (0.2V) is mapped to a score range of 0-0.4; second, the ripple frequency score is calculated, mapping the deviation of the periodic variation characteristics of the ripple from the ideal state to a range of 0-0.3; finally, the duration score is calculated, mapping the duration characteristics of voltage changes to a range of 0-0.3. Add these three scores together to get the final voltage stability coefficient. The closer the coefficient is to 0, the more stable the power supply.
[0084] For wired keyboards, when the voltage stability coefficient exceeds a preset threshold, the system attempts to reduce power consumption by lowering the MCU operating frequency (e.g., from 8MHz to 4MHz), thereby improving power supply stability. For wireless keyboards, if the voltage stability coefficient is high and shows a continuous upward trend, it may be due to insufficient battery power. In this case, the system will prompt the user to charge the battery in time via driver software or keyboard indicator lights. This voltage stability evaluation mechanism based on multi-dimensional characteristics effectively ensures the power supply environment for subsequent calibration processes.
[0085] Step 204: When the average strength of the ambient magnetic field is less than the first magnetic field strength threshold and the voltage stability coefficient is less than the first voltage threshold, determine to adopt the first calibration mode.
[0086] Specifically, the system first compares the filtered average strength of the ambient magnetic field with a first magnetic field strength threshold (50 microtesla), and simultaneously determines whether the voltage stability coefficient is less than a first voltage threshold (0.1). When both conditions are met, it indicates that the current environment is most suitable for calibration, and the system will adopt the first calibration mode. In practice, the system first enters a low-power calibration state: turning off the RGB lighting system to reduce system power consumption by 25%; turning off the RF transmitter of the wireless communication module to reduce electromagnetic interference; reducing the MCU core frequency from 8MHz to 4MHz to improve ADC sampling accuracy; and enabling the internal 2.5V reference voltage source to replace the external voltage reference. In this low-power, high-precision state, the system performs a complete calibration process for each axis in the order from the first row and first column to the last row and last column: First, it collects the static voltage value under no-press conditions (sampling rate 100Hz, continuous sampling of 100 points); then it performs simulated trigger detection (starting from a pressing depth of 0.5mm, increasing in increments of 0.1mm to 4.0mm); finally, it performs threshold acquisition (100 samples are taken at each test point to obtain parameters such as V_on_act and V_off_act).
[0087] Step 205: When the average strength of the ambient magnetic field is greater than or equal to the first magnetic field strength threshold and less than the second magnetic field strength threshold, and the voltage stability coefficient is greater than or equal to the first voltage threshold and less than the second voltage threshold, the second calibration mode is adopted, wherein both the first calibration mode and the second calibration mode are performed under preset low power calibration conditions.
[0088] Specifically, when the average strength of the ambient magnetic field is between 50 and 100 microtesla, and the voltage stability coefficient is between 0.1 and 0.2, it indicates that the environmental conditions are basically acceptable but not ideal. In this case, the system adopts the second calibration mode. In this mode, it also needs to enter the aforementioned low-power calibration state, but the calibration strategy is adjusted: the 104 buttons are divided into 8 groups (13 buttons per group), and calibration is performed using a time-division multiplexing method. After each group is calibrated, the system performs a stability check: continuously collecting the static voltage values of all axes in that group, calculating the standard deviation, and if the standard deviation exceeds the threshold (±50mV), the group is recalibrated. This group calibration strategy can still ensure calibration quality even in less than ideal environments. To ensure the continuity of the calibration process, the system reserves 100ms of settling time when switching between groups, allowing the power supply and magnetic field to return to a stable state.
[0089] Step 206: Otherwise, after a preset delay, re-collect the environmental magnetic field parameters and keyboard operation parameters. If the number of retries exceeds the preset limit, record it in the error log.
[0090] Specifically, when the average strength of the ambient magnetic field exceeds 100 microtesla or the voltage stability coefficient is greater than 0.2, the system will initiate a delayed retry mechanism. First, the current environmental parameters are recorded in the anomaly log, including: the ambient magnetic field strength value and its fluctuation range, the voltage stability coefficient, and the signal status of each axis. Then, the system enters a delayed waiting state, with a default delay time of 30 minutes. During the delay, the system performs a rapid check every 5 minutes (sampling frequency reduced to 10Hz, number of sampling points reduced to 10). Once a significant improvement in the environment is detected (magnetic field strength decreases by more than 20% or voltage stability increases by more than 30%), the delay ends early and the complete parameter acquisition process restarts. If the calibration conditions are still not met after 3 retries (a total of 90 minutes), the system will: write a complete retry record to the anomaly log; send a clear environmental anomaly prompt to the user through the driver software, specifying whether the problem is caused by magnetic field interference or power instability; for wired keyboards, it is recommended to check the USB power supply; for wireless keyboards, it is recommended to change the usage environment. Through this progressive retry mechanism and detailed anomaly feedback, both calibration quality and effective user guidance are ensured.
[0091] Step 30: In calibration mode, perform calibration measurements on each keyboard switch point by point according to the preset scanning order to generate characteristic data for each switch.
[0092] Specifically, the calibration measurement for each axis is performed according to the following procedure: First, a no-press state detection is performed, the output voltage V_idle of the axis's Hall element is collected, and compared with the factory reference value V_idle_ref to calculate the static offset ΔV1 = V_idle - V_idle_ref; then, the main control outputs a control signal to drive the miniature calibration electromagnet inside the magnetic axis to generate a gradient magnetic field, simulating the displacement of the magnet during button pressing, with the stroke starting from 0.5mm and gradually increasing to 4.0mm in 0.1mm increments; during this process, the system collects the Hall element voltage changes in real time, recording the actual voltage V_on_act and corresponding stroke S_on_act when the conduction condition is first reached (voltage ≥ V_on_ref), and the actual voltage V_off_act and corresponding stroke S_off_act when the de-conduction condition is first reached (voltage ≤ V_off_ref).
[0093] The system samples each switch 100 times to obtain data such as V_on_act, V_off_act, S_on_act, and S_off_act. Outliers (data exceeding the mean ± 3 standard deviations) are removed using the "3σ principle." The remaining data are then averaged to obtain the feature data for that switch. This feature data is used in subsequent threshold correction calculations to ensure consistent button response for each switch.
[0094] As an optional embodiment, in calibration mode, the step of calibrating and measuring the keyboard switches point by point according to a preset scanning order to generate characteristic data for each switch may further include the following steps:
[0095] Step 301: Based on the physical layout of the magnetic axis keyboard, the switches are divided into multiple calibration units. Each calibration unit contains a preset number of adjacent switches, and the magnetic field coupling between adjacent switches meets the preset threshold requirements.
[0096] Specifically, the system divides the switches into multiple calibration units based on the physical layout of the magnetic axis keyboard. The system first obtains the physical coordinates of each switch from the keyboard PCB layout diagram and calculates the magnetic field coupling coefficient based on the physical distance between the switches. When the distance between two switches is less than a preset distance threshold (e.g., 20mm), the system calculates their magnetic field coupling degree, which can be quantified using the measured output value of a differential Hall sensor. For example, when switch A is pressed, the system measures the change in output voltage ΔVB of the Hall sensor at the adjacent switch B position, while simultaneously recording the standard output voltage V0 of the Hall sensor when switch B itself is pressed. The coupling coefficient can be expressed as: K = |ΔVB / V0|. When K is greater than the threshold (e.g., 0.05), it indicates a strong magnetic field coupling between the two switches, and they should be assigned to the same calibration unit.
[0097] In some embodiments, the following rules can be followed: the keyboard is divided into a main key area, a numeric keypad area, and a function key area. Special locations are handled as follows: for switches on the keyboard edge, if their coupling coefficient with an adjacent calibration unit is greater than a threshold, they are added to that calibration unit; for multiple switches under irregularly shaped keys such as the spacebar, they are divided into independent calibration units to avoid interference with other units. Through this division method based on magnetic field coupling, the system can ensure that the switches within each calibration unit are accurately calibrated, while reducing mutual interference between adjacent switches during the calibration process.
[0098] Please see Figure 2This diagram illustrates the calibration unit division of a magnetic axis keyboard according to an embodiment of this application. The main key area is divided into two matrix units (main key area unit 1 and main key area unit 2) to ensure calibration accuracy in the most frequently used areas. The top function area is divided into top function area 1 (ESC to 5 keys) and top function area 2 (6 keys to Backspace). Keys with special sizes or functions (such as Enter, Right Shift, Spacebar, etc.) are set as independent calibration units. The left-side modifier key area, left-side edge key area, and right-side function bar each form independent calibration zones. This division scheme ensures calibration accuracy while also considering the convenience of actual production operations. Through reasonable unit division, it effectively controls the coupling effect between adjacent magnetic axes, providing a reliable technical solution for mass production calibration of magnetic axis keyboards.
[0099] Step 302: Select the reference shaft in each calibration unit, collect the output voltage of the Hall element to obtain the static voltage value when the reference shaft is not pressed, and compare it with the preset factory reference voltage value to calculate the static offset.
[0100] Specifically, in each calibration unit, the system selects the shaft at the middle position of the unit as the reference shaft. When detecting the reference shaft in a no-press state, the main control MCU acquires the output voltage of the Hall element of that shaft to obtain the static voltage value V_idle. The system compares this static voltage value with the factory reference voltage value V_idle_ref stored in Flash, and calculates the static offset ΔV1 = V_idle - V_idle_ref. This static offset reflects the actual voltage offset of the reference shaft in a no-press state, providing a basic reference value for subsequent magnetic field interference compensation.
[0101] Step 303: Combine the static offset and perform standard displacement simulation through the miniature calibration electromagnet in the magnetic shaft of the driving reference shaft to establish the magnetic field interference compensation coefficient between shafts in each calibration unit.
[0102] In this magnetic axis keyboard, Hall effect sensors detect changes in magnetic field strength, and their output voltage reflects the magnetic field strength at the current location. When the reference axis moves, the magnetic field generated by the miniature calibration electromagnet within the magnetic axis affects the output voltage of the Hall effect sensors on surrounding axes. The miniature calibration electromagnet is directly integrated into the central axis of the magnetic axis. The system outputs control signals from the main MCU to drive the miniature calibration electromagnet within the magnetic axis to generate a gradient magnetic field, simulating the key press process. The system uses PWM to drive the electromagnet via an H-bridge circuit, precisely controlling the magnetic field strength by changing the PWM duty cycle to simulate the magnetic axis displacement. During the simulated trigger detection process, the system controls the displacement generated by the electromagnet to gradually increase from 0.5mm to 4.0mm, with a step size of 0.1mm, and maintains each displacement point for 50ms to ensure stable sampling.
[0103] Specifically, the system needs to accurately model the magnetic field interference within each calibration unit. First, based on the obtained static offset ΔV1, the system determines the initial state of the reference axis. Then, the main control MCU outputs a PWM control signal (1kHz frequency, adjustable duty cycle) to drive the miniature calibration electromagnet of the reference axis, simulating the standard pressing displacement process. The specific simulation process adopts a fine segmentation strategy: a step size of 0.1mm in the 0-2.0mm range (before triggering), a step size of 0.05mm in the 2.0-2.5mm range (triggering area), and a step size of 0.1mm in the 2.5-4.0mm range (after triggering), ensuring higher precision sampling data in the critical displacement range.
[0104] At each displacement sampling point, the following data are acquired: the Hall element output voltage Vb(s) of the reference shaft at displacement s; the initial static voltage value Vi of the reference shaft; the voltage change of the reference shaft at displacement s ΔV(s) = Vb(s) - Vi; based on the sampling data, the voltage change rate of the reference shaft at displacement s is calculated as: F(s) = ΔV(s) / Vi. Since the magnetic field strength decreases with distance and is affected by displacement, the system establishes the following compensation model: For a shaft at any position, the magnetic field interference compensation coefficient at displacement point s is: K(d,s) = β × [e^(-λd) × (1 + μF(s))] × [1 - e^(-γs)] × cos(θ), where K(d,s) is the compensation coefficient, representing the degree of relative influence on the shaft at a distance d at displacement s; β is the reference calibration coefficient, determined by the initial calibration state (default value 1.0); λ is the distance attenuation factor, reflecting the attenuation characteristics of the magnetic field strength with distance (preferably 0.5 / mm); μ is the displacement coupling coefficient, characterizing the modulation effect of displacement on the magnetic field strength (preferably 0.1 / mm²); γ is the displacement response coefficient, controlling the effective rate of the compensation strength with displacement (preferably 2.0 / mm); θ is the orientation angle of the shaft relative to the reference shaft, used to distinguish the influence of the horizontal and vertical directions; and e is the base of the natural logarithm. By using this compensation model that takes into account distance attenuation, displacement modulation, and directionality, the system can accurately describe the influence of the reference shaft on the magnetic field of the surrounding shaft under different displacement states, providing a precise compensation basis for subsequent calibration measurements.
[0105] Step 304: Based on the magnetic field interference compensation coefficient, perform calibration measurements on each axis in each calibration unit in sequence to generate characteristic data of each axis in each calibration unit.
[0106] Specifically, the system selects the shaft at the middle position of each calibration unit as the reference shaft and adopts a "near-to-far" calibration sequence, that is, calibrating the shafts closer to the reference shaft first, prioritizing the calibration measurements of adjacent shafts in the horizontal direction before calibrating the shafts in the vertical direction. For each shaft under test, the system performs 10 repeated sampling measurements, recording the characteristic voltage V1 and corresponding stroke value L1 when the shaft is pressed from the initial static state to the conduction condition, and the characteristic voltage V2 and corresponding stroke value L2 when it is released from the conduction position to the de-conduction condition. For the obtained sampling data, the system uses the "3σ" rule to remove outliers. Then, the system combines the distance and direction relationship between the shaft and the reference shaft, and applies a magnetic field interference compensation coefficient to compensate for the remaining valid data, finally generating characteristic data representing the conduction and de-conduction characteristics of the shaft. Through this sequential calibration method based on the compensation model, the system can effectively eliminate the influence of magnetic field interference, accurately obtain the characteristic data of each shaft, and provide a reliable reference benchmark for subsequent real-time detection.
[0107] As an optional embodiment, the step of sequentially calibrating and measuring each axis within each calibration unit based on the magnetic field interference compensation coefficient to generate characteristic data for each axis within each calibration unit may further include the following steps:
[0108] Step 3041: Perform a preset number of sampling measurements on each shaft in each calibration unit, record the first characteristic voltage and corresponding first stroke data when each shaft reaches the conduction condition from the static position, and the second characteristic voltage and corresponding second stroke data when it first reaches the disconnection condition from the conduction position.
[0109] Specifically, the system performs 100 sampling measurements on the shaft within each calibration unit. The system drives a miniature calibration electromagnet via a control signal output from the main control MCU, causing the shaft to gradually increase its displacement in 0.1mm increments from a static position. During this process, the system records the first characteristic voltage V_on_act and the corresponding first stroke data S_on_act when each shaft first reaches the conduction condition (voltage ≥ V_on_ref). When the shaft reaches the fully pressed state, the system controls the miniature calibration electromagnet to gradually release, recording the second characteristic voltage V_off_act and the corresponding second stroke data S_off_act when the first disengagement condition (voltage ≤ V_off_ref) is reached. Through this precise sampling measurement, complete shaft motion characteristic data can be obtained.
[0110] Step 3042: Use preset statistical rules to remove outliers that exceed the preset range from all sampled first characteristic voltage, first stroke data, second characteristic voltage and second stroke data.
[0111] Specifically, after obtaining 100 sampling data points, the system employs the "3σ principle" to remove outliers from the collected data. The system calculates the average value μ1 and standard deviation σ1 of the first characteristic voltage V_on_act, the average value μ2 and standard deviation σ2 of the first travel data S_on_act, the average value μ3 and standard deviation σ3 of the second characteristic voltage V_off_act, and the average value μ4 and standard deviation σ4 of the second travel data S_off_act. For each data set, the system removes outliers exceeding the range [μ-3σ, μ+3σ]. For example, for the first characteristic voltage, if a sampled value exceeds the range [μ1-3σ1, μ1+3σ1], all data from that sample (including the corresponding travel data) are marked as outliers and removed. This outlier removal method based on statistical rules effectively improves data reliability.
[0112] Step 3043: The first characteristic voltage, first stroke data, second characteristic voltage and second stroke data after removing outliers are compensated based on the magnetic field interference compensation coefficient to generate characteristic data representing the conduction and disconnection state of the shaft.
[0113] Specifically, the system performs compensation processing on the valid sampled data after removing outliers, based on the established magnetic field interference compensation coefficient, to generate characteristic data representing the conduction and disconnection states of the shaft. The system first determines two parameters based on the spatial relationship between the shaft under test and the reference shaft: distance d (in units of shaft spacing) and direction angle θ (0° horizontally and 90° vertically). For each set of valid sampled data, at the first stroke data S corresponding to the first characteristic voltage V_on_act, the influence of the magnetic field generated by the reference shaft at that displacement point on the Hall element output is obtained: voltage change ΔV(S) = Vb(S) - Vi, relative change rate F(S) = ΔV(S) / Vi, used to characterize the magnetic field interference intensity at that displacement point. Then, the magnetic field interference compensation coefficient at that displacement point is calculated using the formula K(d,S) = β × [e^(-λd) × (1 + μF(S))] × [1 - e^(-γS)] × cos(θ). Substituting the calculated compensation coefficient into the formula V_on_comp = V_on_act - K(d,S) × Vi, we obtain the first characteristic voltage after eliminating the influence of magnetic field interference. Using the same method, we calculate the magnetic field interference compensation coefficient at the second stroke data S corresponding to the second characteristic voltage V_off_act, and perform compensation: V_off_comp = V_off_act - K(d,S) × Vi. After compensating all valid data, we calculate the average value of the compensated characteristic voltage as the characteristic data of the shaft.
[0114] Step 40: Perform threshold correction calculations on the feature data of each axis to obtain the calibration parameters of each axis.
[0115] Specifically, the system first calculates the conduction threshold offset and the disconnection threshold offset based on the first and second characteristic voltages in the characteristic data of each shaft. For shafts where the absolute value of the conduction threshold offset does not exceed 100mV and the absolute value of the disconnection threshold offset does not exceed 80mV, the system directly uses the sum of its reference conduction threshold (e.g., 2.5V) and the conduction threshold offset as the conduction threshold correction value, and the sum of its reference disconnection threshold (e.g., 2.0V) and the disconnection threshold offset as the disconnection threshold correction value. For shafts where the absolute value of the conduction threshold offset exceeds 100mV or the absolute value of the disconnection threshold offset exceeds 80mV, the system corrects the offset by combining the first and second stroke data of the shaft: if the first stroke data exceeds the preset range (2.0-2.5mm), the conduction threshold offset is adjusted proportionally; if the second stroke data exceeds the preset range (1.5-2.0mm), the disconnection threshold offset is adjusted proportionally, ensuring that the final conduction threshold correction value and disconnection threshold correction value maintain a voltage difference of 0.3-0.6V. The system uses the calculated conduction threshold correction values and disconnection threshold correction values for each axis as calibration parameters, storing them in Flash memory for threshold determination during subsequent real-time detection. Through this correction calculation method that considers offset and travel data, the system can ensure that each axis has appropriate and consistent triggering characteristics during actual use.
[0116] As an optional embodiment, the step of calculating threshold corrections for the feature data of each axis to obtain the calibration parameters for each axis may further include the following steps:
[0117] Step 401: Based on the first characteristic voltage and the second characteristic voltage in the characteristic data of each axis, calculate the conduction threshold offset and the disconnection threshold offset of each axis.
[0118] Specifically, the compensated first characteristic voltage V_on of each axis is compared with a preset reference turn-on threshold (2.5V) to obtain the turn-on threshold offset ΔV_on = V_on - 2.5V for that axis; the compensated second characteristic voltage V_off is compared with a preset reference turn-off threshold (2.0V) to obtain the turn-off threshold offset ΔV_off = V_off - 2.0V for that axis. By calculating these offsets, the system can quantitatively evaluate the degree of deviation between the characteristic voltage of each axis and the standard threshold, providing basic data for subsequent threshold correction.
[0119] Step 402: When there is a first shaft with an absolute value of conduction threshold offset less than or equal to the first offset threshold, and / or when there is a first shaft with an absolute value of disconnection threshold offset less than or equal to the second offset threshold, the sum of the preset reference conduction threshold and the conduction threshold offset corresponding to the first shaft is used as the conduction threshold correction value, and / or the sum of the preset reference disconnection threshold and the disconnection threshold offset corresponding to the first shaft is used as the disconnection threshold correction value.
[0120] Specifically, the system determines whether the on-threshold offset and off-threshold offset of each axis are within preset ranges. For first axes whose absolute on-threshold offset is less than or equal to the first offset threshold (100mV) and / or whose absolute off-threshold offset is less than or equal to the second offset threshold (80mV), for each first axis, the system directly uses the algebraic sum of its reference on-threshold (2.5V) and the on-threshold offset as the on-threshold correction value for that first axis, and the algebraic sum of its reference off-threshold (2.0V) and the off-threshold offset as the off-threshold correction value for that first axis. Since the characteristic voltage deviations of these axes are small, threshold correction can be achieved through simple offset compensation, ensuring that the corrected triggering characteristics meet the requirements.
[0121] Step 403: When there is a second shaft with an absolute value of conduction threshold offset greater than the first offset threshold, and / or when there is a second shaft with an absolute value of disconnection threshold offset greater than the second offset threshold, the conduction threshold offset and / or disconnection threshold offset are corrected based on the first stroke data and / or the second stroke data corresponding to the second shaft to obtain the conduction threshold correction value and / or disconnection threshold correction value of the second shaft; wherein, the disconnection threshold correction value of each shaft is less than the corresponding conduction threshold correction value and remains within the preset voltage difference range.
[0122] Specifically, the system performs special processing on second axes where the absolute value of the conduction threshold offset is greater than the first offset threshold (100mV) and / or the absolute value of the disconnection threshold offset is greater than the second offset threshold (80mV). For cases categorized as second shafts, the system performs correction calculations based on their first and second stroke data: When the first stroke data S_on exceeds the preset range (2.0-2.5mm), the system calculates the stroke deviation rate a = (S_on - 2.25) / 0.25, where 2.25mm is the center value of the preset range and 0.25mm is half the width of the preset range. The system then corrects the conduction threshold offset based on this deviation rate: ΔV_on_modified = ΔV_on × (1 - a). When the second stroke data S_off exceeds the preset range (1.5-2.0mm), the system calculates the stroke deviation rate b = (S_off - 1.75) / 0.25, and corrects the disconnection threshold offset: ΔV_off_modified = ΔV_off × (1 - b). The system then adds the corrected offset to the reference conduction threshold and the reference disconnection threshold, respectively, to obtain the preliminary threshold correction value. If the calculated disconnect threshold correction value is greater than or equal to the conduction threshold correction value, or if the difference between the two is not within the preset range (0.3-0.6V), the system will adjust the two threshold correction values proportionally according to a standard deviation of 0.45V to ensure that the final disconnect threshold correction value is less than the conduction threshold correction value and that the difference between the two is within a reasonable range. Through this proportional correction method based on travel data, the system can obtain a suitable trigger threshold for shafts with large characteristic deviations.
[0123] Step 404: Use the conduction threshold correction value and / or disconnection threshold correction value of each axis as calibration parameters.
[0124] Specifically, due to inevitable differences in the production and installation processes of each switch, their triggering characteristics will also vary. Therefore, it is necessary to set personalized trigger thresholds for each switch. The on-threshold correction value is used to accurately determine the switch's press action, and the off-threshold correction value is used to accurately determine the switch's release action. The settings of these two thresholds directly affect the user experience of the switch. The system writes these two correction values into the parameter storage area of the corresponding switch in the Flash memory. During subsequent real-time detection, the switch's status is determined by comparing the switch's real-time voltage value with these two correction values.
[0125] Step 50: Verify and store the calibration parameters in layers, and control the magnetic axis keyboard master controller to switch to the calibrated working mode.
[0126] Specifically, the system first generates a 16-bit CRC checksum for the calibration parameters (including conduction threshold correction and disconnection threshold correction) of each axis. Then, it stores the data hierarchically according to their importance: the raw data of the calibration parameters is stored in the first area of the Flash memory, the CRC checksum is stored in the second area, and a parameter backup area is established in the EEPROM to store a complete copy of the calibration parameters. The system performs a CRC check every time the calibration parameters are read, and can recover the parameters from the EEPROM if an anomaly is detected. After the parameters are stored, the system switches the main control MCU from calibration mode to normal operation mode by setting its operating mode register, putting the magnetic axis keyboard into real-time detection mode. This parameter storage scheme with verification and backup mechanisms ensures the reliability and durability of the calibration parameters.
[0127] As another optional embodiment, the step of verifying and storing the calibration parameters in layers, and controlling the magnetic axis keyboard master controller to switch to the calibrated working mode, may also include the following steps:
[0128] Step 501: Perform integrity verification on the calibration parameters of each shaft.
[0129] Specifically, for each axis's calibrated parameter set, including the conduction threshold correction value, disconnection threshold correction value, static offset, and conduction displacement deviation, the system first organizes these parameters into a data stream in a fixed order, and then calculates the checksum using the CRC32 polynomial generation algorithm. The system packages the calculated 32-bit CRC checksum along with the parameter packet to form a complete calibration data packet. If data anomalies are detected during the verification process (such as a parameter exceeding a reasonable range, CRC check failure, etc.), the system will mark the axis as abnormal and trigger the regeneration process of the axis's calibration parameters. Through this rigorous data integrity verification mechanism, it can be ensured that the calibration parameters of each axis are valid and reliable.
[0130] Step 502: Store the verified calibration parameters in layers according to temporary storage and persistent storage. The temporary storage writes the verified calibration parameters to the main controller's random storage area for real-time key response after calibration. The persistent storage writes the verified calibration parameters to the keyboard flash calibration area and supports storing the calibration results of the most recent preset number of times for data loading and abnormal recovery on the next boot.
[0131] Specifically, the system stores verified calibration parameters in a hierarchical manner, using temporary and persistent storage. For temporary storage, the system writes the calibration parameters to a designated area in the main control MCU's RAM. This area is divided into storage units according to the axis matrix arrangement, with each axis occupying 16 bytes of space, including 4 bytes for the on-threshold correction value, 4 bytes for the off-threshold correction value, 4 bytes for the static offset, 2 bytes for the on-displacement deviation, and 2 bytes for the status flag. For persistent storage, the system establishes a circular storage structure in the "calibration parameter area" of the keyboard Flash. This area has a total capacity of 64KB and is divided into 5 sub-blocks. Each sub-block contains a complete set of calibration data (including calibration timestamp, axis number, calibration parameters, and CRC checksum). When new calibration data is written, the system updates the circular pointer to ensure that the most recent 5 calibration records are retained. This hierarchical storage strategy not only achieves fast access and persistent storage but also provides parameter version management capabilities.
[0132] Step 503: Based on the calibration parameters in the random access memory, control the magnetic axis keyboard main controller to switch to the calibrated working mode, including turning off calibration-related function modules, judging key triggers according to the verified calibration parameters, and automatically switching to normal standby mode when no operation is detected within a preset time.
[0133] Specifically, after calibration, the system first switches the main control MCU to "post-calibration working mode" by configuring its working mode register (WMODE, address 0x40), while simultaneously disabling the ADC continuous sampling channel, PWM output, and timer modules used during calibration. The system loads the on-threshold correction values and off-threshold correction values w for each axis from RAM into the corresponding hardware comparator threshold registers, enabling real-time key status judgment based on these calibrated thresholds. When an abnormal axis response is detected (e.g., three consecutive abnormal trigger times or no response within 10 minutes), the system provides two recovery mechanisms: resetting the parameters to factory default values via the driver software's "Restore Factory Parameters" command, or loading the most recent normal calibration record from Flash via the "Restore Last Calibration Parameters" command. During the recovery operation, the system re-verifies the parameters to ensure their validity and usability. Simultaneously, a 60-second idle detection timer is started. When no key operation is detected for more than 60 seconds, the main control MCU is automatically switched to normal standby mode (setting the WMODE register to 0x01) to further reduce system power consumption. With this sophisticated mode switching and parameter recovery mechanism, the system can achieve reliable and low-power operation while ensuring detection accuracy.
[0134] As an optional implementation, after storing the calibration parameters, the system can also perform a process to restore standby mode. Specifically, the system first switches modes: disabling calibration-related functional modules, including the magnetic field detection function of the miniature calibration electromagnet and the magnetic field detection function of the auxiliary Hall sensor, while restoring the RGB indicator lights to the user-defined state before calibration and reducing the wireless transmission power to normal levels. The system monitors the keyboard's operation status; when no keystrokes are detected within 30 seconds, it automatically reduces the scanning frequency to 10Hz and enters normal standby mode to reduce power consumption. Simultaneously, the system logs the calibration process. Specifically, the system records the calibration timestamp, the number of switches involved in calibration, and the number of switches successfully calibrated in the "calibration log area" of the Flash memory. For abnormal switches with an offset greater than 0.2V, the system records their switch number and calculates the average ambient magnetic field value for subsequent analysis. This log area uses a cyclic overwrite mechanism, retaining a maximum of the 30 most recent records. If the system detects abnormal switch misalignment during calibration, the system will automatically display a prompt message the next time the user connects the driver software: "Some switches have a large misalignment. It is recommended to check whether the keyboard has physical damage or environmental magnetic field interference." This helps users to identify and resolve potential problems in a timely manner.
[0135] This application also provides a computer storage medium that can store multiple instructions. The instructions are adapted to be loaded and executed by a processor to provide an automatic calibration method for magnetic keyboard switches according to the above embodiments. For the specific execution process, please refer to the detailed description of the above embodiments, which will not be repeated here.
[0136] The following describes an electronic device for automatic calibration of magnetic keyboard switches provided by an embodiment of this application. Figure 3 This is a schematic diagram of an exemplary hardware structure of an electronic device provided in an embodiment of this application.
[0137] In some embodiments, the electronic device for automatic calibration of magnetic keyboard switches is a computer device or includes a computer device in the electronic device for automatic calibration of magnetic keyboard switches. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device stores data. The network interface of the computer device is used to communicate with other external terminals or servers via a network connection. In some embodiments, the network interface can be a wired network interface; in some embodiments, the network interface can also be a wireless network interface. When the computer program is executed by the processor, it implements the methods in the embodiments of this application.
[0138] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0139] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0140] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0141] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for automatically calibrating magnetic axis keyboard switches, characterized in that, The method includes: Acquire the working status information of the magnetic axis keyboard, and determine the keyboard calibration time window based on the working status information. The working status information includes key status data and auxiliary behavior data. During the keyboard calibration time window, ambient magnetic field parameters and keyboard operating parameters are collected, and the calibration mode is determined based on the ambient magnetic field parameters and the keyboard operating parameters. In the calibration mode, the keyboard switches are calibrated and measured point by point according to a preset scanning sequence to generate characteristic data of each switch. Threshold correction calculations are performed on the feature data of each shaft to obtain the calibration parameters of each shaft. The calibration parameters are verified and stored hierarchically, and the magnetic axis keyboard master controller is switched to the calibrated working mode. In the calibration mode, the keyboard switches are calibrated point by point according to a preset scanning order to generate characteristic data for each switch, including: Based on the physical layout of the magnetic axis keyboard, the switches are divided into multiple calibration units, each calibration unit contains a preset number of adjacent switches, and the magnetic field coupling between the adjacent switches meets a preset threshold requirement. Select a reference shaft in each calibration unit, and collect the output voltage of the Hall element to obtain the static voltage value when the reference shaft is not pressed. Compare the static offset value with the preset factory reference voltage value. By combining the static offset and performing standard displacement simulation using a miniature calibration electromagnet within the magnetic shaft driving the reference shaft, a magnetic field interference compensation coefficient between shafts in each calibration unit is established. Based on the magnetic field interference compensation coefficient, each axis in each calibration unit is calibrated and measured sequentially to generate characteristic data of each axis in each calibration unit.
2. The automatic calibration method for magnetic axis keyboard switches according to claim 1, characterized in that, The calibration measurement is performed sequentially on each axis within each calibration unit based on the magnetic field interference compensation coefficient, generating characteristic data for each axis within each calibration unit, including: Each shaft in each calibration unit is sampled and measured a preset number of times in sequence. The first characteristic voltage and the corresponding first stroke data when each shaft reaches the conduction condition from the static position are recorded, as well as the second characteristic voltage and the corresponding second stroke data when it first reaches the de-conduction condition from the conduction position. For all sampled first characteristic voltage, first stroke data, second characteristic voltage and second stroke data, outliers exceeding the preset range are removed using preset statistical rules; The first characteristic voltage, first stroke data, second characteristic voltage, and second stroke data after removing outliers are compensated based on the magnetic field interference compensation coefficient to generate characteristic data representing the conduction and disconnection states of the shaft.
3. The automatic calibration method for magnetic axis keyboard switches according to claim 2, characterized in that, The step of performing threshold correction calculations on the feature data of each shaft to obtain the calibration parameters of each shaft includes: Based on the first and second characteristic voltages in the characteristic data of each axis, calculate the conduction threshold offset and disconnection threshold offset of each axis; When there is a first shaft with an absolute value of the conduction threshold offset less than or equal to the first offset threshold, and / or when there is a first shaft with an absolute value of the disconnection threshold offset less than or equal to the second offset threshold, the sum of the preset reference conduction threshold and the conduction threshold offset corresponding to the first shaft is used as the conduction threshold correction value, and / or the sum of the preset reference disconnection threshold and the disconnection threshold offset corresponding to the first shaft is used as the disconnection threshold correction value. When there is a second shaft whose absolute value of the conduction threshold offset is greater than the first offset threshold, and / or when there is a second shaft whose absolute value of the disconnection threshold offset is greater than the second offset threshold, the conduction threshold offset and / or disconnection threshold offset are corrected based on the first stroke data and / or the second stroke data corresponding to the second shaft to obtain the conduction threshold correction value and / or disconnection threshold correction value of the second shaft; wherein, the disconnection threshold correction value of each shaft is less than the corresponding conduction threshold correction value and remains within a preset voltage difference range; The conduction threshold correction value and / or disconnection threshold correction value of each shaft are used as calibration parameters.
4. The automatic calibration method for magnetic axis keyboard switches according to claim 1, characterized in that, The step of performing data verification and hierarchical storage of the calibration parameters, and controlling the magnetic axis keyboard main controller to switch to the calibrated working mode includes: Perform integrity verification on the calibration parameters of each shaft; The calibration parameters after verification are stored in a hierarchical manner, divided into temporary storage and persistent storage. The temporary storage writes the verified calibration parameters into the main controller's random storage area for real-time key response after calibration; the persistent storage writes the verified calibration parameters into the keyboard flash calibration area and supports storing the calibration results of the most recent preset number of times for loading data on the next boot and for abnormal recovery. Based on the calibration parameters in the random storage area, the magnetic axis keyboard master controller switches to the calibrated working mode, including turning off calibration-related function modules, judging key triggers according to the verified calibration parameters, and automatically switching to normal standby mode when no operation is detected within a preset time.
5. The automatic calibration method for magnetic axis keyboard switches according to claim 1, characterized in that, Determining the keyboard calibration time window based on the working status information includes: Acquire key status data and axis signals within a preset time period, and calculate the time interval between two adjacent key presses in the key status data; The system determines whether the time interval continuously exceeds a first preset duration, whether the trend of the time interval meets a preset growth condition, and whether the signals of each axis are abnormal. The first preset duration is determined by the user's historical behavior data. When the time interval continuously exceeds the first preset duration, the change trend meets the preset growth condition, and there is no abnormality in any axis signal, it is determined whether the auxiliary behavior data all meet the corresponding preset calibration conditions. The auxiliary behavior data includes at least the lighting effect status, communication status, and power status of the magnetic axis keyboard. When all the auxiliary behavior data meet the corresponding preset calibration conditions, the preset time period after the current time is determined as the keyboard calibration time window.
6. The automatic calibration method for magnetic axis keyboard switches according to claim 1, characterized in that, The process of acquiring ambient magnetic field parameters and keyboard operating parameters within the keyboard calibration time window, and determining the calibration mode based on the ambient magnetic field parameters and keyboard operating parameters, includes: Within the keyboard calibration time window, keyboard operating parameters are acquired, and multiple sets of ambient magnetic field strength data are obtained by multi-stage sampling through the auxiliary Hall sensor on the main control board of the magnetic axis keyboard. The auxiliary Hall sensor is in a sleep state in non-calibration mode. The multiple sets of environmental magnetic field strength data are filtered, and the average environmental magnetic field strength after filtering is determined. The voltage ripple characteristics of the power supply voltage are determined based on the keyboard operating parameters, and the voltage stability coefficient is determined based on the voltage ripple characteristics. When the average strength of the ambient magnetic field is less than a first magnetic field strength threshold and the voltage stability coefficient is less than a first voltage threshold, the first calibration mode is determined to be used. When the average strength of the ambient magnetic field is greater than or equal to the first magnetic field strength threshold and less than the second magnetic field strength threshold, and the voltage stability coefficient is greater than or equal to the first voltage threshold and less than the second voltage threshold, the second calibration mode is adopted, wherein both the first calibration mode and the second calibration mode are performed under preset low power calibration conditions. Otherwise, after a preset delay, the environmental magnetic field parameters and keyboard operation parameters will be collected again. If the number of retries exceeds the preset limit, it will be recorded in the error log.
7. An electronic device for automatic calibration of magnetic keyboard switches, characterized in that, The electronic device includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the electronic device to perform the method as described in any one of claims 1-6.
8. A computer program product containing instructions, characterized in that, When the computer program product is run on an electronic device that automatically calibrates magnetic keyboard switches, the electronic device performs the method as described in any one of claims 1-6.
9. A computer-readable storage medium comprising instructions, characterized in that, When the instruction is executed on an electronic device that automatically calibrates the magnetic key switch, the electronic device performs the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Measurement precision correction method for digital geological compass
CN121140750A
Information handling system and keyboard dual mode pairing
US20220361266A1