From 22f7d1a81e563baca7a44d3bafd93da6ae08dd4b Mon Sep 17 00:00:00 2001 From: Jonathan Hogg Date: Wed, 1 Jul 2020 19:31:18 +0100 Subject: [PATCH] Use timestamps starting at 0 and record scope time as `capture_start` in the series data --- scope.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scope.py b/scope.py index 3ab7a3a..a5ba945 100755 --- a/scope.py +++ b/scope.py @@ -302,7 +302,8 @@ class Scope(vm.VirtualMachine): address -= address % 2 traces = DotDict() - timestamps = array.array('d', (t*self.master_clock_period for t in range(0, timestamp, ticks*clock_scale))) + + timestamps = array.array('d', (i * sample_period for i in range(nsamples))) for dump_channel, channel in enumerate(sorted(analog_channels)): asamples = nsamples // len(analog_channels) async with self.transaction(): @@ -314,7 +315,7 @@ class Scope(vm.VirtualMachine): value_multiplier, value_offset = (1, 0) if raw else (high-low, low-analog_params.ab_offset/2*(1 if channel == 'A' else -1)) data = await self.read_analog_samples(asamples, capture_mode.sample_width) series = DotDict({'channel': channel, - 'start_timestamp': start_timestamp, + 'capture_start': start_timestamp * self.master_clock_period, 'timestamps': timestamps[dump_channel::len(analog_channels)] if len(analog_channels) > 1 else timestamps, 'samples': array.array('f', (value*value_multiplier+value_offset for value in data)), 'sample_period': sample_period*len(analog_channels), @@ -336,7 +337,7 @@ class Scope(vm.VirtualMachine): mask = 1 << i channel = f'L{i}' series = DotDict({'channel': channel, - 'start_timestamp': start_timestamp, + 'capture_start': start_timestamp * self.master_clock_period, 'timestamps': timestamps, 'samples': array.array('B', (1 if value & mask else 0 for value in data)), 'sample_period': sample_period,