pyfastservo adc: Fix find edge bug
- Fix: if frame changed at 31 tap delay, edge would not get detected
This commit is contained in:
parent
6cef418756
commit
382e8467d9
|
@ -87,18 +87,15 @@ 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
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue