示例#1
0
    def __init__(self, bus, nchan, bright=1.0):
        self.nchans = nchan
        self.nchips = (nchan + 15) // 16
        self.chips = [
            pca9685.PCA9685(bus, 0x40 + k) for k in range(self.nchips)
        ]
        self.curr = [0.0 for v in range(nchan)]

        self.brightness = bright

        self.fade_delta = None  # increment/second for fade
        self.fade_start = None  # absolute time the fade has started
        self.fade_time = None  # nominal fade time in seconds
        self.fade_done = None  # time of fade already processed (in seconds)
    except Exception as e:
        print('Exception occured during load of', mapping_file)
        print('Exception:', e)
        mapping = dict()

    print('')

print('')

bus = smbus.SMBus(0)
chips = list()

for k in range(num_chips):
    # address consecutive from 0x40
    chip = pca9685.PCA9685(bus, 0x40 + k)
    chip.init_chip()
    chips.append(chip)

while True:

    if next_ch is not None and (next_ch > num_ch or next_ch < 0):
        print('Channel', next_ch, 'out of range!')
        next_ch = None

    if next_ch is not None:
        curr_ch = next_ch
        for k in range(num_ch):
            chan_data[k] = 0.0
        chan_data[curr_ch] = 1.0
        next_ch = None