def encode_bits(data, number):
    """Turn bits into n bytes of modulation patterns"""
    # 0000 00BA gets encoded as:
    # 128 64 32 16  8  4  2  1
    #   1  B  B  0  1  A  A  0
    # i.e. a 0 is a short pulse, a 1 is a long pulse
    #print("modulate_bits %s (%s)" % (ashex(data), str(number)))

    shift = 2-number
    encoded = []
    for i in range(number/2):
        bits = (data >> shift) & 0x03
        #print("    shift %d bits %d" % (shift, bits))
        encoded.append(ENCODER[bits])
        shift -= 2
    #print("  returns:%s" % ashex(encoded))
    return encoded


# END
dataset/ETHPy150Open whaleygeek/pyenergenie/src/energenie/encoder.py/encode_bits/swapped operands of `-`