first implementation of protobuf
restructure in client server model loads of work still missing
This commit is contained in:
15
ledd/effect/__init__.py
Normal file
15
ledd/effect/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# LEDD Project
|
||||
# Copyright (C) 2015 LEDD Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
24
ledd/effect/baseeffect.py
Normal file
24
ledd/effect/baseeffect.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# LEDD Project
|
||||
# Copyright (C) 2015 LEDD Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class BaseEffect(object):
|
||||
"""
|
||||
This class only defines default meta-data for effect.
|
||||
"""
|
||||
name = "BaseEffect"
|
||||
version = "0.1"
|
||||
author = "LeDD-Freaks"
|
39
ledd/effect/effectstack.py
Normal file
39
ledd/effect/effectstack.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# LEDD Project
|
||||
# Copyright (C) 2015 LEDD Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
|
||||
from ledd.effect.fadeeffect import FadeEffect
|
||||
|
||||
|
||||
class EffectStack(object):
|
||||
def __init__(self):
|
||||
self.stripes = []
|
||||
self.effect = FadeEffect()
|
||||
# TODO
|
||||
self.modifiers = []
|
||||
|
||||
def start(self):
|
||||
asyncio.get_event_loop().call_soon(self.execute)
|
||||
|
||||
def execute(self):
|
||||
color = self.effect.execute_internal()
|
||||
|
||||
for stripe in self.stripes:
|
||||
stripe.set_color(color)
|
||||
|
||||
# schedule next execution
|
||||
asyncio.get_event_loop().call_later(0.1, self.execute)
|
35
ledd/effect/fadeeffect.py
Normal file
35
ledd/effect/fadeeffect.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# LEDD Project
|
||||
# Copyright (C) 2015 LEDD Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import spectra
|
||||
|
||||
from ledd.effect.generatoreffect import GeneratorEffect
|
||||
|
||||
|
||||
class FadeEffect(GeneratorEffect):
|
||||
author = "LeDD-Freaks"
|
||||
version = "0.1"
|
||||
|
||||
name = "Fade Effect"
|
||||
description = "Fades through the HSV color wheel"
|
||||
|
||||
def execute(self):
|
||||
scale = spectra.scale([spectra.hsv(0.0, 1.0, 1.0), spectra.hsv(360.0, 1.0, 1.0)]).domain([0, 20000])
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
yield scale(i)
|
||||
i = (i + 1) % 20000
|
46
ledd/effect/generatoreffect.py
Normal file
46
ledd/effect/generatoreffect.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# LEDD Project
|
||||
# Copyright (C) 2015 LEDD Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from spectra import Color
|
||||
|
||||
from ledd.effect.baseeffect import BaseEffect
|
||||
|
||||
|
||||
class GeneratorEffect(BaseEffect):
|
||||
"""
|
||||
This is a base class for simple effect.
|
||||
It should yield a new color on each execution.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Do not override, use setup instead.
|
||||
"""
|
||||
self.generator = self.execute()
|
||||
|
||||
def setup(self):
|
||||
pass
|
||||
|
||||
def execute_internal(self):
|
||||
c = next(self.generator)
|
||||
assert isinstance(c, Color)
|
||||
return c
|
||||
|
||||
def execute(self):
|
||||
pass
|
||||
|
||||
def tear_down(self):
|
||||
pass
|
Reference in New Issue
Block a user