Revision 12653b5a

View differences:

Makefile
60 60

  
61 61

  
62 62
# MCU name
63
MCU = atmega32u2
63
MCU = atmega32u4
64 64

  
65 65

  
66 66
# Target architecture (see library "Board Types" documentation).
Matrix.h
117 117
volatile uint8_t detectedKeypress[30][3];
118 118
const volatile static uint8_t mapping[19][8][4][2] PROGMEM =
119 119
{
120
 {BLANK, BLANK, BLANK, BLANK,  BLANK, BLANK, BLANK, BLANK}, //a
121
 {QWERTY_LEFT_ALT, BLANK, BLANK, BLANK,  BLANK, BLANK, BLANK, QWERTY_RIGHT_ALT}, //b
122
 {BLANK, BLANK, BLANK, BLANK,  BLANK, QWERTY_MANU, BLANK, BLANK}, //c
123
 {BLANK, BLANK, BLANK, BLANK,  BLANK, BLANK, BLANK, BLANK}, //d
124
 {BLANK, BLANK, QWERTY_F12, BLANK,  BLANK, BLANK, BLANK, BLANK}, //e
125
 {BLANK, BLANK, QWERTY_F11, BLANK,  BLANK, BLANK, BLANK, BLANK}, //f
126
 {QWERTY_F5, QWERTY_ENTER, QWERTY_F10, QWERTY_F9,  BLANK, QWERTY_BACKSPACE, BLANK, QWERTY_SPACE}, //g
127
 {QWERTY_APOSTROPHE_AND_QUOTE, QWERTY_BACKSLASH_AND_PIPE, QWERTY_0_AND_CLOSING_PARENTHESIS, QWERTY_MINUS_AND_UNDERSCORE,  QWERTY_P, QWERTY_OPENING_BRACKET_AND_OPENING_BRACE, QWERTY_SEMICOLON_AND_COLON, QWERTY_SLASH_AND_QUESTION_MARK}, //h
128
 {BLANK, QWERTY_DOT_AND_GREATER_THAN_SIGN, QWERTY_9_AND_OPENING_PARENTHESIS, QWERTY_F8,  QWERTY_O, QWERTY_F7, QWERTY_L, BLANK}, //i
129
 {QWERTY_F6, QWERTY_COMMA_AND_LESS_THAN_SIGN, QWERTY_8_AND_ASTERISK, QWERTY_EQUAL_AND_PLUS,  QWERTY_I, QWERTY_CLOSING_BRACKET_AND_CLOSING_BRACE, QWERTY_K, BLANK}, //j
130
 {QWERTY_H, QWERTY_M, QWERTY_7_AND_AND_AMPERSAND, QWERTY_6_AND_CARET,  QWERTY_U, QWERTY_Y, QWERTY_J, QWERTY_N}, //k
131
 {QWERTY_G, QWERTY_V, QWERTY_4_AND_DOLLAR, QWERTY_5_AND_PERCENTAGE,  QWERTY_R, QWERTY_T, QWERTY_F, QWERTY_B}, //l
132
 {QWERTY_F4, QWERTY_C, QWERTY_3_AND_HASHMARK, QWERTY_F2,  QWERTY_E, QWERTY_F3, QWERTY_D, BLANK}, //m
133
 {QWERTY_NON_US_BACKSLASH_AND_PIPE, QWERTY_X, QWERTY_2_AND_AT, QWERTY_F1,  QWERTY_W, QWERTY_CAPS_LOCK, QWERTY_S, BLANK}, //n
134
 {QWERTY_ESCAPE, QWERTY_Z, QWERTY_1_AND_EXCLAMATION, QWERTY_GRAVE_ACCENT_AND_TILDE,  QWERTY_Q, QWERTY_TAB, QWERTY_A, BLANK}, //o
135
 {BLANK, QWERTY_RIGHT_SHIFT, BLANK, BLANK,  BLANK, QWERTY_LEFT_SHIFT, BLANK, BLANK}, //p
136
 {BLANK, QWERTY_RIGHT_CONTROL, BLANK, QWERTY_LEFT_CONTROL,  BLANK, BLANK, BLANK, BLANK}, //q
137
 {QWERTY_LEFT_GUI, BLANK, BLANK, BLANK,  BLANK, BLANK, BLANK, BLANK}, //r
138
 {BLANK, BLANK, BLANK, BLANK,  BLANK, BLANK, BLANK, QWERTY_RIGHT_GUI} //s
120
 // TODO
121
 {BLANK, BLANK, BLANK, BLANK, /**/BLANK, QWERTY_MANU, BLANK, BLANK}, //a
122
 {QWERTY_G, QWERTY_V, QWERTY_4_AND_DOLLAR, QWERTY_5_AND_PERCENTAGE, /**/QWERTY_R, QWERTY_T, QWERTY_F, QWERTY_B}, //b
123
 {QWERTY_F4, QWERTY_C, QWERTY_3_AND_HASHMARK, QWERTY_F2, /**/QWERTY_E, QWERTY_F3, QWERTY_D, BLANK}, //c
124
 {QWERTY_NON_US_BACKSLASH_AND_PIPE, QWERTY_X, QWERTY_2_AND_AT, QWERTY_F1, /**/QWERTY_W, QWERTY_CAPS_LOCK, QWERTY_S, BLANK}, //d
125
 {QWERTY_ESCAPE, QWERTY_Z, QWERTY_1_AND_EXCLAMATION, QWERTY_GRAVE_ACCENT_AND_TILDE, /**/QWERTY_Q, QWERTY_TAB, QWERTY_A, BLANK}, //e
126
 {BLANK, QWERTY_RIGHT_SHIFT, BLANK, BLANK, /**/BLANK, QWERTY_LEFT_SHIFT, BLANK, BLANK}, //f
127
 {BLANK, QWERTY_RIGHT_CONTROL, BLANK, BLANK, /**/QWERTY_LEFT_CONTROL, BLANK, BLANK, BLANK}, //g
128
 {QWERTY_LEFT_GUI, BLANK, BLANK, BLANK, /**/BLANK, BLANK, BLANK, BLANK}, //h
129
 {BLANK, BLANK, BLANK, BLANK, /**/BLANK, BLANK, BLANK, QWERTY_RIGHT_GUI}, //i
130
 {BLANK, BLANK, BLANK, BLANK, /**/BLANK, BLANK, BLANK, BLANK}, //j
131
 {BLANK, BLANK, QWERTY_F12, BLANK, /**/BLANK, BLANK, BLANK, BLANK/*right*/}, //k
132
 {BLANK, BLANK, QWERTY_F11, BLANK, /**/BLANK, BLANK, BLANK, BLANK/*down*/}, //l
133
 {QWERTY_F5, QWERTY_ENTER, QWERTY_F10, QWERTY_F9, /**/BLANK, QWERTY_BACKSPACE, BLANK, QWERTY_SPACE}, //m
134
 {QWERTY_APOSTROPHE_AND_QUOTE, QWERTY_BACKSLASH_AND_PIPE, QWERTY_0_AND_CLOSING_PARENTHESIS, QWERTY_MINUS_AND_UNDERSCORE, /**/QWERTY_P, QWERTY_OPENING_BRACKET_AND_OPENING_BRACE, QWERTY_SEMICOLON_AND_COLON, QWERTY_SLASH_AND_QUESTION_MARK}, //n
135
 {BLANK, QWERTY_DOT_AND_GREATER_THAN_SIGN, QWERTY_9_AND_OPENING_PARENTHESIS, QWERTY_F8, /**/QWERTY_O, QWERTY_F7, QWERTY_L, BLANK}, //o
136
 {QWERTY_F6, QWERTY_COMMA_AND_LESS_THAN_SIGN, QWERTY_8_AND_ASTERISK, QWERTY_EQUAL_AND_PLUS, /**/QWERTY_I, QWERTY_CLOSING_BRACKET_AND_CLOSING_BRACE, QWERTY_K, BLANK}, //p
137
 {QWERTY_H, QWERTY_M, QWERTY_7_AND_AND_AMPERSAND, QWERTY_6_AND_CARET, /**/QWERTY_U, QWERTY_Y, QWERTY_J, QWERTY_N}, //q
138
 {BLANK/*up*/, BLANK, BLANK, BLANK, /**/BLANK, QWERTY_MANU, BLANK, BLANK /*left*/}, //r
139
 {QWERTY_LEFT_ALT, BLANK, BLANK, BLANK, /**/BLANK, BLANK, BLANK, QWERTY_RIGHT_ALT} //s
139 140
};
140 141
#undef key
141 142

  
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
}
MatrixScan.h
7 7

  
8 8
#define SHIFTREGPORT PORTC
9 9
#define SHIFTREGDDR DDRC
10
#define SRDATAPIN PC7
11
#define SRCLKPIN PC6
10
#define SRDATAPIN PC6
11
#define SRCLKPIN PC7
12

  
13
#define SHIFTREGRESETPORT PORTE
14
#define SHIFTREGRESETDDR DDRE
15
#define SHIFTREGRESETPIN PE6
16

  
12 17
#define DATAINPORT PORTB
13 18
#define DATAINPIN PINB
14 19
#define DATAINDDR DDRB

Also available in: Unified diff