Revision 12653b5a MatrixScan.c

View differences:

MatrixScan.c
4 4
	// TODO
5 5
	// setup input pins
6 6
	DATAINDDR = ((0<<DIN_7) | (0<<DIN_6) | (0<<DIN_5) | (0<<DIN_4) | (0<<DIN_3) | (0<<DIN_2) | (0<<DIN_1) | (0<<DIN_0));
7
	// setup shift register
7
	// setup shift register clock and data lines
8 8
	SHIFTREGDDR |= (1<<SRCLKPIN) | (1<<SRDATAPIN);
9
	// setup reset line for shiftregisters
10
	SHIFTREGRESETDDR |= (1<<SHIFTREGRESETPIN);
11
	SHIFTREGRESETPORT |= (1<<SHIFTREGRESETPIN);
9 12
	clearSR();
10 13
}
11 14

  
......
27 30
}  
28 31

  
29 32
void clearSR(){
30
	for(uint8_t i = 0; i < 21; i++){
33
	//SHIFTREGPORT &= ~(1<<SHIFTREGRESETPIN);
34
	//_delay_us(1);
35
	//SHIFTREGPORT |= (1<<SHIFTREGRESETPIN);
36
	for(uint8_t i = 0; i < 25; i++){
31 37
		pushBit(0);
32 38
	}
33 39
}
......
64 70
}
65 71

  
66 72
void setReportData(USB_KeyboardReport_Data_t* const ReportData){
73
//	// push initial 1
74
//	pushBit(1);
75
//	//for(uint8_t i = 0; i < 7; i++){
76
//	//        pushBit(0); // to get the 1 on the first output
77
//	//}
78
//	// scan matrix
79
//	uint8_t somethingPressed = 0;
80
//	for(uint8_t i = 0; i < 19; i++){
81
//		_delay_us(100);
82
//		matrixState[i] = DATAINPIN;
83
//		if(matrixState[i] != 0){
84
//			ReportData->KeyCode[0] = HID_KEYBOARD_SC_A + i;
85
//			for(uint8_t bit = 0; bit < 8; bit++){
86
//				if(matrixState[i] & (1<<bit)){
87
//					ReportData->KeyCode[1] = HID_KEYBOARD_SC_1_AND_EXCLAMATION + bit;
88
//				}
89
//			}
90
//		}
91
//		pushBit(0);
92
//	}
93
//	// set mods (check if >= 0xe0)
94
//	clearSR();
95
//	return;
96

  
97

  
98

  
67 99
	// push initial 1
68 100
	pushBit(1);
69
	pushBit(0); // to get the 1 on the first output
70 101
	// set afterglow before we miss it later in case of ghosting
71 102
	ReportData->Modifier |= modAfterglow;
72 103
	modAfterglow = 0;
......
168 199
			}
169 200
		}
170 201
	}
202
	clearSR();
171 203
	return;
172 204
}

Also available in: Unified diff