More refactoring to get things in own files to help my understanding

This commit is contained in:
nzkarit
2017-09-07 20:15:28 +12:00
parent 475bc5da83
commit f484c7eb63
4 changed files with 94 additions and 46 deletions
+46
View File
@@ -0,0 +1,46 @@
import numpy
from Encoder import Encoder
class PPM:
"""The PPM class contains functions about PPM manipulation
"""
def frame_1090es_ppm_modulate(self, even, odd):
"""
Args:
even and odd: The bits you would converted to PPM
Returns:
The bytearray of the PPM data
"""
ppm = [ ]
encoder = Encoder()
for i in range(48): # pause
ppm.append( 0 )
ppm.append( 0xA1 ) # preamble
ppm.append( 0x40 )
for i in range(len(even)):
word16 = numpy.packbits(encoder.manchester_encode(~even[i]))
ppm.append(word16[0])
ppm.append(word16[1])
for i in range(100): # pause
ppm.append( 0 )
ppm.append( 0xA1 ) # preamble
ppm.append( 0x40 )
for i in range(len(odd)):
word16 = numpy.packbits(encoder.manchester_encode(~odd[i]))
ppm.append(word16[0])
ppm.append(word16[1])
for i in range(48): # pause
ppm.append( 0 )
#print '[{}]'.format(', '.join(hex(x) for x in ppm))
return bytearray(ppm)