修正位置最高位值要取反
This commit is contained in:
+33
-1
@@ -99,6 +99,7 @@ class Decoder(srd.Decoder):
|
||||
self.yv_cnt = 0 #y坐标校验累积的数据位个数
|
||||
self.yv_first = 0 #y坐标校验起始位置
|
||||
self.state = 'HEADER' #当前处理的字段
|
||||
self.state2 = 'FIND START' #当前处理的字段
|
||||
self.data = 0 #存放坐标值数据
|
||||
self.highpin = 0 #当前采样宽度(78.125ns)内高电平数量
|
||||
self.lowpin = 0 #当前采样宽度(78.125ns)内低电平数量
|
||||
@@ -126,13 +127,16 @@ class Decoder(srd.Decoder):
|
||||
if self.state == 'HEADER':
|
||||
self.header_str += str(bit)
|
||||
self.head_cnt = self.head_cnt+1
|
||||
if self.head_cnt == 8:
|
||||
if self.head_cnt == 6:
|
||||
self.put(self.header_first, es, self.out_ann,[2, ['HEADER_x:' + self.header_str]])
|
||||
self.state = 'xpos'
|
||||
self.xpos_first = es
|
||||
self.xpos_cnt = 0 #当前坐标 位数归零,准备累积
|
||||
self.data = 0 #当前坐标值归零,准备开始累积
|
||||
elif self.state == 'xpos':
|
||||
if self.xpos_cnt == 19:
|
||||
self.data = ((not bit) << self.xpos_cnt) | self.data
|
||||
else:
|
||||
self.data = (bit << self.xpos_cnt) | self.data
|
||||
self.xpos_cnt = self.xpos_cnt+1
|
||||
if self.xpos_cnt == 20:
|
||||
@@ -162,6 +166,9 @@ class Decoder(srd.Decoder):
|
||||
self.ypos_cnt = 0 #当前坐标 位数归零,准备累积
|
||||
self.data = 0 #当前坐标值归零,准备开始累积
|
||||
elif self.state == 'ypos':
|
||||
if self.ypos_cnt == 19:
|
||||
self.data = ((not bit) << self.ypos_cnt) | self.data
|
||||
else:
|
||||
self.data = (bit << self.ypos_cnt) | self.data
|
||||
self.ypos_cnt = self.ypos_cnt+1
|
||||
if self.ypos_cnt == 20:
|
||||
@@ -178,6 +185,7 @@ class Decoder(srd.Decoder):
|
||||
if self.yv_cnt == 4:
|
||||
self.put(self.yv_first, es, self.out_ann,[9, ['y校验:' + self.yv_str]])
|
||||
self.state = 'HEADER'
|
||||
self.state2 = 'FIND START'
|
||||
self.header_first = es
|
||||
self.head_cnt = 0
|
||||
self.header_str = ""
|
||||
@@ -223,6 +231,30 @@ class Decoder(srd.Decoder):
|
||||
self.lowpin = 0 #当前采样宽度(78.125ns)内低电平数量
|
||||
|
||||
while True:
|
||||
if self.state2 == 'FIND START':
|
||||
#self.file.write('FIND START'+ '\n')
|
||||
self.wait({0: 'l'})
|
||||
self.oldsamplenum = self.samplenum
|
||||
self.state2 = 'FIND START2'
|
||||
if self.state2 == 'FIND START2':
|
||||
#self.file.write('FIND START2'+ '\n')
|
||||
self.wait({0: 'r'})
|
||||
start_width = self.samplenum - self.oldsamplenum
|
||||
self.oldsamplenum = self.samplenum
|
||||
if start_width >= self.bit_width*2.2:
|
||||
self.state2 = 'FIND START3'
|
||||
else:
|
||||
self.state2 = 'FIND START'
|
||||
if self.state2 == 'FIND START3':
|
||||
#self.file.write('FIND START3'+ '\n')
|
||||
(pin,) = self.wait({0:'n'})
|
||||
#当前已经累积的采样宽度
|
||||
total_width = self.samplenum - self.oldsamplenum
|
||||
if total_width>=self.bit_width : #累积采样宽度接近设置的采样次数
|
||||
self.state2 = 'FIND DATA'
|
||||
self.oldsamplenum = self.samplenum
|
||||
if self.state2 == 'FIND DATA':
|
||||
#self.file.write('FIND DATA'+ '\n')
|
||||
(pin,) = self.wait({0:'n'})
|
||||
#当前已经累积的采样宽度
|
||||
total_width = self.samplenum - self.oldsamplenum
|
||||
|
||||
Reference in New Issue
Block a user