Adding array sizes (fixing the extra key problem)
This commit is contained in:
		
							parent
							
								
									81bb9d772d
								
							
						
					
					
						commit
						1c8c8762ce
					
				
					 1 changed files with 4 additions and 4 deletions
				
			
		
							
								
								
									
										8
									
								
								main.c
									
										
									
									
									
								
							
							
						
						
									
										8
									
								
								main.c
									
										
									
									
									
								
							| 
						 | 
					@ -334,8 +334,8 @@ inline void pinSetup(void)
 | 
				
			||||||
	PORTF = 0xFF;
 | 
						PORTF = 0xFF;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void keyPressDetection( uint8_t *keys, uint8_t *validKeys) {
 | 
					void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys ) {
 | 
				
			||||||
	for ( uint8_t key = 0; key < KEYBOARD_SIZE + 1; key++ ) {
 | 
						for ( uint8_t key = 0; key < numberOfKeys + 1; key++ ) {
 | 
				
			||||||
		if ( keys[key] & (1 << 7) ) {
 | 
							if ( keys[key] & (1 << 7) ) {
 | 
				
			||||||
			pint8( key );
 | 
								pint8( key );
 | 
				
			||||||
			print(" ");
 | 
								print(" ");
 | 
				
			||||||
| 
						 | 
					@ -431,8 +431,8 @@ int main( void )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Detect Valid Keypresses - TODO
 | 
							// Detect Valid Keypresses - TODO
 | 
				
			||||||
		uint8_t validKeys = 0;
 | 
							uint8_t validKeys = 0;
 | 
				
			||||||
		keyPressDetection( keyDetectArray, &validKeys );
 | 
							keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE );
 | 
				
			||||||
		keyPressDetection( keypadDetectArray, &validKeys );
 | 
							keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE );
 | 
				
			||||||
		print(":\n");
 | 
							print(":\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// TODO undo potentially old keys
 | 
							// TODO undo potentially old keys
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue