示例#1
0
文件: tlc5940.py 项目: c-base/antenna
 def pack_2to3(self, inp):
     """
     converts 2 12bit integers to 3 8bit integers
     output bytes: 00000000 00001111 11111111
     """
     if len(inp) != 2:
         logger.error("Input to pack_2to3 should have 2 elements.")
         return []
     inp = [value & 4095 for value in inp]
     return [inp[0] >> 4, (inp[0] << 4) & 255 | inp[1] >> 8, inp[1] & 255]
示例#2
0
文件: tlc5940.py 项目: c-base/antenna
 def pack_4to3(self, inp):
     """
     converts 4 6bit integers to 3 8bit integers
     output bytes: 00000011 11112222 22333333
     """
     if len(inp) != 4:
         logger.error("Input to pack_4to3 should have 4 elements.")
         return []
     inp = [value & 63 for value in inp]
     return [(inp[0] << 2) & 255 | inp[1] >> 4, (inp[1] << 4) & 255 | inp[2] >> 2, (inp[2] << 6) & 255 | inp[3]]