comparison 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
comparison
equal deleted inserted replaced
305:4617ef5e06f1 308:ab4515606277
37 37
38 38
39 // ----- Macros ----- 39 // ----- Macros -----
40 40
41 // -- pinSetup Macros -- 41 // -- pinSetup Macros --
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 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
43 #define REG_UNSET(reg) reg &= ~(1 << ( matrix[row*(MAX_ROW_SIZE+1)+col] % 10 ) ) 43 #define REG_UNSET(reg) reg &= ~(1 << ( matrix[row*(MAX_ROW_SIZE+1)+col] % 10 ) )
44 44
45 #define PIN_SET(pin,scan,direction) \ 45 #define PIN_SET(pin,scan,direction) \
46 switch ( direction ) { \ 46 switch ( direction ) { \
47 case columnSet: PIN_SET_COL(pin,scan); \ 47 case columnSet: PIN_SET_COL(pin,scan); \
55 case scanCol: \ 55 case scanCol: \
56 case scanRow_powrCol: \ 56 case scanRow_powrCol: \
57 case scanDual: \ 57 case scanDual: \
58 REG_SET(port##pin); break; \ 58 REG_SET(port##pin); break; \
59 case scanCol_powrRow: REG_UNSET(ddr##pin); REG_UNSET(DDR##pin); \ 59 case scanCol_powrRow: REG_UNSET(ddr##pin); REG_UNSET(DDR##pin); \
60 REG_SET(port##pin); REG_SET(PORT##pin); break; \ 60 REG_SET(port##pin); REG_SET(PORT##pin); break; \
61 case powrRow: break; \ 61 case powrRow: break; \
62 case powrCol: REG_SET(ddr##pin); REG_SET(DDR##pin); \ 62 case powrCol: REG_SET(ddr##pin); REG_SET(DDR##pin); \
63 REG_SET(port##pin); REG_SET(PORT##pin); break; \ 63 REG_SET(port##pin); REG_SET(PORT##pin); break; \
64 } \ 64 } \
65 break 65 break
70 case scanRow_powrCol: REG_UNSET(ddr##pin); REG_SET(port##pin); break; \ 70 case scanRow_powrCol: REG_UNSET(ddr##pin); REG_SET(port##pin); break; \
71 case scanRow: \ 71 case scanRow: \
72 case scanDual: \ 72 case scanDual: \
73 REG_SET(port##pin); break; \ 73 REG_SET(port##pin); break; \
74 case scanCol_powrRow: REG_SET(ddr##pin); REG_SET(DDR##pin); \ 74 case scanCol_powrRow: REG_SET(ddr##pin); REG_SET(DDR##pin); \
75 REG_UNSET(port##pin); REG_UNSET(PORT##pin); break; \ 75 REG_UNSET(port##pin); REG_UNSET(PORT##pin); break; \
76 case powrRow: REG_SET(ddr##pin); REG_SET(DDR##pin); \ 76 case powrRow: REG_SET(ddr##pin); REG_SET(DDR##pin); \
77 REG_SET(port##pin); REG_SET(PORT##pin); break; \ 77 REG_SET(port##pin); REG_SET(PORT##pin); break; \
78 case powrCol: break; \ 78 case powrCol: break; \
79 } \ 79 } \
80 break 80 break
81 81
82 #define PIN_CASE(pinLetter) \ 82 #define PIN_CASE(pinLetter) \
259 259
260 // Pin Status 260 // Pin Status
261 if ( showDebug == 0 ) // Only show once 261 if ( showDebug == 0 ) // Only show once
262 { 262 {
263 matrix_debugPins(); 263 matrix_debugPins();
264 } 264 }
265 } 265 }
266 266
267 // Scans the given matrix determined by the scanMode method 267 // Scans the given matrix determined by the scanMode method
268 inline void matrix_scan( uint8_t *matrix, uint8_t *detectArray ) 268 inline void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
269 { 269 {
378 // And marking any keys that are detected on the row and column 378 // And marking any keys that are detected on the row and column
379 //matrix_pinSetup( matrix, scanRow_powrCol, 0, MAX_ROW_SIZE, MAX_COL_SIZE ); TODO 379 //matrix_pinSetup( matrix, scanRow_powrCol, 0, MAX_ROW_SIZE, MAX_COL_SIZE ); TODO
380 _delay_us( 1 ); 380 _delay_us( 1 );
381 col = 1; 381 col = 1;
382 row = 1; 382 row = 1;
383 for ( ; col < (MAX_ROW_SIZE+1); col++ ) for ( ; row < (MAX_COL_SIZE+1); row++ ) 383 for ( ; col < (MAX_ROW_SIZE+1); col++ ) for ( ; row < (MAX_COL_SIZE+1); row++ )
384 { 384 {
385 // Scan over the pins for each of the rows, and using the pin alias to determine which pin to set 385 // Scan over the pins for each of the rows, and using the pin alias to determine which pin to set
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.)) 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.))
387 switch ( matrix[row*(MAX_ROW_SIZE+1)+0] / 10 ) 387 switch ( matrix[row*(MAX_ROW_SIZE+1)+0] / 10 )
388 { 388 {
402 PIN_DUALTEST_ROW(PINF); 402 PIN_DUALTEST_ROW(PINF);
403 } 403 }
404 } 404 }
405 #endif 405 #endif
406 } 406 }
407 407