diff --git a/ledd/controller.py b/ledd/controller.py
index 2850f6c..d13321c 100644
--- a/ledd/controller.py
+++ b/ledd/controller.py
@@ -14,13 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+import errno
import logging
import time
-import errno
+import smbus
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship, reconstructor
-import smbus
from . import Base
@@ -51,7 +51,7 @@ class Controller(Base):
i2c_device = Column(Integer)
address = Column(String)
stripes = relationship("Stripe", backref="controller")
- _pwm_freq = Column("pwm_freq", Integer)
+ pwm_freq = Column("pwm_freq", Integer)
"""
A controller controls a number of stripes.
@@ -62,12 +62,14 @@ class Controller(Base):
self._mode = None
self.bus = smbus.SMBus(self.i2c_device)
self._address = int(self.address, 16)
+ self._pwm_freq = self.pwm_freq
@reconstructor
def init_on_load(self):
self._mode = None
self.bus = smbus.SMBus(self.i2c_device)
self._address = int(self.address, 16)
+ self._pwm_freq = self.pwm_freq
def __repr__(self):
return "".format(len(self.stripes), self.id)
@@ -141,3 +143,6 @@ class Controller(Base):
'i2c_device': self.i2c_device,
'mode': self.mode
}
+
+ def close(self):
+ self.bus.close()
diff --git a/ledd/daemon.py b/ledd/daemon.py
index 62687d5..016ae69 100644
--- a/ledd/daemon.py
+++ b/ledd/daemon.py
@@ -14,26 +14,26 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-import logging
-import configparser
-import os
-import sys
import asyncio
-import signal
+import configparser
import errno
+import logging
+import os
+import signal
+import sys
-from sqlalchemy import create_engine
+import spectra
from jsonrpc import JSONRPCResponseManager, dispatcher
from jsonrpc.exceptions import JSONRPCError, JSONRPCInvalidParams
-import spectra
+from sqlalchemy import create_engine
from sqlalchemy.exc import OperationalError
from sqlalchemy.orm.exc import NoResultFound
from ledd import VERSION
+from ledd.controller import Controller
from ledd.effectstack import EffectStack
from ledd.models import Meta
from ledd.stripe import Stripe
-from ledd.controller import Controller
from . import Base, session
log = logging.getLogger(__name__)
@@ -94,6 +94,10 @@ def run():
loop.run_forever()
except (KeyboardInterrupt, SystemExit):
log.info("Exiting")
+
+ for c in controller:
+ c.close()
+
try:
os.remove("ledd.pid")
except FileNotFoundError:
@@ -138,6 +142,7 @@ def start_effect(**kwargs):
"""
Part of the Color API. Used to start a specific effect.
Required parameters: stripe IDs: sids; effect id: eid, effect options: eopt
+ :param kwargs:
"""
if "sids" not in kwargs or "eid" not in kwargs or "eopt" not in kwargs:
diff --git a/ledd/effectstack.py b/ledd/effectstack.py
index 6100135..0b8e029 100644
--- a/ledd/effectstack.py
+++ b/ledd/effectstack.py
@@ -1,3 +1,19 @@
+# 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 .
+
import asyncio
from ledd.effects.fadeeffect import FadeEffect