import sigrokdecode as srd
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 3
id = 'pwm'
)
def __init__(self):
+ self.reset()
+
+ def reset(self):
+ self.samplerate = None
self.ss_block = self.es_block = None
def metadata(self, key, value):
self.put(self.ss_block, self.es_block, self.out_binary, data)
def decode(self):
+ if not self.samplerate:
+ raise SamplerateError('Cannot decode without samplerate.')
+
num_cycles = 0
average = 0
# Get the next two edges. Setup some variables that get
# referenced in the calculation and in put() routines.
start_samplenum = self.samplenum
- pins = self.wait({0: 'e'})
+ self.wait({0: 'e'})
end_samplenum = self.samplenum
- pins = self.wait({0: 'e'})
+ self.wait({0: 'e'})
self.ss_block = start_samplenum
self.es_block = self.samplenum