Summary of the invention
In view of this, the present invention provides a kind of matrix keyboard circuit, scan method, device, processor and handheld terminal.Its concrete scheme is following:
A kind of matrix keyboard circuit comprises: positive phase matrix, anti-phase matrix and/or independent matrix, wherein:
In the said positive phase matrix; Each column scan input signal is pulled to power supply through each self-corresponding first resistance respectively; Each line scan signals is connected to each column scan input signal through each self-corresponding first button; When having button to press in the positive phase matrix, the said row input scan signal height state that connects this button is identical with said line output sweep signal height state;
In the said anti-phase matrix; Said each line scan signals is through each self-corresponding second button, second resistance and the triode of series connection successively; Link to each other with each column scan signal; When having button to press in the anti-phase matrix, connect the said row input scan signal height state and the said line output sweep signal height opposite states of this button;
In the said independent matrix, said each column scan signal is through each self-corresponding the 3rd button and the 3rd resistance eutral grounding of series connection successively, and when having button to press in the independent matrix, the column scan signal input state that connects this button is 0.
Preferably, said triode is the NPN pipe.
A kind of matrix keyboard circuit scanning method comprises:
When button was pressed, line scan signals exported complete 0 and complete 1 respectively;
Reading line scan signals respectively is complete 0 o'clock, and first scanning result of said column scan signal and said line scan signals are complete 1 o'clock, second scanning result of said column scan signal;
Analyze said first scanning result and second scanning result, confirm push-button type;
According to said definite push-button type, carry out operation accordingly, to confirm the current button that is pressed.
Preferably, said first scanning result of said analysis and second scanning result, confirm that the process of its push-button type comprises:
When the value of said first scanning result and second scanning result is 1 entirely, confirm that said push-button type is shake;
When said first scanning result is identical with said second scanning result, confirm that said push-button type is independent matrix press-key;
When said first scanning result is not 1 entirely, and said second scanning result is 1 o'clock entirely, confirms that said push-button type is the positive matrix press-key;
When said first scanning result is 1 entirely, and said second scanning result is not 1 o'clock entirely, confirms that said push-button type is the anti-phase matrix press-key.
Preferably, the said definite push-button type of said foundation is carried out operation accordingly, comprises with the process of confirming the current button that is pressed:
When said push-button type was independent matrix press-key, searching in said first scanning result was 0 bit, confirms that said bit corresponding key is the current button that is pressed;
When said push-button type was the positive matrix press-key, according to current line output 0, the order output scanning signal of other line outputs 1 scanned the button in the positive phase matrix to each line scan signals successively, to confirm the current button that is pressed;
When said push-button type was the anti-phase matrix press-key, each line scan signals was successively according to current line output 1, and the order output scanning signal of other line outputs 0 scans the button in the anti-phase matrix, to confirm the current button that is pressed.
Preferably, line scan signals import respectively complete 0 with complete 1 step before also comprise:
Wait for Preset Time;
Whether judge currently has key to press, if, then continue to carry out, if not, then finish.
A kind of matrix keyboard circuit scanister comprises:
The sweep signal output unit is used for when button is pressed, and line scan signals exports complete 0 and complete 1 respectively;
The scanning result reading unit, being used for reading respectively line scan signals is complete 0 o'clock, first scanning result of said column scan signal and said line scan signals are complete 1 o'clock, second scanning result of said column scan signal;
Analyze and confirm the unit, be used to analyze said first scanning result and second scanning result, confirm push-button type;
Button is confirmed the unit, is used for according to said definite push-button type, carries out operation accordingly, to confirm the current button that is pressed.
A kind of processor comprises: the matrix keyboard scanister, and said matrix keyboard scanister is used for; When having button to press in the said matrix keyboard circuit, the control line scan signals exports complete 0 respectively with complete 1, and reading line scan signals respectively is complete 0 o'clock; First scanning result of said column scan signal and said line scan signals are complete 1 o'clock, and second scanning result of said column scan signal is analyzed said first scanning result and second scanning result; Confirm push-button type; According to said definite push-button type, carry out operation accordingly, to confirm the current button that is pressed.
A kind of handheld terminal comprises: above-mentioned matrix keyboard circuit with link to each other above-mentioned processor with said matrix keyboard circuit.
Preferably, said handheld terminal is mobile phone or palm PC PDA.
Of above-mentioned scheme, the disclosed matrix keyboard circuit of the embodiment of the invention comprises positive phase matrix, anti-phase matrix and/or independent matrix; Under the situation that does not increase sweep signal; Have different scanning result's characteristic through the same scan signal at different matrixes, keyboard is scanned, can improve key scan quantity greatly; Solve the not enough problem of IO port, improved the performance at terminal.
Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
The embodiment of the invention discloses a kind of matrix keyboard circuit; Its structure is as shown in Figure 3; Comprise: positive phase matrix 31, anti-phase matrix 32 and independent matrix 33, wherein: the line scan signals of KBC output and the number of column scan signal are respectively m+1, n+1 in the present embodiment, and the number of first button that each line scan signals is corresponding is n+1; Correspond respectively to n+1 column scan signal; Total number of first button in the positive phase matrix is that (m+1) * (n+1) is individual, and total number of second button is that (m+1) * (n+1) is individual, and total number of the 3rd button is n+1.
In the said positive phase matrix 31; Each column scan input signal Col [n...0] is pulled to power supply through each self-corresponding first resistance R, 10~R1n respectively; Each line scan signals Row [m...0] is connected to each column scan input signal Col [n...0] through each self-corresponding first button; When having button to press in the positive phase matrix 31, the said row input scan signal height state that connects this button is identical with said line output sweep signal height state.
In the said anti-phase matrix 32; Said each line scan signals Row [m...0] is through each self-corresponding second button, second resistance R, 20~R2n and the NPN triode Qn~Q0 of series connection successively; Link to each other with each column scan signal Col [n...0]; When having button to press in the anti-phase matrix, connect the said row input scan signal height state and the said line output sweep signal height opposite states of this button.
In the said independent matrix 33; Said each column scan signal Col [n...0] is through each self-corresponding the 3rd button and the 3rd resistance R 30~R3n ground connection of series connection successively; When having button to press in the independent matrix, the column scan signal input state that connects this button is 0.
In the above-mentioned matrix circuit, resistance R 10~R1n resistance can equate, gets 47Kohm usually, and resistance R 20~R2n resistance can equate, gets 47Kohm usually, and resistance R 30~R3n resistance can equate, gets 4.7Kohm usually.
In the present embodiment, if m, n get 4, promptly the number of line scan signals and column scan signal is respectively 4, if according to connected mode among Fig. 1, it scans 4*4=16 button only.And according to connected mode shown in Fig. 3; Under the situation that does not increase sweep signal; Can scan 4*4+4*4+4=36 button altogether, this shows, the disclosed matrix keyboard circuit of the embodiment of the invention can improve key scan quantity greatly; Solve the not enough problem of IO port, improved the performance at terminal.
Present embodiment does not limit in the keyboard matrix circuit need comprise anti-phase matrix and independent matrix simultaneously; Can be according to actual needs; Select anti-phase matrix or independent matrix and positive phase matrix to be used arbitrarily; Make it to enlarge number of keys, the demand of the convenient, flexible multiple situation of adaptation according to actual conditions.Suppose to adopt positive phase matrix to match with the anti-phase matrix, its key number that can scan is 4*4+4*4=32, under the situation that does not increase sweep signal, the key scan number is doubled.Suppose to adopt positive phase matrix to match with independent matrix, its key number that can scan is 4*4+4=20, and under the situation that does not increase sweep signal, the number of scanning button has promoted four.
Triode in the foregoing description can be selected PNP for use equally, just need adjust concrete circuit connecting form accordingly according to the type of pipe.
The present invention discloses a kind of matrix keyboard circuit scanning method, be used with above-mentioned keyboard matrix circuit, its flow process is as shown in Figure 4, comprising:
Step S41, when button is pressed, line scan signals exports complete 0 and complete 1 respectively;
Step S42, to read line scan signals respectively be complete 0 o'clock, and first scanning result of said column scan signal and said line scan signals are complete 1 o'clock, second scanning result of said column scan signal;
Step S43, said first scanning result of analysis and second scanning result are confirmed push-button type;
If comprise positive phase matrix and reverse matrix in the current keyboard matrix circuit; Then push-button type comprises positive matrix press-key and anti-phase matrix press-key; If comprise independent matrix, then push-button type also comprises independent matrix press-key, distinguishes the zone at button place to utilize matrix-type.
Step S44, the said definite push-button type of foundation are carried out operation accordingly, to confirm the current button that is pressed.
Zones of different according to the button place adopts corresponding method, confirms the button that is pressed in this zone.
In the above-mentioned steps, can also comprise, at the beginning of flow process begins, when judgement has key to press, wait for Preset Time; Whether judge then currently has key to press, if, then continue to carry out, if not, then finish.To realize mode, eliminate because the erroneous judgement that key jitter causes improves the accuracy of judging through time-delay.
Pass through to set the output valve of line scan signals in the present embodiment; To obtain column scan signal corresponding result when the different line scan signals output valves; And then judge push-button type through the result, that is, be that the button in which matrix is pressed; According to the characteristics of this matrix, carry out corresponding operation then to confirm concrete button.This method is simple, can be adapted to the multiple way of realization of above-mentioned keyboard matrix circuit.
Further, in the above-mentioned steps, said first scanning result of said analysis and second scanning result confirm that the process of its push-button type is as shown in Figure 5, comprising:
Step S51, judge whether said first scanning result is identical with second scanning result, if, execution in step S52 then, if not, execution in step S53 then;
Step S52, confirm that said push-button type is independent matrix press-key, and finish;
Step S53, judge whether the value of said first scanning result and second scanning result is 1 entirely, if, execution in step S54 then, if not, execution in step S55 then;
Step S54, confirm that said push-button type is shake, and finish;
Step S55, judge whether said first scanning result is not 1 entirely, and said second scanning result is 1 entirely, if, execution in step S56 then, if not, execution in step S57 then;
Step S56, confirm that said push-button type is the positive matrix press-key, and finish;
Step S57, judge whether said first scanning result is 1 entirely, and said second scanning result is not 1 entirely, if, execution in step S58 then, if not, execution in step S59 then;
Step S58, confirm that said push-button type is the anti-phase matrix press-key, and finish;
Step S59, confirm that said button is invalid button.
In the present embodiment according to the different situations of first scanning result and second scanning result; Analyze the push-button type of current button; To confirm being convenient to the different disposal route of following adopted in its residing position through its push-button type, judge the concrete button that is pressed.
Present embodiment does not limit the sequencing of a plurality of criterions, can adjust its order according to actual needs arbitrarily.
Further,, carry out operation accordingly according to said definite push-button type, as shown in Figure 6 with the flow process of confirming the current button that is pressed, comprising:
Step S61, when said push-button type is independent matrix press-key, searching in said first scanning result is 0 bit, confirms that said bit corresponding key is the current button that is pressed;
If first scanning result is 1101, be pressed with resistance R 32 corresponding key in the then corresponding independent matrix.
Step S62, when said push-button type is the positive matrix press-key, according to current line output 0, the order output scanning signal of other line outputs 1 scans the button in the positive phase matrix to each line scan signals successively, to confirm the current button that is pressed;
Its detailed process is: Row0 output 0, and Row [3...1] output 1 scans the button in the positive phase matrix; See that the corresponding column scan signal of which button is input as 0 in first row, if do not have, then Row1 output 0; Other line outputs 1 scan the button in the positive phase matrix, see that the corresponding column scan signal of which button is 0 in second row; The output of conversion line scan signals successively up to the button that has detected whole four lines, is found the key that is pressed.
Step S63, when said push-button type is the anti-phase matrix press-key, each line scan signals is successively according to current line output 1, the order output scanning signal of other line outputs 0, the button in the scanning anti-phase matrix is to confirm the current button that is pressed.
Concrete steps are similar with above-mentioned steps S62, and just the output valve of line scan signals has been done corresponding adjustment, judge that the principle of the key that is pressed is opposite with it.
Through above-mentioned steps, determine the key that is pressed, decision rule is separate between each matrix, avoids judging by accident, has improved discriminant accuracy.
Further, the invention discloses a kind of matrix keyboard scanister, the signal of above-mentioned keyboard matrix circuit is handled being used for, realize the scanning of each button and confirm.Its structure is as shown in Figure 7, comprising: sweep signal output unit 71, scanning result reading unit 72, the definite unit 73 of analysis and button are confirmed unit 74, wherein:
Sweep signal output unit 71 is used for when button is pressed, and line scan signals exports complete 0 and complete 1 respectively; It is complete 0 o'clock that scanning result reading unit 72 is used for reading respectively line scan signals, and first scanning result of said column scan signal and said line scan signals are complete 1 o'clock, second scanning result of said column scan signal; Analyze and confirm that unit 73 is used to analyze said first scanning result and second scanning result, confirm push-button type; Button confirms that unit 74 is used for according to said definite push-button type, carries out operation accordingly, to confirm the current button that is pressed.
The principle of work of each unit is described below in this matrix keyboard scanister:
When key is pressed; Sweep signal output unit control line scan signals exports complete 0 successively with complete 1, the scanning result reading unit read when line scan signals export successively complete 0 the time first scanning result and the line scan signals of column scan signal export complete 1 the time, second scanning result of column scan signal; Said result is analyzed in analyzing definite unit; Confirm the different types of corresponding key as a result, utilize button to confirm the unit then, determine the current button that is pressed.
Its concrete course of work such as above-mentioned method embodiment are said, repeat no more at this.
Simultaneously, the invention discloses a kind of processor with above-mentioned matrix keyboard scanister, said matrix keyboard scanister is used for; When having button to press in the said matrix keyboard circuit, the control line scan signals exports complete 0 respectively with complete 1, and reading line scan signals respectively is complete 0 o'clock; First scanning result of said column scan signal and said line scan signals are complete 1 o'clock, and second scanning result of said column scan signal is analyzed said first scanning result and second scanning result; Confirm push-button type; According to said definite push-button type, carry out operation accordingly, to confirm the current button that is pressed.
Further, the invention also discloses a kind of handheld terminal, its structure is as shown in Figure 8, comprising: described matrix keyboard circuit 81 of the foregoing description and the processor 82 that links to each other with said matrix keyboard circuit;
Said processor 82 is used for, and when having button to press in the said matrix keyboard circuit 81, the control line scan signals exports complete 0 and complete 1 respectively; Reading line scan signals respectively is complete 0 o'clock; First scanning result of said column scan signal and said line scan signals are complete 1 o'clock, and second scanning result of said column scan signal is analyzed said first scanning result and second scanning result; Confirm push-button type; According to said definite push-button type, carry out operation accordingly, to confirm the current button that is pressed.
Further, the handheld terminal described in the present embodiment is mobile phone or palm PC PDA, and perhaps any one has the terminal device of matrix keyboard circuit.
Each embodiment adopts the mode of going forward one by one to describe in this instructions, and what each embodiment stressed all is and the difference of other embodiment that identical similar part is mutually referring to getting final product between each embodiment.For the disclosed device of embodiment, because it is corresponding with the embodiment disclosed method, so description is fairly simple, relevant part is partly explained referring to method and is got final product.
The professional can also further recognize; The unit and the algorithm steps of each example of describing in conjunction with embodiment disclosed herein; Can realize with electronic hardware, computer software or the combination of the two; For the interchangeability of hardware and software clearly is described, the composition and the step of each example described prevailingly according to function in above-mentioned explanation.These functions still are that software mode is carried out with hardware actually, depend on the application-specific and the design constraint of technical scheme.The professional and technical personnel can use distinct methods to realize described function to each certain applications, but this realization should not thought and exceeds scope of the present invention.
The method of describing in conjunction with embodiment disclosed herein or the step of algorithm can be directly with the software modules of hardware, processor execution, and perhaps the combination of the two is implemented.Software module can place the storage medium of any other form known in random access memory (RAM), internal memory, ROM (read-only memory) (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or the technical field.
To the above-mentioned explanation of the disclosed embodiments, make this area professional and technical personnel can realize or use the present invention.Multiple modification to these embodiment will be conspicuous concerning those skilled in the art, and defined General Principle can realize under the situation that does not break away from the spirit or scope of the present invention in other embodiments among this paper.Therefore, the present invention will can not be restricted to these embodiment shown in this paper, but will meet and principle disclosed herein and features of novelty the wideest corresponding to scope.