Update notebook, add frequency meter

This commit is contained in:
jaseg 2021-03-25 12:15:38 +01:00
parent 6fc8f23691
commit 2bb9aecfc6
2 changed files with 2198 additions and 82 deletions

View file

@ -12,11 +12,11 @@ count = lambda le_iter: sum(1 for _ in le_iter)
DEFAULT_SAMPLING_RATE = 1e6 # sps DEFAULT_SAMPLING_RATE = 1e6 # sps
def sigrok_capture(duration:'seconds'=1, sampling_rate=DEFAULT_SAMPLING_RATE, driver='dreamsourcelab-dslogic', config=None, channel=0): def sigrok_capture(duration:'milliseconds', sampling_rate=DEFAULT_SAMPLING_RATE, driver='dreamsourcelab-dslogic', config=None, channel=0):
proc = subprocess.run(['sigrok-cli', proc = subprocess.run(['sigrok-cli',
'--driver', driver, '--driver', driver,
'--time', f'{duration}s', '--time', f'{duration}ms',
'--config', (f'{config},' if config else '') + f'samplerate={int(sampling_rate/1e3)}k', '--config', (f'{config},' if config else '') + f'samplerate={int(sampling_rate/1e3)}k',
'--channels', str(channel), '--channels', str(channel),
'--output-format', 'csv'], check=True, stdout=subprocess.PIPE) '--output-format', 'csv'], check=True, stdout=subprocess.PIPE)
@ -54,7 +54,7 @@ def calc_frequency(intervals, sampling_rate=DEFAULT_SAMPLING_RATE):
if __name__ == '__main__': if __name__ == '__main__':
while True: while True:
capture = sigrok_capture() capture = sigrok_capture(1500)
intervals = list(debounce(capture)) intervals = list(debounce(capture))
intervals = intervals[2:-1] # ignore partial first and last intervals intervals = intervals[2:-1] # ignore partial first and last intervals

File diff suppressed because one or more lines are too long