def run_led_driver(self):
        # master parameters, used in rendering and updated by playlist
        # advancer thread. Time, requested framerate, button state
        masterParams = EffectParameters()

        # Get the appropriate piece of the jar
        model = JarModel(self.jar_id)

        # the controller manages the animation loop - creates frames, calls into the renderer
        # at appropriate intervals, updates the time stored in master params, and sends frames
        # out over OPC
        controller = AnimationController(
            model,
            self.cmd_queue,
            self.resp_queue,
            (DEFAULT_PHOTO, 'colorcycle', 1.0),
            masterParams,
        )
        controller.start()
示例#2
0
文件: soma_client.py 项目: mct/soma
def main(screen, interval):

    # master parameters, used in rendering and updated by playlist advancer thread
    masterParams = EffectParameters()

    # if we got a curses screen, use it for button emulation through the keyboard
    if screen:
        # re-open stdout with a buffer size of 0. this makes print commands work again.
        sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
        screen.clear()
        screen.refresh()

        # put keyboard state into effect parameters
        keymonitor = KeyboardMonitorThread(masterParams, screen)
        keymonitor.start()

    else:
        ButtonMonitorThread(masterParams).start()

    model = SomaModel()  #address_filename="../addresses.txt")

    # a playlist. each entry in a playlist can contain one or more effect layers
    # (if more than one, they are all rendered into the same frame...mixing method
    # is determined by individual effect layers' render implementations)
    playlist = Playlist([

        # This is a very handy layer for debugging.  Steps through LEDs in
        # order of frame index in response to a button push, printing the
        # address of the lit LED.
        #[ControlledAddressTestLayer()],

        #[TriangleWaveLayer()],
        [
            PhotoColorsLayer(model),
            DimBrightButtonLayer(),
            SpeckLayer(button=0),
            SpeckLayer(button=1),
            Lightning(),
            Repair(),
        ],
        [
            MultiplierLayer(ColorWave(model, grayscale=True),
                            ColorWiper(model)),
            Lightning(),
            Repair(),
        ],
        [
            RandomPhaseLayer(model),
            ColorCycleLayer(0.00003, 0.0001),
            Lightning(),
            Repair(),
        ],

        #[
        #   ColorPaletteBattleLayer(model),
        #   Repair(),
        #],
        [
            MorseLayer2([
                "figure", "action", "light", "yang", "synergy",
                "unity in dual", "SOMA"
            ], [
                "ground", "intention", "darkness", "yin", "discord",
                "order from chaos", "FLG"
            ]),
            ColorCycleLayer(0.0003, 0.0005),
            Lightning(),
            Repair(),
        ],
    ])

    # the renderer manages a playlist (or dict of multiple playlists), as well as transitions
    # and gamma correction
    renderer = Renderer(playlists={'all': playlist}, gamma=2.2)

    # the controller manages the animation loop - creates frames, calls into the renderer
    # at appropriate intervals, updates the time stored in master params, and sends frames
    # out over OPC
    controller = AnimationController(model, renderer, masterParams)

    # a thread that periodically advances the active playlist within the renderer.
    # TODO: example to demonstrate swapping between multiple playlists with custom fades

    advancer = PlaylistAdvanceThread(renderer, switchInterval=interval)
    advancer.start()

    # go!
    controller.drawingLoop()
示例#3
0
文件: soma_test.py 项目: mct/soma
def main(screen):

    # master parameters, used in rendering and updated by playlist advancer thread
    masterParams = EffectParameters()

    # if we got a curses screen, use it for button emulation through the keyboard
    if screen:
        # re-open stdout with a buffer size of 0. this makes print commands work again.
        sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
        screen.clear()
        screen.refresh()

        # put keyboard state into effect parameters
        keymonitor = KeyboardMonitorThread(masterParams, screen)
        keymonitor.start()

    # model = SomaModel('../../cad/SomaPointParsing/input_points.json')
    model = SomaModel()

    # a playlist. each entry in a playlist can contain one or more effect layers
    # (if more than one, they are all rendered into the same frame...mixing method
    # is determined by individual effect layers' render implementations)
    playlist = Playlist([
        # [
        #    RandomPhaseLayer(model),
        #    ColorCycleLayer()
        # ],
        # [
        #    ColorPaletteBattleLayer(model)
        # ],
        [
            HolidayColorWiper(model,
                              colors=[(204, 31, 31), (36, 143, 0),
                                      (255, 255, 255)],
                              timer=3)
        ],
        # [
        #PhotoColorsLayer(model),
        # InvertColorsLayer(),
        #InvertColorByRegionLayer(model),
        # ],
        # [
        #     SineWaveLayer(color = (0.2, 0.5, 1)),
        #     # SomaTestLayer(),
        #     # ColorBlinkyLayer(),
        # ],
        # [
        #     PhotoColorsLayer(model),
        #     DimBrightButtonLayer(),

        #     # ColorWave(model),
        #     SpeckLayer(button=0),
        #     SpeckLayer(button=1),

        #     #PhotoColorsLayer(model),
        #     #DimBrightButtonLayer()
        #     #AddressTestLayer(),
        #     #TestPatternLayer(),
        #     #ColorWave(model),
        #     # ColorWiper(model),
        #      # MultiplierLayer(ColorWave(model), ColorWiper(model)),
        # ],
        # [
        # FireflySwarmLayer(),
        # ButtonTestLayer()
        # RandomPhaseLayer(model)
        # MultiplierLayer(AxonChaseLayer(),ColorWave(model))
        # AxonChaseLayer(segments=['all'])
        # ColorWave(model),
        #    ColorWave(model),
        # AxonChaseLayer()
        # ],
        # [
        # AxonChaseLayer(color=(0,1,0), trigger_threshold=0.2, cycle_time=1.5),
        # AxonChaseLayer(color=(0,0,1), trigger_threshold=0.1, cycle_time=1.5),
        # ],
    ])

    # the renderer manages a playlist (or dict of multiple playlists), as well as transitions
    # and gamma correction
    renderer = Renderer(playlists={'all': playlist}, gamma=2.2)

    # the controller manages the animation loop - creates frames, calls into the renderer
    # at appropriate intervals, updates the time stored in master params, and sends frames
    # out over OPC
    controller = AnimationController(model, renderer, masterParams)

    # a thread that periodically advances the active playlist within the renderer.
    # TODO: example to demonstrate swapping between multiple playlists with custom fades
    advancer = PlaylistAdvanceThread(renderer, switchInterval=10)
    advancer.start()

    # go!
    controller.drawingLoop()