summaryrefslogtreecommitdiff
path: root/decoders/em4100/pd.py
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2015-12-18 17:42:16 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2015-12-18 18:23:18 +0100
commit91ae892dcb8637961fc52cc8b528e1f77bec3a53 (patch)
treea1429b740adcc604abe5fa0026c49902213068d6 /decoders/em4100/pd.py
parent13090f246f88ecea35afd43e3ada0dda061f6994 (diff)
downloadlibsigrokdecode-91ae892dcb8637961fc52cc8b528e1f77bec3a53.tar.gz
libsigrokdecode-91ae892dcb8637961fc52cc8b528e1f77bec3a53.zip
em4100: Simplify the code a bit.
Diffstat (limited to 'decoders/em4100/pd.py')
-rw-r--r--decoders/em4100/pd.py32
1 files changed, 8 insertions, 24 deletions
diff --git a/decoders/em4100/pd.py b/decoders/em4100/pd.py
index d9b62a5..d1a7ba3 100644
--- a/decoders/em4100/pd.py
+++ b/decoders/em4100/pd.py
@@ -98,7 +98,8 @@ class Decoder(srd.Decoder):
def start(self):
self.out_ann = self.register(srd.OUTPUT_ANN)
- def add_bit(self, bit, ss, es):
+ def putbit(self, bit, ss, es):
+ self.put(ss, es, self.out_ann, [0, [str(bit)]])
if self.state == 'HEADER':
if bit == 1:
if self.first_one > 0:
@@ -185,40 +186,25 @@ class Decoder(srd.Decoder):
self.col_parity_pos = []
self.all_row_parity_ok = True
- def putbit(self, bit, ss, es):
- self.put(ss, es, self.out_ann, [0, [str(bit)]])
- self.add_bit(bit, ss, es)
-
def manchester_decode(self, samplenum, pl, pp, pin):
- ss, es = 0, 0
bit = self.oldpin ^ self.polarity
if pl > self.halfbit_limit:
- samples = samplenum - self.oldsamplenum
- t = samples / self.samplerate
-
+ es = int(samplenum - pl/2)
if self.oldpl > self.halfbit_limit:
ss = int(self.oldsamplenum - self.oldpl/2)
- es = int(samplenum - pl/2)
- self.putbit(bit, ss, es)
- if self.oldpl <= self.halfbit_limit:
+ else:
ss = int(self.oldsamplenum - self.oldpl)
- es = int(samplenum - pl/2)
- self.putbit(bit, ss, es)
+ self.putbit(bit, ss, es)
self.last_bit_pos = int(samplenum - pl/2)
-
- if pl < self.halfbit_limit:
- samples = samplenum - self.oldsamplenum
- t = samples / self.samplerate
-
+ else:
+ es = int(samplenum)
if self.oldpl > self.halfbit_limit:
ss = int(self.oldsamplenum - self.oldpl/2)
- es = int(samplenum)
self.putbit(bit, ss, es)
self.last_bit_pos = int(samplenum)
- if self.oldpl <= self.halfbit_limit:
+ else:
if self.last_bit_pos <= self.oldsamplenum - self.oldpl:
ss = int(self.oldsamplenum - self.oldpl)
- es = int(samplenum)
self.putbit(bit, ss, es)
self.last_bit_pos = int(samplenum)
@@ -244,9 +230,7 @@ class Decoder(srd.Decoder):
if self.oldpin != pin:
pl = samplenum - self.oldsamplenum
pp = pin
-
self.manchester_decode(samplenum, pl, pp, pin)
-
self.oldpl = pl
self.oldpp = pp
self.oldsamplenum = samplenum