Quote:Is there a Python library that will handle this for meLuckily, this isn't javascript. We don't have a repository of functions that are only two lines each.
Try this: create a list of 8 items, and set all of them to zero. Each item in your list of solenoids you want on, is then the index, so just set it to one.
Something like this:
>>> def bitmap(on_solenoids): ... bits = [0 for _ in range(8)] ... for solenoid in on_solenoids: ... bits[solenoid] = 1 ... return bits ... >>> bitmap([1, 3, 4, 7]) [0, 1, 0, 0, 1, 1, 0, 1]