Example #1
0
    def __init__(self, screen, interval):
        self.running = True
        self.screen = screen
        self.interval = interval

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

        # if we got a curses screen, use it for debug input through the keyboard
        if self.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)
            self.screen.clear()
            self.screen.refresh()

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

        points_filename = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                             '..', 'models', 'pulse_pod.json'))
        model = PulseModel(points_filename=points_filename)

        # 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([
            [
              AverageLayer(
                OrbitalLayer(0.0013, 0.0011, 3.0, 5.0, 1, 3.0),
                OrbitalLayer(0.0007, 0.0011, 5.0, 5.0, -1, 5.0),
              )
            ],
        ])

        # 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, self.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=self.interval)
        advancer.start()
        
        # A thread that listens for heartbeats and special effects. Heartbeats information
        # will update the master parameters, which are available to all effect layers.
        # Special effects will be added as the last layer of effects
        pulseListenerThread = PulseListenerThread(self, self.masterParams)
        pulseListenerThread.start()

        
        try:
            controller.drawingLoop()
        except KeyboardInterrupt:
            pulseListenerThread.terminate()
Example #2
0
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()
Example #3
0
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()
Example #4
0
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),
            Repair(),
        ],

        [
            MultiplierLayer(ColorWave(model, grayscale=True), ColorWiper(model)),
            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()
Example #5
0
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()