A matrix keyboard debugging method based on serial port instructions
Through the matrix keyboard debugging method based on serial port instructions, the predefined key mapping table and serial port instruction management mechanism are used to solve the problem of poor expansion of matrix keyboard debugging in the existing technology, and a more flexible and easy-to-use debugging process is achieved.
Patent Information
- Application Number
- CN202411159065.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-08-22
AI Technical Summary
The existing matrix keyboard debugging methods are poor in scalability and are difficult to adapt to matrix keyboards of different types and scales. The traditional debugging methods lack flexibility and automation capabilities, making it difficult to meet complex debugging needs.
The matrix keyboard debugging method based on serial port instructions is adopted, and the key value code is obtained through the predefined key mapping table, the key type is identified, and the debugging management mechanism of the serial port instructions is made controllable and customizable.
It improves the scalability and flexibility of matrix keyboard debugging, provides a more friendly human-computer interaction method, greatly improving the flexibility and ease of use of the debugging process.
Smart Images

Figure CN119046071B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of keyboard debugging, and in particular to a matrix keyboard debugging method based on serial port instructions. Background Art
[0002] With the widespread use of computers and electronic devices, keyboards, as an important input device for human-computer interaction, have become an indispensable part of people's daily work and life. Matrix keyboards have been widely used in various embedded devices, industrial control equipment, mobile terminals and other fields due to their simple structure, low cost and small size. However, with the increasing richness of keyboard functions and the continuous expansion of application scenarios, the traditional matrix keyboard debugging method has been unable to meet the growing development needs.
[0003] At present, the debugging of matrix keyboards is mainly based on the internal logic of the firmware or physical keys. In the firmware, the key scan code is fixedly mapped or complex conditional judgment is performed to identify the key type and perform the corresponding operation. This method has poor flexibility and scalability, and it is difficult to adapt to matrix keyboards of different types and sizes. It also increases the complexity of firmware development and maintenance. Another common debugging method is to reserve a physical debugging key or switch on the keyboard, and turn the debugging function on and off through manual operation. Although this method is simple and intuitive, it lacks flexibility and automation capabilities and is difficult to adapt to complex debugging needs.
[0004] In addition, in actual matrix keyboard applications, keyboard functions are constantly enriched. In addition to traditional numeric and alphanumeric keys, a large number of function keys, combination keys, multimedia keys, etc. have been introduced. Traditional debugging methods often treat combination keys as ordinary keys or simply superimpose key value codes, which is difficult to meet the needs of accurate recognition and flexible mapping of combination keys. At the same time, in response to the increasingly complex keyboard functions, traditional debugging information output methods, such as simple numerical printing or fixed format output, have poor readability and are difficult to meet the needs of problem location and automated testing. Summary of the invention
[0005] In view of the problem of poor scalability of matrix keyboard debugging in the prior art, the present application provides a matrix keyboard debugging method based on serial port instructions, which obtains the corresponding key value code through a predefined key mapping table, identifies the key type, and outputs the corresponding debugging information. At the same time, the debugging management mechanism based on serial port instructions makes the debugging process controllable and customizable, thereby improving the scalability.
[0006] The purpose of this application is achieved through the following technical solutions.
[0007] The present specification provides a matrix keyboard debugging method based on serial port instructions, including: S1, obtaining a scan code scan_code of a matrix keyboard, the scan code scan_code including the row pin number row and the column pin number col of a key pressed by a user; S2, judging the key type according to the obtained scan code scan_code: if the scan code scan_code is less than 0X80, it indicates that the corresponding key is an ordinary key, and the embedded controller EC outputs the corresponding ordinary key debugging information through the serial port; if the scan code scan_code is greater than or equal to 0X80, it indicates that the corresponding key is a special key, and step S3 is executed; S3, if the key is a special key, EC converts the obtained scan code scan_code into an index number index, accesses a predefined key mapping table through the index number index, obtains the corresponding key value code key_code, and determines the function or mapping of the special key; S4, according to the key value code key_code And key event event, determine the type of special key: If the key value code Key_Code is equal to the key value code FN_Code of the FN key, and the key event Event is the make code Make_Code, EC sets the FN pressed flag FN_Flag to 1, indicating that the FN key is in the pressed state, and obtains the key value code Other_Key_Code of other keys except the FN key: If the key value code Other_Key_Code of other keys is greater than 0xE0, and the FN pressed flag FN_Flag is 1, EC performs a bitwise AND operation on the key value code Other_Key_Code of other keys and 0xE0 to generate the index number Comb_Index of the FN combination key, and obtains the corresponding key value code Comb_Code of the FN combination key in the pre-defined key mapping table. EC outputs the FN combination key debugging information through the serial port. The debugging information contains the key value code Comb_Code of the FN combination key and the corresponding function. If the key code Key_Code is equal to the key code FN_Code of the FN key, and the key event Event is the break code Break_Code, EC sets the FN pressed flag FN_Flag to 0, indicating that the FN key is released, and EC outputs the debugging information of the FN key release through the serial port; if the key code Key_Code is not equal to the key code FN_Code of the FN key, EC obtains the FN key combination processing function corresponding to the key code key_code in the pre-defined key mapping table, executes the corresponding key combination function operation, and outputs the corresponding FN key combination debugging information through the serial port.
[0008] Preferably, S41, pre-define the key code FN_Code of the FN key, the judgment threshold Special_TH of the special key, the key mapping table Map_Table and the FN combination key processing function FN_Handler; scan the matrix keyboard to obtain the key code Key_Code and the key event Event of the currently pressed key; S43, determine whether the key code Key_Code is equal to the key code FN_Code of the FN key: if yes, execute step S44; if not, execute step S47; S44, determine whether the key event Event is a make code Make_Code: if yes, set the FN pressed flag FN_Flag is 1, indicating that the FN key is in a pressed state, and step S45 is executed; if not, the FN pressed flag bit FN_Flag is set to 0, indicating that the FN key is released, and step S46 is executed; S45, obtain the key code Other_Key_Code of other keys except the FN key: if the key code Other_Key_Code of other keys is greater than the judgment threshold Special_TH of the special key, and the FN pressed flag bit FN_Flag is 1, then the following sub-steps are executed: Through the table lookup function Table_Lookup, with the key code Other_Key_Code of other keys as the index, in the key mapping table Map_Tabl e to obtain the key value code Comb_Code of the corresponding FN key combination; perform a bitwise AND operation on the key value code Other_Key_Code of other keys and the preset mask Mask to generate the index number Comb_Index of the FN key combination; output the debugging information of the FN key combination through the debugging function Debug_Output, including the key value code Comb_Code, index number Comb_Index and corresponding function description Func_Desp of the FN key combination; return to step S42 and continue scanning the next key; S46, output the debugging information of the FN key release through the debugging function Debug_Output, and return to step S4 2; S47, in the key mapping table Map_Table, with the key value code Key_Code as the index, obtain the function pointer Func_Ptr of the corresponding FN combination key processing function FN_Handler: if the function pointer Func_Ptr is successfully obtained, the FN combination key processing function FN_Handler is called through the function pointer to perform the corresponding combination key function operation; if no valid function pointer is obtained, the default FN combination key processing function Default_Handler is called, and a prompt message is output; through the debugging function Debug_Output, the corresponding FN combination key debugging information is output, and return to step S42.
[0009] Among them, by pre-defining the key mapping table, the corresponding relationship between the key value code and the FN combination key code is established to improve the retrieval efficiency of the FN combination key; by introducing the special key judgment threshold, through the threshold judgment and bitwise AND operation, the special keys are quickly identified and the FN combination key index number is generated, which simplifies the judgment logic; by using the function pointer, the flexible call of the FN combination key processing function is realized, which improves the scalability and maintainability of the code; through the debugging function, the debugging information in a unified format is output, which is convenient for tracking and locating problems. S5, EC manages keyboard debugging by receiving serial port instructions.
[0010] Further, S5, EC manages keyboard debugging by receiving serial port instructions, including: when EC receives an instruction that matches a pre-defined keyboard debugging function opening instruction and the current instruction is not in execution state, EC turns on the keyboard debugging function and sets the keyboard debugging switch flag Debug_Flag to a pre-defined high level value, indicating that the keyboard debugging function is turned on; EC cyclically detects the keyboard debugging switch flag Debug_Flag by polling: when it is detected that the keyboard debugging switch flag Debug_Flag is set to a pre-defined high level value, obtains the scan code Scan_Code, key value code Key_Code, and FN combination key value code Comb_Code of the key, prints them through the serial port, and performs keyboard debugging; during the cyclic detection process, when EC receives an instruction that matches a pre-defined keyboard debugging function closing instruction, EC turns off the keyboard debugging function and sets the keyboard debugging switch flag Debug_Flag to a pre-defined low level value, indicating that the keyboard debugging function is turned off.
[0011] Preferably, S51, pre-defines a keyboard debugging function opening instruction Open_Cmd, a keyboard debugging function closing instruction Close_Cmd, a keyboard debugging switch flag Debug_Flag, and a debugging information format Fmt_Str: the keyboard debugging function opening instruction Open_Cmd and the closing instruction Close_Cmd are respectively preset specific character strings or control codes; the keyboard debugging switch flag Debug_Flag is a Boolean variable used to identify the current state of the keyboard debugging function; the debugging information format Fmt_Str is a character string template containing a number of placeholders, used to generate formatted debugging information; S52, EC receives the external input control command Ctrl_Cmd through the serial port; S53, determines whether the control command Ctrl_Cmd matches the keyboard debugging function opening command Open_Cmd: if they match, and the current keyboard debugging function is not turned on, execute step S54; if they do not match, execute step S55; S54, turn on the keyboard debugging function: set the keyboard debugging switch flag Debug_Flag to True, indicating that the keyboard debugging function is turned on; send a prompt message that the keyboard debugging function is successfully turned on through the serial port, and return to step S52; S55, determine whether the current keyboard debugging function is turned on, that is, determine whether the keyboard debugging function is turned on. Whether the debug switch flag Debug_Flag is True: if it is turned on, execute step S56; if it is not turned on, execute step S52; S56, obtain the currently pressed key information through the matrix keyboard scanning program, including: scan code Scan_Code, key value code Key_Code and FN combination key value code Comb_Code; S57, generate formatted debug information Debug_Info according to the debug information format Fmt_Str for the key information obtained in step S56: the debug information Debug_Info at least includes the scan code Scan_Code, the key value code Key _Code and FN combination key value code Comb_Code and other fields; S58, sending debugging information Debug_Info through the serial port; S59, judging whether the control instruction Ctrl_Cmd matches the keyboard debugging function closing instruction Close_Cmd: if they match, executing step S510; if they do not match, returning to step S56 and continuing to execute the keyboard debugging function; S510, turning off the keyboard debugging function: setting the keyboard debugging switch flag Debug_Flag to False, indicating that the keyboard debugging function has been turned off; sending a prompt message that the keyboard debugging function is successfully turned off through the serial port, and returning to step S52.
[0012] Furthermore, keyboard debugging is performed through serial port printing, including: combining the scan code Scan_Code, the key value code Key_Code and the FN combination key value code Comb_Code into a debugging information string according to a predefined format; and sending the debugging information string to the debugging keyboard through the serial port sending pin TX.
[0013] Furthermore, determining whether the current instruction is in an execution state includes: recording the execution state of each received serial port instruction, the execution state including the instruction identification code, execution start time and execution end time; when a new serial port instruction is received, querying the current instruction record, if the current instruction has no corresponding record or the execution has ended, determining that the current execution is in an unexecuted state.
[0014] Preferably, when a serial port instruction is received, an execution status record is created for the instruction, and the execution status record includes: a unique identification code of the instruction, which is used to identify different serial port instructions; the execution start time of the instruction, which records the time point when the instruction is received; the execution end time of the instruction, which is initialized to an invalid value. When a new serial port instruction is received, the current instruction record is queried: if the current instruction has no corresponding execution status record, the instruction is judged to be in an unexecuted state; if the current instruction has a corresponding execution status record, the execution end time of the record is compared: if the execution end time is an initial invalid value, the instruction is judged to be in an execution state; if the execution end time is a valid value, the instruction is judged to have been executed and is in an unexecuted state. After the execution of the instruction is completed, the execution end time of the corresponding execution status record is updated to the current time. By regularly cleaning up expired execution status records, it is ensured that the number of records will not grow indefinitely: traverse all execution status records to find records whose execution end time is earlier than a certain threshold of the current time; delete these expired records to reclaim storage space. Introduce a maximum number limit for execution status records to prevent memory overflow caused by too many records: define the maximum number threshold of execution status records; before creating a new execution status record, check whether the total number of current records reaches the threshold; if the threshold is reached, delete the earliest created execution status record and create a new record. For instructions that take too long to execute, introduce an execution timeout mechanism: define the maximum allowed time threshold for instruction execution; during instruction execution, periodically check whether the execution time of the instruction exceeds the threshold; if it exceeds the threshold, force the execution of the instruction to terminate and update the execution end time of the corresponding execution status record. By adopting the above serial port instruction execution status judgment method, the keyboard controller can effectively judge whether the current instruction is in the execution state, avoiding repeated execution or missed execution of instructions. At the same time, through the management and optimization of execution status records, the reliability and resource utilization efficiency of instruction execution status judgment are improved, and the stability and scalability of the keyboard controller are enhanced.
[0015] Further, S3, the step of converting the scan code scan_code into the index number index, includes: judging whether the highest bit of the scan code scan_code is 1: if the highest bit of the scan code scan_code is 1, clearing the highest bit of the scan code scan_code to zero to obtain the processed scan code processed_scan_code; if the highest bit of the scan code scan_code is 0, directly assigning the scan code scan_code to the processed scan code processed_scan_code; shifting the processed scan code processed_scan_code left by one bit to obtain the index number index; using the index number index as the address, searching for the corresponding key-value code Key_Code in a predefined key mapping table: if the key-value code Key_Code corresponding to the index number index is obtained in the key mapping table, passing the key-value code Key_Code to step S4; if the key-value code Key_Code corresponding to the index number index is not obtained in the key mapping table, passing the predefined invalid key-value code invalid_key_code to step S4.
[0016] Preferably, a key mapping table Key_Map, a mask value Mask and an invalid key value code Invalid_Key_Code are predefined: the key mapping table Key_Map uses the index number Index as the index to store the corresponding key value code Key_Code; the mask value Mask is used to extract the valid bits of the index number Index from the scan code Scan_Code; the invalid key value code Invalid_Key_Code indicates that the corresponding key value code is not found in the key mapping table Key_Map; the scan code Scan_Code of the current key is obtained; the scan code Scan_Code and the mask value Mask are bitwise ANDed to obtain a temporary scan code Temp_Scan_Code: Temp_Scan_Code=Scan_Code&Mask; it is determined whether the highest bit of the temporary scan code Temp_Scan_Code is 1: if the highest bit is 1, the temporary scan code Temp_Scan_Code is The highest bit of Code is cleared to 0 to obtain the processed scan code Processed_Scan_Code: Processed_Scan_Code = Temp_Scan_Code&(~Mask); if the highest bit is 0, the temporary scan code Temp_Scan_Code is directly assigned to the processed scan code Processed_Scan_Code, and the processed scan code Processed_Scan_Code is shifted right by one bit to obtain the index number Index: Index = Processed_Scan_Code>>1; in the key mapping table Key_Map, use the index number Index as the index to find the corresponding key-value code Key_Code: if the search is successful, the key-value code Key_Code is output as the result of the scan code conversion; if the search fails, the invalid key-value code Invalid_Key_Code is output as the result of the scan code conversion. By predefining the key mapping table, a mapping relationship between index numbers and key-value codes is established, avoiding the use of complex conditional judgment statements and improving the efficiency of key-value code search; mask operations are used to extract the low bits of the scan code and construct the valid bits of the index number, reducing unnecessary data bits and optimizing the way the index number is generated; invalid key-value codes are introduced to indicate the failure of table lookup, enhancing the fault tolerance and robustness of the program.
[0017] Furthermore, the predefined key mapping table includes: a special key table, an FN combination key key value table, and an FN combination key function table; the special key table uses the index number index as the address to store the key value code Key_Code corresponding to each special key. The FN combination key key value table uses the index number comb_index of the FN combination key as the address to store the combination key value code comb_code corresponding to each FN combination key: when the EC determines that the obtained key value code Key_Code is not equal to the key value code FN_code of the FN key, the index number comb_index of the FN combination key is obtained by performing a bitwise AND operation between the key value code Key_Code of the corresponding key and the predefined FN combination key start value FN_start; the EC uses the index number comb_index of the FN combination key as the address to search for the corresponding combination key value code comb_code in the FN combination key key value table.
[0018] Preferably, a special key mapping table is defined to store the mapping information of the special key: the mapping table uses the unique identifier of the special key as an index to store the corresponding key-value code; the unique identifier can be a number, a string or other value that can uniquely identify the special key; the key-value code represents the physical key code or virtual key code corresponding to the special key. The special key mapping table is stored in a rewritable non-volatile memory, such as EEPROM or Flash: when the keyboard controller is initialized, the mapping table is read from the non-volatile memory; during operation, if the mapping table changes, the change is written to the non-volatile memory; after power failure or restart, the keyboard controller automatically restores the mapping table from the non-volatile memory. A set of standard interface functions are provided for accessing and modifying the special key mapping table: a function for adding a special key mapping is defined, and the unique identifier and key-value code of the special key are passed in; a function for deleting a special key mapping is defined, and the unique identifier of the special key is passed in; a function for querying a special key mapping is defined, and the unique identifier of the special key is passed in, and the corresponding key-value code is returned; a function for modifying a special key mapping is defined, and the unique identifier of the special key and a new key-value code are passed in. In the key scanning and processing flow of the keyboard controller, a special key mapping table is used for key conversion: when a physical key is scanned, the special key mapping table is queried according to the scan code of the physical key; if the corresponding key value code is found in the mapping table, the physical key is converted to the corresponding special key; if the corresponding key value code is not found in the mapping table, it is processed according to the default key processing flow. By extending the special key mapping table, dynamic addition of new special keys is supported: sufficient space is reserved in the non-volatile memory for storing the extended special key mapping; an interface function for adding new special key mapping is provided, allowing new mapping relationships to be dynamically added at runtime; the newly added special key mapping takes effect immediately without restarting the keyboard controller. A version management mechanism for the special key mapping table is introduced to support the upgrade and rollback of the mapping table: the currently used mapping table version number is recorded in the non-volatile memory; an interface function for upgrading the mapping table is provided, and the new mapping table data and version number are passed in; during the upgrade process, the old version of the mapping table data is retained so that it can be rolled back when a problem occurs; an interface function for rolling back the mapping table is provided to restore the mapping table to the specified old version. By adopting the special key mapping method based on the mapping table, the keyboard controller can flexibly support the configuration and expansion of special keys. By storing the mapping table in a non-volatile memory, the keyboard controller can automatically restore the special key mapping after power failure or restart. At the same time, standard interface functions are provided to facilitate the access and modification of special key mappings. Dynamic addition of new special key mappings is supported to meet the scalability requirements of the keyboard controller. The introduction of a version management mechanism for the mapping table improves the maintainability and stability of the keyboard controller.
[0019] Furthermore, the FN combination key function table uses the combination key value code comb_code as the address to store the entry address of the FN combination key processing function corresponding to each combination key value code comb_code: when EC finds the combination key value code comb_code corresponding to the index number comb_index in the FN combination key key value table, it uses the combination key value code comb_code as the address to obtain the entry address of the corresponding FN combination key processing function in the FN combination key function table.
[0020] Preferably, in step a, a FN combination key value table and a FN combination key function table are predefined: the FN combination key value table uses the index number Comb_Index of the FN combination key as an index to store the corresponding FN combination key key value code Comb_Code; the FN combination key function table uses the FN combination key value code Comb_Code as an index to store the entry address Func_Addr of the corresponding FN combination key processing function; in step b, when the EC detects that the FN key and other keys are pressed simultaneously, the following steps are performed: the scan code Scan_Code and the key value code Key_Code of the other keys are obtained; the index number Comb_Index of the FN combination key is generated by a hash function Hash with the scan code Scan_Code and the key value code Key_Code as input; in step c, the corresponding FN combination key key value code Comb_Code is searched in the FN combination key value table with the index number Comb_Index as an index; if the search is successful, the step is performed; otherwise, step d is performed. Execute step e; step d, in the FN combination key function table, use the FN combination key key value code Comb_Code as an index to obtain the entry address Func_Addr of the corresponding FN combination key processing function: jump to the entry address Func_Addr through the function pointer, and execute the corresponding FN combination key processing function; in the FN combination key processing function, according to the value of the FN combination key key value code Comb_Code, execute the corresponding combination key function operation, including: multimedia control, system control, application control, etc.; after execution, return to step f; step e, call the default FN combination key processing function Default_Handler: in the default FN combination key processing function Default_Handler, according to the pre-defined strategy, execute the corresponding default operation, such as: output error prompt information, ignore the combination key, etc.; after execution, return to step f; step f, clear the pressed state of the FN key, return to step b, and wait for the next pressing of the FN combination key. Among them, by pre-defining the FN combination key value table and function table, a mapping relationship between the FN combination key index number, key value code and processing function is established, which improves the efficiency of searching and calling the combination key; a hash function is introduced to map the scan code and key value code of the key to the index number of the FN combination key, avoiding the use of complex conditional judgment statements and simplifying the recognition logic of the combination key; a function pointer is used to realize the flexible calling of the FN combination key processing function, which improves the scalability and reusability of the code; through the default FN combination key processing function, it is compatible with undefined FN combination keys, enhancing the fault tolerance and robustness of the code.
[0021] Furthermore, the FN combination keys include Fn+F1 to Fn+F12, which are used to realize specific functions such as multimedia control and system control; Fn+Insert and Fn+Delete are mapped to screenshot function and calculator function respectively; Fn+↑, Fn+↓, Fn+←, Fn+→ are mapped to functions such as increase brightness, decrease brightness, decrease volume, increase volume, etc. respectively.
[0022] Furthermore, the matrix keyboard includes: a plurality of keys K, the keys K are arranged in a matrix of M rows and N columns, wherein M and N are both positive integers; M row pins R1 to RM, each row pin Ri is connected to a first end T1 of a row of keys K; N column pins C1 to CN, each column pin Ci is connected to a second end T2 of a column of keys K; wherein the first ends T1 of all keys K in the same row share one row pin, and the second ends T2 of all keys K in the same column share one column pin; the row pins R1 to RM are set as outputs, and output a preset high level through EC control when no key event is detected; the column pins C1 to CN are set as inputs, and are connected to a preset high level through pull-up resistors.
[0023] Furthermore, when any key K is pressed, conduction is formed between the row pin corresponding to the row where the corresponding key K is located and the column pin where the key is located, so that the level of the corresponding column pin is pulled down to a low level; EC sets the row pin of the current scan row to a low level row by row, and sets the row pins of other rows to a high level; reads the level status of each column pin, and if the level of a column pin is a low level, it is determined that a press event has occurred on the key corresponding to the corresponding column pin and the row pin of the current scan row; identifies the key where the key event has occurred based on the row number of the current scan row and the column number of the detected low level.
[0024] Compared with the prior art, the advantages of this application are:
[0025] By obtaining the key scan code and converting it into an index number, using the predefined multi-level key mapping table to obtain the corresponding key value code and identify the key type, the key decoding logic can be effectively simplified and the key recognition efficiency can be improved. Compared with the traditional method based on fixed mapping or complex condition judgment, this method has better flexibility and scalability.
[0026] The keyboard debugging management mechanism based on serial port commands is introduced to correspond the opening, execution, and closing of the debugging function to the commands one by one, and is managed uniformly through flags, making the debugging process controllable and customizable. Compared with the traditional debugging method based on firmware internal logic or physical buttons, this method provides users with a more friendly and intelligent human-computer interaction method, greatly improving the flexibility and ease of use of the debugging process.
[0027] In the process of converting scan codes to index numbers, the numerical characteristics of scan codes are fully utilized, the effective bits are quickly extracted through mask operations, and the index numbers are generated in combination with shift operations, which optimizes the search efficiency of the key mapping table. Compared with traditional methods based on branch judgment or sequential search, this method has significant advantages in both time complexity and space complexity, and is particularly suitable for debugging scenarios of large-scale matrix keyboards.
[0028] The recognition and processing of FN key combinations are fully considered, and the FN key flag and key combination mapping table are introduced. Through the cooperation of the two, the accurate judgment and response of the FN key and other key combinations are realized, which effectively expands the input function of the keyboard. Compared with the method of treating the key combination as an ordinary key or simply superimposing the key value code, this method can better support the customized configuration and flexible mapping of the key combination. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] This specification will be further described in the form of exemplary embodiments, which will be described in detail by the accompanying drawings. These embodiments are not restrictive, and in these embodiments, the same number represents the same structure, wherein:
[0030] Figure 1 is an exemplary flow chart of a matrix keyboard debugging method based on serial port instructions according to some embodiments of this specification;
[0031] Figure 2 is a schematic diagram of matrix keyboard pins according to some embodiments of this specification;
[0032] Figure 3 is an exemplary flow chart for determining key types according to some embodiments of this specification;
[0033] Figure 4 is an exemplary flow chart of polling printing according to some embodiments of the present specification. DETAILED DESCRIPTION
[0034] The method and system provided in the embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0035] Figure 1The present invention is an exemplary flow chart of a matrix keyboard debugging method based on serial port instructions according to some embodiments of the present specification, comprising: obtaining a scan code scan_code of the matrix keyboard, the scan code scan_code including the row pin number row and the column pin number col of the key pressed by the user; judging the key type according to the obtained scan code scan_code: if the scan code scan_code is less than 0X80, it indicates that the corresponding key is an ordinary key, and the embedded controller EC outputs the corresponding ordinary key debugging information through the serial port; if the scan code scan_code is greater than or equal to 0X80, it indicates that the corresponding key is a special key, and the execution Next step; if the key is a special key, EC converts the obtained scan code scan_code into an index number index, accesses the pre-defined key mapping table through the index number index, obtains the corresponding key value code key_code, and determines the function or mapping of the special key; according to the key value code key_code and the key event event, the type of the special key is determined: if the key value code Key_Code is equal to the key value code FN_Code of the FN key, and the key event Event is the make code Make_Code, EC sets the FN pressed flag FN_Flag to 1, indicating that the FN key is in the pressed state, and obtains the special key except F Other_Key_Code of the key value code of other keys except N key: If the key value code of other keys Other_Key_Code is greater than 0xE0, and the FN pressed flag bit FN_Flag is 1, EC performs bitwise AND operation on the key value code of other keys Other_Key_Code and 0xE0 to generate the index number Comb_Index of FN key combination, obtains the key value code Comb_Code of the corresponding FN key combination in the pre-defined key mapping table, and EC outputs the FN key combination debugging information through the serial port. The debugging information includes the key value code Comb_Code of FN key combination and the corresponding function; If the key code Key_Code is equal to the key code FN_Code of the FN key, and the key event Event is the break code Break_Code, EC sets the FN pressed flag FN_Flag to 0, indicating that the FN key is released, and EC outputs the debugging information of the FN key release through the serial port; if the key code Key_Code is not equal to the key code FN_Code of the FN key, EC obtains the FN key combination processing function corresponding to the key code key_code in the pre-defined key mapping table, executes the corresponding key combination function operation, and outputs the corresponding FN key combination debugging information through the serial port; EC manages keyboard debugging by receiving serial port instructions.
[0036] Figure 2This is a schematic diagram of the matrix keyboard pins shown in some embodiments of this specification. The hardware connection of the matrix keyboard is as follows: the keyboard consists of M rows and N columns of keys K, where M and N are positive integers. Each key K is a mechanical switch with two pin ends T1 and T2. M row pins R1RM and N column pins C1CN are set. For all keys in the i-th row (i=1M), their T1 ends are connected to the corresponding row pins Ri; for all keys in the j-th column (j=1N), their T2 ends are connected to the corresponding column pins Cj. All row pins R1~RM are configured as output mode, and are normally controlled by EC to output a high level (such as 3.3V). All column pins C1~CN are configured as input mode, and are connected to a high level (such as 3.3V) through pull-up resistors (such as 10kΩ).
[0037] Key scanning and event detection: EC initializes all row pins to high level and column pins to input. EC starts from the first row and scans row by row: set the row pin Ri of the current scan row to low level, and keep other row pins Rj (j≠i) at high level; read the level status of each column pin C1~CN; if a column pin Cj reads a low level, it means that the key Kij located at the i-th row and j-th column is pressed, forming a conduction, so that the column pin Cj is pulled low; record the row number i and the column number j where the low level is detected, and generate a scan code scan_code=(i, j) for subsequent key recognition. After EC completes the current row scan, it restores the current row pin to a high level. EC scans the next row in turn, and repeats until all M rows are scanned. After completing a round of scanning, EC can set a suitable scanning interval (such as 20ms) as needed, and then proceed to the next round of scanning.
[0038] Scan code generation example: Assuming the matrix keyboard has 4 rows and 4 columns, then M=N=4, the row pins are R1R4, and the column pins are C1C4. If the EC detects that the column pin C3 (j=3) is low when scanning the second row (i=2), it means that the key K23 is pressed. The EC generates the scan code scan_code=(2,3), indicating that the key where the key event occurred is located at the second row and the third column.
[0039] Figure 3 This is an exemplary flow chart for determining the key type according to some embodiments of this specification. Key type determination: During the matrix keyboard scanning process, EC obtains the key scan code scan_code that triggers the key event, which contains the row number row and column number col information of the key. EC determines the key type according to the numerical range of the scan code scan_code: if scan_code<0x80 (decimal 128), the key is considered to be a normal key; if scan_code≥0x80, the key is considered to be a special key. According to the determination result, corresponding key processing is performed.
[0040] Normal key processing: If the key is a normal key, EC directly sends its scan code scan_code to the host computer through the serial port. After receiving the scan code, the host computer can parse and respond to the key according to its own needs. In debug mode, EC can also output additional debugging information through the serial port, such as "Normalkey: row=2, col=3", etc., to facilitate the location and analysis of normal key events. Special key processing is detailed below.
[0041] EC further determines and processes the specific functions of special keys according to the key value code key_code, such as: multimedia control keys: volume adjustment, play / pause, previous song / next song, etc.; system control keys: power, sleep, wake up, etc.; function switching keys: Fn, NumLock, CapsLock, etc.; combination keys: such as Ctrl+Alt+Delete, etc. For special keys with different functions, EC can call the corresponding processing function or send the corresponding control command. In debug mode, EC can also output additional debug information through the serial port, such as "Specialkey: index=0x1A, key_code=VOLUME_UP", etc.
[0042] Steps to convert scan_code to index: Determine whether the highest bit of scan_code is 1; perform bitwise AND operation on scan_code and binary number 0x80 (decimal 128), i.e. scan_code&0x80. Determine the result of bitwise AND operation: if the result is 0, it means the highest bit of scan_code (the 7th bit) is 0; if the result is not 0, it means the highest bit of scan_code is 1. Perform corresponding scan code processing according to the judgment result.
[0043] Process the scan code scan_code to get processed_scan_code. If the highest bit of scan_code is 1: perform a bitwise AND operation on scan_code and the binary number 0x7F (decimal 127), that is,
[0044] processed_scan_code=scan_code&0x7F;In this way, the highest bit of scan_code can be cleared to 0, and the processed scan code processed_scan_code is obtained. If the highest bit of scan_code is 0: scan_code is directly assigned to processed_scan_code, that is, processed_scan_code=scan_code; In this way, no additional processing is required for the scan code.
[0045] Convert the processed scan code processed_scan_code to the index number index, and shift processed_scan_code left by one position, that is, index=processed_scan_code<<1; the left shift operation is equivalent to multiplying processed_scan_code by 2, and the scan code can be mapped to a continuous even index space. Look up the table according to the index number index to obtain the corresponding key-value code Key_Code, and define the key mapping table key_map[] to store the key-value code of each special key: key_map[] is an array of fixed size, and the array size is Max_Index+1; Max_Index is the maximum possible value of the index number index, which is determined by the number of rows and columns of the matrix keyboard; the array element key_map[i] represents the key-value code corresponding to the index number i, and is initialized to the corresponding Key_Code value. With index number index as the subscript, access the key mapping table key_map[] to obtain the corresponding key value code: if index≤Max_Index, then Key_Code=key_map[index]; if index>Max_Index, it means that index exceeds the valid range, then Key_Code=invalid_key_code. Pass the obtained Key_Code to the subsequent key processing steps. By judging the highest bit of the scan code, ordinary keys (highest bit is 0) and special keys (highest bit is 1) can be distinguished. For special keys, clearing the highest bit can map the scan code to the range of 0x00~0x7F to ensure the continuity of processed_scan_code. Shifting left by 1 bit can convert processed_scan_code to an even index number index, which is convenient for aligning and allocating index space according to multiples of 2. In the predefined key mapping table, each special key is assigned a unique key value code Key_Code. By looking up the table by index, the corresponding Key_Code can be quickly obtained, avoiding tedious conditional judgment. If index exceeds the size of the mapping table, a predefined invalid key value code is returned to facilitate exception handling. The subsequent steps can further call the corresponding key processing function according to the value of Key_Code.
[0046] Predefined key mapping table: special key table. The special key table is a one-dimensional array named special_key_table[]. Each element of the array represents a special key, and the value of the element is the key code Key_Code corresponding to the special key. The subscript of the array is the index number index of the special key, which corresponds to the index in step 3. The size of the special key table is Max_Index+1, where Max_Index is the maximum possible value of the index number index.
[0047] The FN combination key value table is a one-dimensional array named fn_comb_key_table[]. Each element of the array represents an FN combination key, and the value of the element is the combination key value code comb_code corresponding to the FN combination key. The subscript of the array is the index number comb_index of the FN combination key, which corresponds to the comb_index in step 4.2. The size of the FN combination key value table is Max_Comb_Index+1, where Max_Comb_Index is the maximum possible value of the FN combination key index number comb_index.
[0048] FN key combination function table, the FN key combination function table is a function pointer array, the array name is fn_comb_func_table[]. Each element of the array is a function pointer, pointing to the processing function of the corresponding FN key combination. The subscript of the array is the combo key value code comb_code, which corresponds to the comb_code in step 4.3. The size of the FN key combination function table is Max_Comb_Code+1, where Max_Comb_Code is the maximum possible value of the combo key value code comb_code.
[0049] Processing of special keys: When EC obtains the key code Key_Code, it determines whether the key code Key_Code is equal to the key code FN_Code of the FN key. EC first determines whether the obtained key code Key_Code is equal to the predefined key code FN_Code of the FN key. If Key_Code is equal to FN_Code, it means that the FN key is currently pressed or released; if Key_Code is not equal to FN_Code, it means that other special keys are currently pressed. Process the FN key press event. If it is determined that Key_Code is equal to FN_Code, and the key event Event is the make code Make_Code, it means that the FN key is pressed. EC sets the FN press flag FN_Flag to 1, indicating that the FN key is currently in the pressed state. EC waits for and obtains the key code Other_Key_Code of keys other than the FN key.
[0050] Process the FN key release event. If the Key_Code is equal to FN_Code and the key event Event is Break_Code, it means that the FN key is released. EC sets the FN pressed flag FN_Flag to 0, indicating that the FN key is currently in the released state. EC outputs the debugging information of the FN key release through the serial port, such as "FN key released".
[0051] Process the FN key combination. If the key code Other_Key_Code of other keys obtained is greater than 0xE0, and the FN pressed flag FN_Flag is 1, it means that the FN key combination is currently pressed. EC performs a bitwise AND operation on Other_Key_Code and 0xE0 to generate the index number Comb_Index of the FN key combination. EC uses Comb_Index as the index to find the key code Comb_Code of the corresponding FN key combination in the pre-defined key mapping table. If a valid Comb_Code is found, EC outputs the debugging information of the FN key combination through the serial port, such as "FN+F1 pressed, Comb_Code=0x101, Function: VolumeUp". The debugging information contains the key combination name of the FN key combination (such as "FN+F1"), the key code Comb_Code, and the corresponding function description.
[0052] Process other special keys. If it is determined that Key_Code is not equal to FN_Code, it means that other special keys are currently pressed. EC uses Key_Code as the index to find the corresponding special key processing function in the pre-defined key mapping table. If a valid processing function is found, EC calls the function to perform the corresponding special key function operation. EC outputs the debugging information of special keys through the serial port, such as "Specialkeypressed, Key_Code=0x80, Function: Mute". The debugging information contains the key value code Key_Code of the special key and the corresponding function description.
[0053] Supported FN key combinations, including but not limited to the following combinations: Fn+F1 to Fn+F12: function key combinations, which can be used for multimedia control, system control and other functions. Fn+Insert: can be used for screenshot, paste and other functions. Fn+Delete: can be used for system sleep, clear and other functions. Fn+arrow keys: can be used for volume adjustment, brightness adjustment, page scrolling and other functions. Specific FN key combination functions can be defined and mapped according to actual needs. Through the above steps, EC can accurately identify and process FN keys, FN key combinations and other special keys according to key value codes and key events. The FN pressed flag is used to record the current state of the FN key to determine whether an FN key combination needs to be generated. By generating the FN key combination index number through bitwise AND operation, the FN key combination can be mapped to a continuous index space for easy table lookup and processing.
[0054] The predefined key mapping table stores the key code and corresponding processing function of each special key and FN key combination, which improves the efficiency and scalability of key processing. By outputting detailed debugging information through the serial port, key events and processing results can be monitored in real time, which is convenient for debugging and verification. The index number of the FN key combination is calculated. If it is determined that Key_Code is equal to FN_code, it means that the FN key is currently pressed. EC performs a bitwise AND operation on the key code Key_Code of the FN key and the predefined FN key combination start value FN_start to obtain the index number comb_index of the FN key combination. The FN key combination start value FN_start is a predefined constant used to map the key code of the FN key combination to a continuous index space.
[0055] Processing of FN key combination, obtains the key combination code comb_code, EC uses the index number comb_index of the FN key combination as the array subscript, and searches for the corresponding key combination code comb_code in the FN key combination key value table fn_comb_key_table[]. If comb_index exceeds the valid range of the FN key combination key value table, comb_code is set to the predefined invalid key combination code invalid_comb_code. Obtain the entry address of the FN key combination processing function. If a valid key combination code comb_code is obtained, EC uses comb_code as the array subscript, and obtains the entry address of the corresponding FN key combination processing function in the FN key combination function table fn_comb_func_table[]. If comb_code exceeds the valid range of the FN key combination function table, the function entry address is set to the predefined invalid function address invalid_func_addr.
[0056] Execute the FN key combination processing function. If a valid function entry address is obtained, EC calls the FN key combination processing function pointed to by the function address and executes the corresponding key combination function. If an invalid function address is obtained, no operation is performed, or a predefined error handling is performed. Through the above steps, EC can quickly identify and process special keys and FN key combinations through the predefined key mapping table. The special key table realizes the mapping of scan code to key value code, the FN key combination key value table realizes the mapping of FN key combination to key combination value code, and the FN key combination function table realizes the mapping of key combination value code to processing function. This multi-level mapping method improves the efficiency and flexibility of key processing, and also facilitates the subsequent function expansion and modification.
[0057] Figure 4This is an exemplary flow chart of polling printing according to some embodiments of this specification. Serial port command management keyboard debugging: receiving and parsing serial port commands, EC receives command data sent externally through the serial port and parses the received data. The command data usually contains the identification code, parameters and other information of the command, and EC parses it according to the predefined command format. Matching the keyboard debugging function opening command, EC matches the received command with the predefined keyboard debugging function opening command. The keyboard debugging function opening command can be a specific string or a data packet in a specific format. If the received command matches the predefined opening command and the current command is not in the execution state, EC executes the subsequent steps.
[0058] To turn on the keyboard debugging function, EC sets the keyboard debugging switch flag Debug_Flag to a predefined high level value, indicating that the keyboard debugging function is turned on. Debug_Flag can be a Boolean variable or a specific register bit, which is used to indicate the current state of the keyboard debugging function. When Debug_Flag is a high level value, it means that the keyboard debugging function is on; when Debug_Flag is a low level value, it means that the keyboard debugging function is off. Record the execution status of the serial port instructions. EC creates an execution status record for each serial port instruction received. The execution status record contains information such as the instruction identification code, execution start time, and execution end time. The execution start time can be recorded using the EC's internal timestamp counter or an external real-time clock. The execution end time is initialized to an invalid value and updated after the instruction execution is completed.
[0059] Check the execution status of the current instruction. When EC receives a new serial port instruction, it first queries the current instruction record. If there is no corresponding record for the current instruction, or the execution end time of the corresponding record is valid (that is, the instruction has been executed), it is determined that the current instruction is in an unexecuted state. If the current instruction is in an unexecuted state, EC can execute the instruction; otherwise, EC ignores the instruction or returns to a busy state. Polling detects the keyboard debug switch flag. EC detects the value of the keyboard debug switch flag Debug_Flag in a cyclic manner through polling. Polling can be performed in the main loop of EC, or triggered by a timer interrupt. Execute the keyboard debugging function. When Debug_Flag is detected to be a high level value, EC executes the keyboard debugging function. EC obtains the scan code Scan_Code, key value code Key_Code and FN combination key value code Comb_Code of the key. Combine the obtained information into a debugging information string according to a predefined format. The debugging information string can contain scan codes, key value codes, FN combination key value codes and other related information for keyboard debugging and analysis.
[0060] Send debugging information through the serial port. EC sends the debugging information string to the debugging device through the serial port's transmit pin TX. The debugging device can be a host computer, a debugger, or other devices with serial port receiving function. EC can use the serial port's interrupt mode or query mode to send data. Match the keyboard debugging function shutdown command. During the keyboard debugging process, EC continues to receive serial port commands. When receiving a command that matches the pre-defined keyboard debugging function shutdown command, EC executes the shutdown step. Turn off the keyboard debugging function. EC sets the keyboard debugging switch flag Debug_Flag to a pre-defined low level value, indicating that the keyboard debugging function is turned off. When Debug_Flag is a low level value, EC stops executing the keyboard debugging function and no longer obtains and sends key information. Through the above steps, EC can manage the keyboard debugging function through serial port commands. The external device can turn on or off the keyboard debugging function by sending specific commands, and EC sets the keyboard debugging switch flag according to the received command. When the keyboard debugging function is turned on, EC polls and detects Debug_Flag, obtains key information, and sends the debugging information string through the serial port to achieve real-time debugging of the keyboard.
Claims
1. A matrix keyboard debugging method based on serial port instructions, comprising: S1, obtain the scan code scan_code of the matrix keyboard, the scan code scan_code includes the row pin number row and column pin number col of the key pressed by the user; S2, determine the key type based on the obtained scan code scan_code: If the scan code scan_code is less than 0X80, it means that the corresponding key is a normal key, and the embedded controller EC outputs the corresponding normal key debugging information through the serial port; If the scan code scan_code is greater than or equal to 0X80, it indicates that the corresponding key is a special key, and step S3 is executed; S3, if the key is a special key, EC converts the acquired scan code scan_code into an index number index, accesses a predefined key mapping table through the index number index, obtains the corresponding key value code key_code, and determines the function or mapping of the special key; S4, determine the special key type according to the key value code key_code and key event event: If the key code Key_Code is equal to the key code FN_Code of the FN key, and the key event Event is the make code Make_Code, EC sets the FN pressed flag FN_Flag to 1, indicating that the FN key is in the pressed state, and obtains the key code Other_Key_Code of other keys except the FN key: If the key code Other_Key_Code of other keys is greater than 0xE0, and the FN pressed flag FN_Flag is 1, EC performs a bitwise AND operation on the key code Other_Key_Code of other keys and 0xE0 to generate the index number Comb_Index of the FN combination key, obtains the key code Comb_Code of the corresponding FN combination key in the pre-defined key mapping table, and EC outputs the FN combination key debugging information through the serial port. The debugging information includes the key code Comb_Code of the FN combination key and the corresponding function; If the key code Key_Code is equal to the key code FN_Code of the FN key, and the key event Event is the break code Break_Code, EC sets the FN pressed flag FN_Flag to 0, indicating that the FN key is released, and EC outputs the debugging information of the FN key release through the serial port; If the key value code Key_Code is not equal to the key value code FN_Code of the FN key, the EC obtains the FN key combination processing function corresponding to the key value code key_code in the pre-defined key mapping table, executes the corresponding key combination function operation, and outputs the corresponding FN key combination debugging information through the serial port; S5, EC manages keyboard debugging by receiving serial port commands.
2. The matrix keyboard debugging method based on serial port instructions according to claim 1, characterized in that: S5, EC manages keyboard debugging by receiving serial port commands, including: When the EC receives an instruction that matches the predefined keyboard debugging function on instruction and the current instruction is not in execution state, the EC turns on the keyboard debugging function and sets the keyboard debugging switch flag Debug_Flag to a predefined high level value, indicating that the keyboard debugging function is turned on; EC detects the keyboard debug switch flag Debug_Flag in a cyclic manner through polling: When it is detected that the keyboard debugging switch flag Debug_Flag is set to a predefined high level value, the scan code Scan_Code, key value code Key_Code, and FN combination key value code Comb_Code of the key are obtained and printed through the serial port for keyboard debugging; During the cyclic detection process, when the EC receives an instruction matching the predefined keyboard debugging function closing instruction, the EC closes the keyboard debugging function and sets the keyboard debugging switch flag Debug_Flag to a predefined low level value, indicating that the keyboard debugging function has been closed.
3. The matrix keyboard debugging method based on serial port instructions according to claim 2, characterized in that: Print through the serial port and perform keyboard debugging, including: Combine the scan code Scan_Code, the key value code Key_Code and the FN key combination code Comb_Code into a debugging information string according to a predefined format; The debugging information string is sent to the debugging keyboard through the sending pin TX of the serial port.
4. The matrix keyboard debugging method based on serial port instructions according to claim 3 is characterized in that: Determine whether the current instruction is in execution state, including: Record the execution status of each serial port command received, which includes the command identification code, execution start time and execution end time; When a new serial port command is received, the current command record is queried. If the current command has no corresponding record or the execution has ended, it is determined that the current execution is in an unexecuted state.
5. The matrix keyboard debugging method based on serial port instructions according to claim 4 is characterized in that: S3, the step of converting the scan code scan_code into the index number index, comprising: Determine whether the highest bit of the scan code scan_code is 1: If the highest bit of the scan code scan_code is 1, the highest bit of the scan code scan_code is cleared to 0 to obtain the processed scan code processed_scan_code; If the highest bit of the scan code scan_code is 0, the scan code scan_code is directly assigned to the processed scan code processed_scan_code; Shift the processed scan code processed_scan_code one bit to the left to get the index number index; Use the index number index as the address and search for the corresponding key value code Key_Code in the pre-defined key mapping table: If the key value code Key_Code corresponding to the index number index is obtained in the key mapping table, the key value code Key_Code is passed to step S4; If the key value code Key_Code corresponding to the index number index is not obtained in the key mapping table, the predefined invalid key value code invalid_key_code is passed to step S4.
6. The matrix keyboard debugging method based on serial port instructions according to claim 5 is characterized in that: Predefined key mapping tables, including: special key table, FN combination key value table, FN combination key function table; The special key table uses the index number index as the address to store the key value code Key_Code corresponding to each special key; The FN key combination value table uses the index number comb_index of the FN key combination as the address to store the key combination value code comb_code corresponding to each FN key combination: When EC determines that the obtained key code Key_Code is not equal to the key code FN_code of the FN key, the index number comb_index of the FN key combination is obtained by performing a bitwise AND operation on the key code Key_Code of the corresponding key and the predefined FN key combination start value FN_start; EC uses the index number comb_index of the FN combination key as the address and searches for the corresponding combination key value code comb_code in the FN combination key value table.
7. The matrix keyboard debugging method based on serial port instructions according to claim 6 is characterized in that: The FN key combination function table uses the key combination code comb_code as the address and stores the entry address of the FN key combination processing function corresponding to each key combination code comb_code: When EC finds the combination key value code comb_code corresponding to the index number comb_index in the FN combination key value table, it uses the combination key value code comb_code as an address to obtain the entry address of the corresponding FN combination key processing function in the FN combination key function table.
8. The matrix keyboard debugging method based on serial port instructions according to claim 7 is characterized in that: FN key combination includes Fn+F1 to Fn+F12, Fn+Insert, Fn+Delete and Fn+arrow keys.
9. The matrix keyboard debugging method based on serial port instructions according to claim 8, characterized in that: Matrix keyboard, including: A plurality of keys K, the keys K are arranged in a matrix of M rows and N columns, wherein M and N are both positive integers; M row pins R1 to RM, each row pin Ri is connected to a first end T1 of a row of keys K; N column pins C1 to CN, each column pin Ci is connected to the second end T2 of a column of keys K; The first ends T1 of all the keys K in the same row share a row pin, and the second ends T2 of all the keys K in the same column share a column pin; The row pins R1 to RM are set as outputs and are controlled by EC to output a preset high level when no key event is detected; Column pins C1 to CN are set as inputs and connected to a preset high level through pull-up resistors.
10. The matrix keyboard debugging method based on serial port instructions according to claim 9, characterized in that: S1, get the scan code scan_code of the matrix keyboard, including: When any key K is pressed, the row pin corresponding to the row where the corresponding key K is located is connected to the column pin where the key is located, so that the level of the corresponding column pin is pulled down to a low level; EC sets the row pins of the current scan row to a low level row by row, and sets the row pins of other rows to a high level; reads the level status of each column pin, and if the level of a column pin is a low level, it determines that the key corresponding to the corresponding column pin and the row pin of the current scan row has been pressed; based on the row number of the current scan row and the column number of the detected low level, identifies the key where the key event occurred.
Citation Information
Patent Citations
User-defined keyboard and implementing method thereof
CN101158885A
Matrix type keyboard scanning and coding circuit
CN205318331U