Cater for the case where another state change occurs while the ISR is running.

Thank you peterhinch
pull/6894/head
Sandor Attila Gerendi 2021-12-30 17:50:12 +02:00 zatwierdzone przez GitHub
rodzic 5366ead756
commit c79be30ca6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -66,11 +66,12 @@ lut_index = 0
def encoder_state_changed_irq_handler(sm): def encoder_state_changed_irq_handler(sm):
global counter, direction, lut_index global counter, direction, lut_index
lut_index |= sm.get() & 3 while sm.rx_fifo():
counter += state_look_up_table[lut_index] lut_index |= sm.get() & 3
if state_look_up_table[lut_index] != 0: counter += state_look_up_table[lut_index]
direction = 1 if (state_look_up_table[lut_index] > 0) else 0 if state_look_up_table[lut_index] != 0:
lut_index = ((lut_index << 2) & 0b1100) | (direction << 4) direction = 1 if (state_look_up_table[lut_index] > 0) else 0
lut_index = ((lut_index << 2) & 0b1100) | (direction << 4)
@rp2.asm_pio() @rp2.asm_pio()