scanAsync improved
This commit is contained in:
		
							parent
							
								
									c65d505969
								
							
						
					
					
						commit
						69e6e69c77
					
				| @ -67,41 +67,13 @@ void Keyboard::scanAsync() | ||||
|     /** Without delay - scanning only one column per cycle **/ | ||||
|     if (millis() < _timeElapsed + this->_debounce) | ||||
|         return; | ||||
|     uint8_t key = 0; | ||||
|     switch (_current_scan_col) | ||||
|     { | ||||
|         default: | ||||
|             pcf8574->digitalWrite(7, LOW); | ||||
|             _current_scan_col = 1; | ||||
|             break; | ||||
|         case 1: | ||||
|         { | ||||
|     uint8_t key = 4*_current_scan_col; | ||||
|     scanColumn(&key, 1, 4); | ||||
|             pcf8574->digitalWrite(6, LOW);             | ||||
|             pcf8574->digitalWrite(7, HIGH); | ||||
|             _current_scan_col = 2; | ||||
|             break; | ||||
|         } | ||||
|         case 2: | ||||
|         { | ||||
|             key=4; | ||||
|             scanColumn(&key, 1, 4); | ||||
|             pcf8574->digitalWrite(5, LOW);             | ||||
|             pcf8574->digitalWrite(6, HIGH); | ||||
|             _current_scan_col = 3; | ||||
|             break; | ||||
|         } | ||||
|         case 3: | ||||
|         { | ||||
|             key=8; | ||||
|             scanColumn(&key, 1, 4); | ||||
|             pcf8574->digitalWrite(7, LOW);             | ||||
|             pcf8574->digitalWrite(5, HIGH); | ||||
|             _current_scan_col = 1; | ||||
|             break; | ||||
|         } | ||||
|         break; | ||||
|     } | ||||
|     pcf8574->digitalWrite(7-(_current_scan_col+1)%3, LOW); | ||||
|     pcf8574->digitalWrite(7-_current_scan_col, HIGH); | ||||
|     _current_scan_col++;  | ||||
|     if(_current_scan_col>2) | ||||
|         _current_scan_col = 0;   | ||||
| } | ||||
| 
 | ||||
| void Keyboard::scanColumn(uint8_t* key_ptr, uint8_t start, uint8_t stop){ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user