forked from mirrors/qmk_userspace
		
	Fix a potential bug in encoder_init(). (#16372)
After executing `setPinInputHigh(pin)`, it is necessary to wait for the charging time to read from the corresponding pin. This is the same as requiring `matrix_output_unselect_delay()` after doing `unselect_row()` in matrix.c.
This commit is contained in:
		
					parent
					
						
							
								ae5f43072f
							
						
					
				
			
			
				commit
				
					
						b1de11c275
					
				
			
		
					 1 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
					@ -59,6 +59,8 @@ static uint8_t thisHand, thatHand;
 | 
				
			||||||
static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
 | 
					static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__attribute__((weak)) void encoder_wait_pullup_charge(void) { wait_us(100); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; }
 | 
					__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); }
 | 
					__attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); }
 | 
				
			||||||
| 
						 | 
					@ -84,7 +86,9 @@ void encoder_init(void) {
 | 
				
			||||||
    for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
 | 
					    for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
 | 
				
			||||||
        setPinInputHigh(encoders_pad_a[i]);
 | 
					        setPinInputHigh(encoders_pad_a[i]);
 | 
				
			||||||
        setPinInputHigh(encoders_pad_b[i]);
 | 
					        setPinInputHigh(encoders_pad_b[i]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    encoder_wait_pullup_charge();
 | 
				
			||||||
 | 
					    for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
 | 
				
			||||||
        encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
 | 
					        encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue