Mercurial > louis > kiibohd-controller
annotate Scan/matrix/matrix_scan.c @ 308:ab4515606277
Fix whitespace
Use a consistent standard - Tabs in front for indenting, spaces after for anything else. This way everything stays nice and lined up while also letting users change there prefered indent level. Most of the new files from Haata where already in this format.
author | Rowan Decker <Smasher816@gmail.com> |
---|---|
date | Sun, 08 Mar 2015 18:40:01 -0700 |
parents | 0c5d1fe99302 |
children |
rev | line source |
---|---|
123
0c5d1fe99302
Adding CLI and CDC Serial support for Teensy 2.0 and Teensy 2.0++
Jacob Alexander <haata@kiibohd.com>
parents:
59
diff
changeset
|
1 /* Copyright (C) 2011,2014 by Jacob Alexander |
0c5d1fe99302
Adding CLI and CDC Serial support for Teensy 2.0 and Teensy 2.0++
Jacob Alexander <haata@kiibohd.com>
parents:
59
diff
changeset
|
2 * |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
3 * Permission is hereby granted, free of charge, to any person obtaining a copy |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
4 * of this software and associated documentation files (the "Software"), to deal |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
5 * in the Software without restriction, including without limitation the rights |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
7 * copies of the Software, and to permit persons to whom the Software is |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
8 * furnished to do so, subject to the following conditions: |
123
0c5d1fe99302
Adding CLI and CDC Serial support for Teensy 2.0 and Teensy 2.0++
Jacob Alexander <haata@kiibohd.com>
parents:
59
diff
changeset
|
9 * |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
10 * The above copyright notice and this permission notice shall be included in |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
11 * all copies or substantial portions of the Software. |
123
0c5d1fe99302
Adding CLI and CDC Serial support for Teensy 2.0 and Teensy 2.0++
Jacob Alexander <haata@kiibohd.com>
parents:
59
diff
changeset
|
12 * |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
19 * THE SOFTWARE. |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
20 */ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
21 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
22 // ----- Includes ----- |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
23 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
24 // AVR Includes |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
25 #include <avr/io.h> |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
26 #include <util/delay.h> |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
27 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
28 // Project Includes |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
29 #include <print.h> |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
30 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
31 // Local Includes |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
32 #include "matrix_scan.h" |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
33 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
34 // Matrix Configuration |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
35 #include <matrix.h> |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
36 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
37 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
38 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
39 // ----- Macros ----- |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
40 |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
41 // -- pinSetup Macros -- |
308 | 42 #define REG_SET(reg) reg |= (1 << ( matrix[row*(MAX_ROW_SIZE+1)+col] % 10 ) ) // Modulo 10 for the define offset for each pin set 12 or 32 -> shift of 2 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
43 #define REG_UNSET(reg) reg &= ~(1 << ( matrix[row*(MAX_ROW_SIZE+1)+col] % 10 ) ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
44 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
45 #define PIN_SET(pin,scan,direction) \ |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
46 switch ( direction ) { \ |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
47 case columnSet: PIN_SET_COL(pin,scan); \ |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
48 case rowSet: PIN_SET_ROW(pin,scan); \ |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
49 } \ |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
50 break |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
51 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
52 // TODO Only scanCol_powrRow Tested (and powrRow) |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
53 #define PIN_SET_COL(pin,scan) \ |
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
54 switch ( scan ) { \ |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
55 case scanCol: \ |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
56 case scanRow_powrCol: \ |
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
57 case scanDual: \ |
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
58 REG_SET(port##pin); break; \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
59 case scanCol_powrRow: REG_UNSET(ddr##pin); REG_UNSET(DDR##pin); \ |
308 | 60 REG_SET(port##pin); REG_SET(PORT##pin); break; \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
61 case powrRow: break; \ |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
62 case powrCol: REG_SET(ddr##pin); REG_SET(DDR##pin); \ |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
63 REG_SET(port##pin); REG_SET(PORT##pin); break; \ |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
64 } \ |
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
65 break |
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
66 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
67 // TODO Only scanCol_powrRow Tested (and powrRow) |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
68 #define PIN_SET_ROW(pin,scan) \ |
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
69 switch ( scan ) { \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
70 case scanRow_powrCol: REG_UNSET(ddr##pin); REG_SET(port##pin); break; \ |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
71 case scanRow: \ |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
72 case scanDual: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
73 REG_SET(port##pin); break; \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
74 case scanCol_powrRow: REG_SET(ddr##pin); REG_SET(DDR##pin); \ |
308 | 75 REG_UNSET(port##pin); REG_UNSET(PORT##pin); break; \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
76 case powrRow: REG_SET(ddr##pin); REG_SET(DDR##pin); \ |
308 | 77 REG_SET(port##pin); REG_SET(PORT##pin); break; \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
78 case powrCol: break; \ |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
79 } \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
80 break |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
81 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
82 #define PIN_CASE(pinLetter) \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
83 case pin##pinLetter##0: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
84 case pin##pinLetter##1: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
85 case pin##pinLetter##2: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
86 case pin##pinLetter##3: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
87 case pin##pinLetter##4: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
88 case pin##pinLetter##5: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
89 case pin##pinLetter##6: \ |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
90 case pin##pinLetter##7 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
91 |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
92 // -- Column Scan Macros -- |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
93 #define PIN_TEST_COL(pin) \ |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
94 scanCode = matrix[row*(MAX_ROW_SIZE+1)+col]; \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
95 if ( scanCode && !( pin & ( 1 << ( matrix[0*(MAX_ROW_SIZE+1)+col] % 10 ) ) ) ) \ |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
96 { \ |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
97 detectArray[scanCode]++; \ |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
98 } \ |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
99 break |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
100 |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
101 // -- Row Scan Macros -- |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
102 #define PIN_TEST_ROW(pin) \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
103 scanCode = matrix[row*(MAX_ROW_SIZE+1)+col]; \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
104 if ( scanCode && !( pin & ( 1 << ( matrix[row*(MAX_ROW_SIZE+1)+0] % 10 ) ) ) ) \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
105 { \ |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
106 detectArray[scanCode]++; \ |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
107 } \ |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
108 break |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
109 |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
110 // -- Scan Dual Macros -- |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
111 #define PIN_DUALTEST_ROW(pin) \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
112 scanCode = matrix[row*(MAX_ROW_SIZE+1)+col]; \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
113 if ( scanCode \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
114 && !( pin & ( 1 << ( matrix[row*(MAX_ROW_SIZE+1)+0] % 10 ) ) ) \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
115 && detectArray[scanCode] & 0x01 ) \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
116 { \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
117 detectArray[scanCode]++; \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
118 } \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
119 else \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
120 { \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
121 if ( detectArray[scanCode] & 0x01 ) \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
122 detectArray[scanCode]--; \ |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
123 } \ |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
124 break |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
125 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
126 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
127 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
128 // ----- Variables ----- |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
129 uint8_t showDebug = 0; |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
130 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
131 // Debug Variables for GPIO setting |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
132 uint8_t portA = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
133 uint8_t portB = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
134 uint8_t portC = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
135 uint8_t portD = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
136 uint8_t portE = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
137 uint8_t portF = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
138 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
139 uint8_t ddrA = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
140 uint8_t ddrB = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
141 uint8_t ddrC = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
142 uint8_t ddrD = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
143 uint8_t ddrE = 0x00; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
144 uint8_t ddrF = 0x00; |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
145 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
146 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
147 // ----- Functions ----- |
53
c6fdd7005ea0
Adding initial HP150 and IBMConvertible scan modules.
Jacob Alexander <triplehaata@gmail.com>
parents:
52
diff
changeset
|
148 void matrix_debugPins(void); |
c6fdd7005ea0
Adding initial HP150 and IBMConvertible scan modules.
Jacob Alexander <triplehaata@gmail.com>
parents:
52
diff
changeset
|
149 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
150 // Pin Setup Debug |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
151 inline void matrix_debugPins() |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
152 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
153 char tmpStr[6]; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
154 info_print("Initial Matrix Pin Setup"); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
155 info_print(" ddrA ddrB ddrC ddrD ddrE ddrF"); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
156 print(" "); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
157 hexToStr_op( ddrA, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
158 hexToStr_op( ddrB, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
159 hexToStr_op( ddrC, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
160 hexToStr_op( ddrD, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
161 hexToStr_op( ddrE, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
162 hexToStr_op( ddrF, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
163 print("\n"); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
164 info_print("portA portB portC portD portE portF"); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
165 print(" "); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
166 hexToStr_op( portA, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
167 hexToStr_op( portB, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
168 hexToStr_op( portC, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
169 hexToStr_op( portD, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
170 hexToStr_op( portE, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
171 hexToStr_op( portF, tmpStr, 2 ); dPrintStrs( " 0x", tmpStr ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
172 print("\n"); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
173 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
174 showDebug++; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
175 } |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
176 |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
177 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
178 // Column Setup |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
179 inline void matrix_columnSet( uint8_t *matrix, uint8_t scanType, uint16_t startIndex, uint16_t colsToIterate ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
180 { |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
181 // Calculate the number of pins to iterate over |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
182 uint8_t maxColumns = startIndex + colsToIterate - 1; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
183 if ( maxColumns > MAX_COL_SIZE ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
184 maxColumns = MAX_COL_SIZE; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
185 |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
186 uint16_t row, col; |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
187 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
188 // Columns |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
189 for ( col = startIndex, row = 0; col <= maxColumns; col++ ) |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
190 { |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
191 // We can't pass 2D arrays, so just point to the first element and calculate directly |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
192 switch ( matrix[row*(MAX_ROW_SIZE+1)+col] ) |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
193 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
194 #if defined(__AVR_AT90USB1286__) |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
195 PIN_CASE(A): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
196 PIN_SET(A, scanType, columnSet); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
197 #endif |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
198 PIN_CASE(B): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
199 PIN_SET(B, scanType, columnSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
200 PIN_CASE(C): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
201 PIN_SET(C, scanType, columnSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
202 PIN_CASE(D): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
203 PIN_SET(D, scanType, columnSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
204 PIN_CASE(E): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
205 PIN_SET(E, scanType, columnSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
206 PIN_CASE(F): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
207 PIN_SET(F, scanType, columnSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
208 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
209 default: |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
210 continue; |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
211 } |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
212 } |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
213 } |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
214 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
215 // Row Setup |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
216 inline void matrix_rowSet( uint8_t *matrix, uint8_t scanType, uint16_t startIndex, uint8_t rowsToIterate ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
217 { |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
218 // Calculate the number of pins to iterate over |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
219 uint16_t maxRows = startIndex + rowsToIterate - 1; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
220 if ( maxRows > MAX_ROW_SIZE ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
221 maxRows = MAX_ROW_SIZE; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
222 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
223 uint16_t row, col; |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
224 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
225 // Rows |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
226 for ( col = 0, row = startIndex; row <= maxRows; row++ ) |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
227 { |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
228 // We can't pass 2D arrays, so just point to the first element and calculate directly |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
229 switch ( matrix[row*(MAX_ROW_SIZE+1)+col] ) |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
230 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
231 #if defined(__AVR_AT90USB1286__) |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
232 PIN_CASE(A): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
233 PIN_SET(A, scanType, rowSet); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
234 #endif |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
235 PIN_CASE(B): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
236 PIN_SET(B, scanType, rowSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
237 PIN_CASE(C): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
238 PIN_SET(C, scanType, rowSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
239 PIN_CASE(D): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
240 PIN_SET(D, scanType, rowSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
241 PIN_CASE(E): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
242 PIN_SET(E, scanType, rowSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
243 PIN_CASE(F): |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
244 PIN_SET(F, scanType, rowSet); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
245 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
246 default: |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
247 continue; |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
248 } |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
249 } |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
250 } |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
251 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
252 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
253 // Goes through the defined matrix and matrix mode, and sets the initial state of all of the available pins |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
254 void matrix_pinSetup( uint8_t *matrix, uint8_t scanType ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
255 { |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
256 // Loop through all the pin assignments, for the initial pin settings |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
257 matrix_rowSet ( matrix, scanType, 1, MAX_ROW_SIZE ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
258 matrix_columnSet( matrix, scanType, 1, MAX_COL_SIZE ); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
259 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
260 // Pin Status |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
261 if ( showDebug == 0 ) // Only show once |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
262 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
263 matrix_debugPins(); |
308 | 264 } |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
265 } |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
266 |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
267 // Scans the given matrix determined by the scanMode method |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
268 inline void matrix_scan( uint8_t *matrix, uint8_t *detectArray ) |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
269 { |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
270 // Loop variables for all modes |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
271 uint16_t col = 1; |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
272 uint16_t row = 1; |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
273 uint16_t scanCode = 0; |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
274 |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
275 |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
276 // TODO Only scanCol_powrRow tested |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
277 // Column Scan and Column Scan, Power Row |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
278 #if scanMode == scanCol || scanMode == scanCol_powrRow |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
279 for ( ; row <= MAX_ROW_SIZE; row++ ) |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
280 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
281 // Power each row separately |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
282 matrix_rowSet( matrix, powrRow, row, 1 ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
283 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
284 for ( col = 1; col <= MAX_COL_SIZE; col++ ) |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
285 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
286 // Scan over the pins for each of the columns, and using the pin alias to determine which pin to set |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
287 // (e.g. / 10 is for the pin name (A,B,C,etc.) and % 10 is for the position of the pin (A1,A2,etc.)) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
288 switch ( matrix[0*(MAX_ROW_SIZE+1)+col] / 10 ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
289 { |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
290 #if defined(__AVR_AT90USB1286__) |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
291 case 0: // PINA |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
292 PIN_TEST_COL(PINA); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
293 #endif |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
294 case 1: // PINB |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
295 PIN_TEST_COL(PINB); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
296 case 2: // PINC |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
297 PIN_TEST_COL(PINC); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
298 case 3: // PIND |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
299 PIN_TEST_COL(PIND); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
300 case 4: // PINE |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
301 PIN_TEST_COL(PINE); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
302 case 5: // PINF |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
303 PIN_TEST_COL(PINF); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
304 } |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
305 } |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
306 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
307 // Unset the row power |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
308 matrix_rowSet( matrix, scanMode, row, 1 ); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
309 } |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
310 #endif // scanMode |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
311 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
312 |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
313 // Row Scan and Row Scan, Power Row |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
314 #if scanMode == scanRow || scanMode == scanRow_powrCol |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
315 for ( ; col <= MAX_COL_SIZE; col++ ) |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
316 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
317 // Power each column separately |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
318 matrix_columnSet( matrix, powrCol, col, 1 ); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
319 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
320 for ( row = 1; row <= MAX_ROW_SIZE; row++ ) |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
321 { |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
322 // Scan over the pins for each of the rows, and using the pin alias to determine which pin to set |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
323 // (e.g. / 10 is for the pin name (A,B,C,etc.) and % 10 is for the position of the pin (A1,A2,etc.)) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
324 switch ( matrix[row*(MAX_ROW_SIZE+1)+0] / 10 ) |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
325 { |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
326 #if defined(__AVR_AT90USB1286__) |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
327 case 0: // PINA |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
328 PIN_TEST_ROW(PINA); |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
329 #endif |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
330 case 1: // PINB |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
331 PIN_TEST_ROW(PINB); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
332 case 2: // PINC |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
333 PIN_TEST_ROW(PINC); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
334 case 3: // PIND |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
335 PIN_TEST_ROW(PIND); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
336 case 4: // PINE |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
337 PIN_TEST_ROW(PINE); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
338 case 5: // PINF |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
339 PIN_TEST_ROW(PINF); |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
340 } |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
341 } |
52
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
342 |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
343 // Unset the column power |
689e131c5a4b
Adding SKM67001 scan module.
Jacob Alexander <triplehaata@gmail.com>
parents:
41
diff
changeset
|
344 matrix_columnSet( matrix, scanMode, col, 1 ); |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
345 } |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
346 #endif // scanMode |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
347 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
348 |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
349 // Dual Scan |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
350 #if scanMode == scanDual |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
351 // First do a scan of all of the columns, marking each one |
59
f605b500bbd3
Commenting out lines, to get the code to compile.
Jacob Alexander <triplehaata@gmail.com>
parents:
53
diff
changeset
|
352 //matrix_pinSetup( matrix, scanCol_powrRow, 0, MAX_ROW_SIZE, MAX_COL_SIZE ); TODO |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
353 _delay_us( 1 ); |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
354 for ( ; row < (MAX_COL_SIZE+1); row++ ) for ( ; col < (MAX_ROW_SIZE+1); col++ ) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
355 { |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
356 // Scan over the pins for each of the columns, and using the pin alias to determine which pin to set |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
357 // (e.g. / 10 is for the pin name (A,B,C,etc.) and % 10 is for the position of the pin (A1,A2,etc.)) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
358 switch ( matrix[0*(MAX_ROW_SIZE+1)+col] / 10 ) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
359 { |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
360 #if defined(__AVR_AT90USB1286__) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
361 case 0: // PINA |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
362 PIN_TEST_COL(PINA); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
363 #endif |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
364 case 1: // PINB |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
365 PIN_TEST_COL(PINB); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
366 case 2: // PINC |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
367 PIN_TEST_COL(PINC); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
368 case 3: // PIND |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
369 PIN_TEST_COL(PIND); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
370 case 4: // PINE |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
371 PIN_TEST_COL(PINE); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
372 case 5: // PINF |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
373 PIN_TEST_COL(PINF); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
374 } |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
375 } |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
376 |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
377 // Next, do a scan of all of the rows, clearing any "vague" keys (only detected on row, but not column, or vice-versa) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
378 // And marking any keys that are detected on the row and column |
59
f605b500bbd3
Commenting out lines, to get the code to compile.
Jacob Alexander <triplehaata@gmail.com>
parents:
53
diff
changeset
|
379 //matrix_pinSetup( matrix, scanRow_powrCol, 0, MAX_ROW_SIZE, MAX_COL_SIZE ); TODO |
36
00a06e011158
Pre Tandy1000 overhaul
Jacob Alexander <triplehaata@gmail.com>
parents:
30
diff
changeset
|
380 _delay_us( 1 ); |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
381 col = 1; |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
382 row = 1; |
308 | 383 for ( ; col < (MAX_ROW_SIZE+1); col++ ) for ( ; row < (MAX_COL_SIZE+1); row++ ) |
30
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
384 { |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
385 // Scan over the pins for each of the rows, and using the pin alias to determine which pin to set |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
386 // (e.g. / 10 is for the pin name (A,B,C,etc.) and % 10 is for the position of the pin (A1,A2,etc.)) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
387 switch ( matrix[row*(MAX_ROW_SIZE+1)+0] / 10 ) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
388 { |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
389 #if defined(__AVR_AT90USB1286__) |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
390 case 0: // PINA |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
391 PIN_DUALTEST_ROW(PINA); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
392 #endif |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
393 case 1: // PINB |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
394 PIN_DUALTEST_ROW(PINB); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
395 case 2: // PINC |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
396 PIN_DUALTEST_ROW(PINC); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
397 case 3: // PIND |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
398 PIN_DUALTEST_ROW(PIND); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
399 case 4: // PINE |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
400 PIN_DUALTEST_ROW(PINE); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
401 case 5: // PINF |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
402 PIN_DUALTEST_ROW(PINF); |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
403 } |
91901960eac4
Adding the rest of the matrix scanning modes
Jacob Alexander <triplehaata@gmail.com>
parents:
27
diff
changeset
|
404 } |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
405 #endif |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
406 } |
308 | 407 |