def test_serial(self): # Code taken from # https://gist.github.com/adammhaile/1b43fdde6ae6cbbd35560c68a9b90beb log.setLogLevel(log.DEBUG) devs = Devices(hardware_id="1D50:60AB", baudrate=921600) log.info("Serial devices:") dev_list = devs.find_serial_devices() log.info(dev_list) first_dev = dev_list[list(dev_list.keys())[0]][0] log.info('Default device:') log.info(devs.get_device()) log.info('Device ID for: ' + first_dev) old_id = devs.get_device_id(first_dev) log.info(old_id) log.info('Setting device ID to 42') devs.set_device_id(first_dev, 42, baudrate=921600) log.info('New Device ID for: ' + first_dev) log.info(devs.get_device_id(first_dev)) log.info('Restoring device ID to ' + str(old_id)) devs.set_device_id(first_dev, old_id, baudrate=921600) log.info('Device version for: ' + first_dev) log.info(devs._get_device_version(first_dev)) driver = Serial( LEDTYPE.APA102, 600, SPISpeed=4, c_order=ChannelOrder.RGB) layout = Strip(driver) for b in range(7, 256, 8): log.info('Set brightness ' + str(b)) layout.set_brightness(b) time.sleep(0.25) log.info('Run StripChannelTest') anim = StripChannelTest(layout) anim.run(amt=1, max_steps=8) layout.all_off() layout.update() log.printer("Test Complete!")
def run(args): if not args.ledtype: log.error(NO_LED_ERROR) return -1 log.set_log_level('DEBUG') driver = Serial(ledtype=ledtype.make(args.ledtype), num=10) layout = Strip([driver]) animation = StripChannelTest(layout) animation._set_runner(None) animation.start()
def test_set_individual_colors(self): strip = Strip(MockDriver(4)) strip.set(0, 'red'), strip.set(1, GREEN) strip.set(2, 'hot pink') expected = [RED, GREEN, HOT_PINK, BLACK] self.assertEqual(expected, strip.color_list)
} try: templateData['batteryVoltage'] = round(chanBattery.voltage * 5, 2) templateData['panelVoltage'] = round(chanPanel.voltage * 5, 2) except NameError: print("Ignoring name error") return render_template('index.html', **templateData) ledDriver = SPI(ledtype=app.config['LED_TYPE'], num=app.config['LED_COUNT'], spi_interface='PYDEV', c_order=app.config['CHANNEL_ORDER']) ledStrip = Strip(ledDriver) intVolume = app.config['STARTING_VOLUME'] doorSong = app.config['DOOR_SONG'] setVolume() GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) doorSwitch = app.config['DOOR_SWITCH'] GPIO.setup(doorSwitch, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(doorSwitch,
def test_clone(self): strip = Strip(MockDriver(4)) clone = strip.clone() clone.set(1, RED) self.assertEqual(clone.get(1), RED) self.assertEqual(strip.get(1), BLACK)
def test_set_offset(self): strip = Strip(MockDriver(4)) strip.set_color_list(RED + GREEN, 2) expected = [BLACK, BLACK, RED, GREEN] self.assertEqual(expected, strip.color_list)
def test_set_partial_color(self): strip = Strip(MockDriver(4)) strip.color_list = (RED + GREEN + HOT_PINK + GREEN)[:-1] expected = [RED, GREEN, HOT_PINK, BLACK] self.assertEqual(expected, strip.color_list)
def test_set_too_much_color(self): strip = Strip(MockDriver(4)) strip.color_list = RED + GREEN + HOT_PINK + GREEN + HOT_PINK expected = [RED, GREEN, HOT_PINK, GREEN] self.assertEqual(expected, strip.color_list)
def test_set_linear_color(self): strip = Strip(MockDriver(4)) strip.color_list = RED + GREEN + HOT_PINK expected = [RED, GREEN, HOT_PINK, BLACK] self.assertEqual(expected, strip.color_list)
def test_dummy(self): for driver in Dummy(32), Dummy(32, 0.01): driver.set_project(clock_only_project()) layout = Strip([driver]) layout.push_to_driver()
def test_dummy(self): for driver in Dummy(32), Dummy(32, 0.01): layout = Strip([driver]) layout.push_to_driver()
def __init__(self, driver): super(object, self).__init__() self._led = Strip(driver)
class BiblioPixelLedController(object): # bibliopixel animation for the leds _led = None def __init__(self, driver): super(object, self).__init__() self._led = Strip(driver) def turn_off(self): self._led.all_off() self._led.push_to_driver() self._led.start() def turn_on_color(self, color): self._led.fill(color) self._led.push_to_driver() self._led.start()