DigitalMeasurement.py
.README.md
extension.json
DigitalMeasurement.py
or AnalogMeasurement.py
pulseCount.py
to see how this was modified for our Pulse Count extension.voltage_peak_to_peak.py
to see how this was modified for an example analog extension.extension.json
file. In our pulseCount.py
example, this is declared like so:def process_data(self, data):
will be called one or more times. This function takes a parameter data
which differs between analog and digital measurements.process_data
is called. Be sure to update the internal state of your class in such a way that this isn't a problem. For example, when computing the average analog value over a range, it would be best to hold the sum of all values passed to process_data
and the total count of samples in data members, and only compute the average in the measure
function.data
is an instance of AnalogData
, which is an iterable
class with the properties sample_count
and samples
. sample_count
is a number, and is the number of analog samples in the data instance. Note - this might not be the total number of analog samples passed to your measurement, since process_data
may be called more than once if the user selected range spans multiple chunks.process_data
function should not return a value. Instead, it should update the internal state of your class, such that the measure
function can produce your measurement's results.data
parameter is an instance of the iterable
Saleae class DigitalData
. Each iteration returns a pair of values - the current time, as a GraphTime
class instance, and the current bit state as a bool
. (True
= signal high).GraphTime
has one feature. One GraphTime
can be subtracted from another to compute the difference in seconds, as a GraphTimeDelta
. GraphTimeDelta
can be converted to a float using float(graph_time_delta)
. This allows your code to compute the time in between transitions, or the time duration between the beginning of the measurement and any transition inside of the measurement range, but it does not expose absolute timestamps.DigitalData
collection will first include the starting time and bit state, and then every transition that exists in the user selected range, if any. It also exposes the starting and ending time of the user-selected measurement range. Consult the API Documentation for details.def measure(self):
function will be called on your class once all data has been passed to process_data
. This will only be called once and should return a dictionary with one key for every requested_measurements
entry that was passed into your class's constructor.requested_measurements
provided by the constructor before computing or returning those values. However, returning measurements that were not requested is allowed. The results will just be ignored.