pyfastservo adc: Fix find edge bug

- Fix: if frame changed at 31 tap delay, edge would not get detected
This commit is contained in:
linuswck 2024-11-08 12:41:07 +08:00
parent 6cef418756
commit 382e8467d9
1 changed files with 5 additions and 8 deletions

View File

@ -87,21 +87,18 @@ def perform_bitslip():
def find_edge():
prev_frame = read_frame()
transition = False
for tap_delay in range(32):
write_to_memory(ADC_DELAY_ADDR, tap_delay)
current_frame = read_frame()
print(f"Tap delay: {tap_delay}, Current frame: 0x{current_frame:02x}")
print(f"prev_frame: 0x{prev_frame:02x}")
if current_frame != prev_frame:
if not transition:
transition = True
else:
final_delay = (tap_delay // 2) + 2
print(f"Edge detected; setting iDelay to: {final_delay}")
write_to_memory(ADC_DELAY_ADDR, final_delay)
return
final_delay = ((tap_delay+1) // 2) + 2
print(f"Edge detected; setting iDelay to: {final_delay}")
write_to_memory(ADC_DELAY_ADDR, final_delay)
return
prev_frame = current_frame