summaryrefslogtreecommitdiff
authorDustin Frisch <dustin@dustin-frisch.de>2011-03-05 18:17:28 (GMT)
committer Dustin Frisch <dustin@dustin-frisch.de>2011-03-05 18:17:28 (GMT)
commit32a104bb7b39f9c9713b69e98a6786b20832bfce (patch) (side-by-side diff)
tree0d28414b7cd9191958fde3b81e99b6ea4d7d913e
downloadmood-32a104bb7b39f9c9713b69e98a6786b20832bfce.zip
mood-32a104bb7b39f9c9713b69e98a6786b20832bfce.tar.gz
Initial importHEADmaster
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mood-cli/.project17
-rw-r--r--mood-cli/.pydevproject13
-rw-r--r--mood-cli/src/mood_cli.py26
-rw-r--r--mood-gui/.project17
-rw-r--r--mood-gui/.pydevproject13
-rw-r--r--mood-gui/src/main_window.glade232
-rw-r--r--mood-gui/src/mood_gui.py106
-rw-r--r--mood-sine/.project17
-rw-r--r--mood-sine/.pydevproject13
-rw-r--r--mood-sine/src/mood_sine.py42
-rw-r--r--mood/.project17
-rw-r--r--mood/.pydevproject10
-rw-r--r--mood/src/mood/Animation.py85
-rw-r--r--mood/src/mood/Animation.pycbin0 -> 3075 bytes
-rw-r--r--mood/src/mood/Color.py33
-rw-r--r--mood/src/mood/Color.pycbin0 -> 1539 bytes
-rw-r--r--mood/src/mood/Light.py42
-rw-r--r--mood/src/mood/Light.pycbin0 -> 1799 bytes
-rw-r--r--mood/src/mood/Line.py50
-rw-r--r--mood/src/mood/Line.pycbin0 -> 2083 bytes
-rw-r--r--mood/src/mood/Packet.py20
-rw-r--r--mood/src/mood/Packet.pycbin0 -> 1015 bytes
-rw-r--r--mood/src/mood/__init__.py8
-rw-r--r--mood/src/mood/__init__.pycbin0 -> 466 bytes
24 files changed, 761 insertions, 0 deletions
diff --git a/mood-cli/.project b/mood-cli/.project
new file mode 100644
index 0000000..ac9a211
--- a/dev/null
+++ b/mood-cli/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mood-cli</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.python.pydev.pythonNature</nature>
+ </natures>
+</projectDescription>
diff --git a/mood-cli/.pydevproject b/mood-cli/.pydevproject
new file mode 100644
index 0000000..43d2404
--- a/dev/null
+++ b/mood-cli/.pydevproject
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/mood-cli/src</path>
+</pydev_pathproperty>
+<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
+<path>/home/dustin/workspaces/python/mood/src</path>
+</pydev_pathproperty>
+</pydev_project>
diff --git a/mood-cli/src/mood_cli.py b/mood-cli/src/mood_cli.py
new file mode 100644
index 0000000..1820f84
--- a/dev/null
+++ b/mood-cli/src/mood_cli.py
@@ -0,0 +1,26 @@
+import sys
+import mood
+
+if __name__ == '__main__':
+ if len(sys.argv) != 6:
+ print 'Usage mood_ctrl PORT ID RR GG BB'
+ print ' PORT The port to connect to'
+ print ' ID The ID of the board to select (1 byte hex)'
+ print ' RR The value of the red light (1 by te hex)'
+ print ' GG The value of the green light (1 by te hex)'
+ print ' BB The value of the blue light (1 by te hex)'
+ sys.exit(1)
+
+ port = sys.argv[1]
+
+ id = int(sys.argv[2], 16)
+
+ r = int(sys.argv[3], 16)
+ g = int(sys.argv[4], 16)
+ b = int(sys.argv[5], 16)
+
+ color = mood.Color(r, g, b)
+
+ line = mood.Line(port, 5)
+ line[id].color = color
+
diff --git a/mood-gui/.project b/mood-gui/.project
new file mode 100644
index 0000000..aeac2fd
--- a/dev/null
+++ b/mood-gui/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mod-gui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.python.pydev.pythonNature</nature>
+ </natures>
+</projectDescription>
diff --git a/mood-gui/.pydevproject b/mood-gui/.pydevproject
new file mode 100644
index 0000000..dcbbe06
--- a/dev/null
+++ b/mood-gui/.pydevproject
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/mod-gui/src</path>
+</pydev_pathproperty>
+<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
+<path>/home/dustin/workspaces/python/mood/src</path>
+</pydev_pathproperty>
+</pydev_project>
diff --git a/mood-gui/src/main_window.glade b/mood-gui/src/main_window.glade
new file mode 100644
index 0000000..addbeaa
--- a/dev/null
+++ b/mood-gui/src/main_window.glade
@@ -0,0 +1,232 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <!-- interface-local-resource-path /home/dustin/workspaces/python/mod-gui -->
+ <object class="GtkWindow" id="main_window">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Mood</property>
+ <signal name="destroy" handler="on_main_window_destroy"/>
+ <signal name="delete_event" handler="on_main_window_delete_event"/>
+ <child>
+ <object class="GtkVBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">3</property>
+ <child>
+ <object class="GtkFrame" id="frame_info">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkTable" id="table_info">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">3</property>
+ <property name="row_spacing">3</property>
+ <child>
+ <object class="GtkLabel" id="label_port">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Port:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_id">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">ID:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_port">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x25CF;</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_id">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">&#x25CF;</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_info">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Info</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox">
+ <property name="visible">True</property>
+ <property name="spacing">3</property>
+ <child>
+ <object class="GtkFrame" id="frame_r">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkVScale" id="vscale_r">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_r</property>
+ <property name="inverted">True</property>
+ <property name="show_fill_level">True</property>
+ <property name="value_pos">bottom</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_r">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Red</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame_g">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkVScale" id="vscale_g">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_g</property>
+ <property name="inverted">True</property>
+ <property name="show_fill_level">True</property>
+ <property name="value_pos">bottom</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_g">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Green</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame_b">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkVScale" id="vscale_b">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="orientation">vertical</property>
+ <property name="adjustment">adjustment_b</property>
+ <property name="inverted">True</property>
+ <property name="show_fill_level">True</property>
+ <property name="value_pos">bottom</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_b">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Blue</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame_color">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <object class="GtkColorSelection" id="colorselection">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="has_palette">True</property>
+ <property name="current_color">#000000000000</property>
+ <signal name="color_changed" handler="on_colorselection_color_changed"/>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label_color">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Color</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkAdjustment" id="adjustment_g">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ <signal name="value_changed" handler="on_adjustment_g_value_changed"/>
+ </object>
+ <object class="GtkAdjustment" id="adjustment_b">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ <signal name="value_changed" handler="on_adjustment_b_value_changed"/>
+ </object>
+ <object class="GtkAdjustment" id="adjustment_r">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ <signal name="value_changed" handler="on_adjustment_r_value_changed"/>
+ </object>
+</interface>
diff --git a/mood-gui/src/mood_gui.py b/mood-gui/src/mood_gui.py
new file mode 100644
index 0000000..d54a4a7
--- a/dev/null
+++ b/mood-gui/src/mood_gui.py
@@ -0,0 +1,106 @@
+import sys
+import mood
+
+import gtk.gdk
+
+class MainWindow():
+
+ def __init__(self, port, id):
+ self.__port = port
+ self.__id = id
+
+ self.__line = mood.Line(port, 1)
+
+ self.__init()
+
+
+ def __init(self):
+ self.__builder = gtk.Builder()
+ self.__builder.add_from_file("main_window.glade")
+
+ self.__builder.connect_signals({"on_main_window_destroy" : self.__on_destroy,
+ "on_main_window_delete_event" : self.__on_delete_event,
+ "on_adjustment_r_value_changed" : self.__on_adjustment_value_changed,
+ "on_adjustment_g_value_changed" : self.__on_adjustment_value_changed,
+ "on_adjustment_b_value_changed" : self.__on_adjustment_value_changed,
+ "on_colorselection_color_changed" : self.__on_colorselection_color_changed,
+ })
+
+ self.__window = self.__builder.get_object("main_window")
+ self.__adjustment_r = self.__builder.get_object("adjustment_r")
+ self.__adjustment_g = self.__builder.get_object("adjustment_g")
+ self.__adjustment_b = self.__builder.get_object("adjustment_b")
+ self.__colorselection = self.__builder.get_object("colorselection")
+ self.__entry_port = self.__builder.get_object("entry_port")
+ self.__entry_id = self.__builder.get_object("entry_id")
+
+ self.__entry_port.set_text("%s" % self.__port)
+ self.__entry_id.set_text("%02X" % self.__id)
+
+ self.__update_adjustment = False
+ self.__update_colorchooser = False
+
+ self.__window.show()
+
+
+ def __on_destroy(self, widget, data = None):
+ gtk.main_quit()
+
+
+ def __on_delete_event(self, widget, event, data = None):
+ return False
+
+
+ def __on_adjustment_value_changed(self, widget, data = None):
+ r = self.__adjustment_r.get_value() / 100.0
+ g = self.__adjustment_g.get_value() / 100.0
+ b = self.__adjustment_b.get_value() / 100.0
+
+ self.__update_adjustment = True
+ self.__update_color(r, g, b)
+ self.__update_adjustment = False
+
+
+ def __on_colorselection_color_changed(self, widget, data = None):
+ gtk_color = self.__colorselection.get_current_color()
+ r = gtk_color.red_float
+ g = gtk_color.green_float
+ b = gtk_color.blue_float
+
+ self.__update_colorchooser = True
+ self.__update_color(r, g, b)
+ self.__update_colorchooser = False
+
+
+ def __update_color(self, r, g, b):
+ if not self.__update_adjustment:
+ self.__adjustment_r.set_value(r * 100.0)
+ self.__adjustment_g.set_value(g * 100.0)
+ self.__adjustment_b.set_value(b * 100.0)
+
+ if not self.__update_colorchooser:
+ gtk_color = gtk.gdk.Color(r, g, b)
+ self.__colorselection.set_current_color(gtk_color)
+
+ self.__color = mood.Color(int(r * 0xFF),
+ int(g * 0xFF),
+ int(b * 0xFF))
+ self.__line[self.__id].color = self.__color
+
+
+
+if __name__ == '__main__':
+
+ if len(sys.argv) != 3:
+ print 'Usage mood_ctrl PORT ID RR GG BB'
+ print ' PORT The port to connect to'
+ print ' ID The ID of the board to select (1 byte hex)'
+ sys.exit(1)
+
+ port = sys.argv[1]
+ id = int(sys.argv[2], 16)
+
+ main_window = MainWindow(port, id)
+
+ gtk.main()
+
diff --git a/mood-sine/.project b/mood-sine/.project
new file mode 100644
index 0000000..26ceacb
--- a/dev/null
+++ b/mood-sine/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mood-sine</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.python.pydev.pythonNature</nature>
+ </natures>
+</projectDescription>
diff --git a/mood-sine/.pydevproject b/mood-sine/.pydevproject
new file mode 100644
index 0000000..20c838c
--- a/dev/null
+++ b/mood-sine/.pydevproject
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/mood-sine/src</path>
+</pydev_pathproperty>
+<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
+<path>/home/dustin/workspaces/python/mood/src</path>
+</pydev_pathproperty>
+</pydev_project>
diff --git a/mood-sine/src/mood_sine.py b/mood-sine/src/mood_sine.py
new file mode 100644
index 0000000..08124cf
--- a/dev/null
+++ b/mood-sine/src/mood_sine.py
@@ -0,0 +1,42 @@
+import sys
+import math
+import mood
+
+class SineAnimation(mood.Animation):
+ def __init__(self, line, fps):
+ mood.Animation.__init__(self, line, fps)
+
+ def init(self, line):
+ for light in line.lights:
+ light.color = mood.Color.black()
+
+ def next(self, line, duration, time):
+ f = (time % 5) / 5.0 * 2.0 * math.pi
+
+ rot = math.pi * 2.0 / 3.0
+
+ f_r = f + rot * 0.0
+ f_g = f + rot * 1.0
+ f_b = f + rot * 2.0
+
+ for light in line.lights:
+ rot = 1 / len(line.lights) * light.id
+
+ r = int((math.sin(f_r + rot) / 2 + 0.5) * 255)
+ g = int((math.sin(f_g + rot) / 2 + 0.5) * 255)
+ b = int((math.sin(f_b + rot) / 2 + 0.5) * 255)
+
+ light.color = mood.Color(r, g, b)
+
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ print 'Usage mood_ctrl PORT'
+ print ' PORT The port to connect to'
+ sys.exit(1)
+
+ port = sys.argv[1]
+ line = mood.Line(port, 1)
+
+ animation = SineAnimation(line, 50)
+ animation.start()
diff --git a/mood/.project b/mood/.project
new file mode 100644
index 0000000..a2ccaea
--- a/dev/null
+++ b/mood/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>mood</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.python.pydev.PyDevBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.python.pydev.pythonNature</nature>
+ </natures>
+</projectDescription>
diff --git a/mood/.pydevproject b/mood/.pydevproject
new file mode 100644
index 0000000..ffa1bba
--- a/dev/null
+++ b/mood/.pydevproject
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?>
+
+<pydev_project>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/mood/src</path>
+</pydev_pathproperty>
+</pydev_project>
diff --git a/mood/src/mood/Animation.py b/mood/src/mood/Animation.py
new file mode 100644
index 0000000..22ddfb7
--- a/dev/null
+++ b/mood/src/mood/Animation.py
@@ -0,0 +1,85 @@
+import threading
+import time
+
+class Animation(object):
+ '''
+ An Animation driver.
+ '''
+
+ def __init__(self, line, fps):
+ '''
+ Creates an animation on the given line with the given number of frames per
+ second
+ '''
+ self.__line = line
+ self.__fps = fps
+
+ self.__running = False
+
+ self.__event = threading.Event()
+ self.__thread = threading.Thread(target = self.__run)
+
+
+ def init(self, line):
+ '''
+ Sets the first frame of the animation
+ '''
+ pass
+
+
+ def next(self, line, duration, time):
+ '''
+ Sets the next frame of the animation on the given line in relation to the
+ given time in seconds passed since the last frame or in relation to the
+ given absolute play time in seconds
+ '''
+ pass
+
+
+ def __run(self):
+ self.__timestamp = time.time()
+ self.init(self.__line)
+
+ self.__event.wait(1 / self.__fps)
+
+ while self.__running:
+ old_timestamp = self.__timestamp
+ new_timestamp = time.time()
+
+ duration = new_timestamp - old_timestamp
+ self.__timestamp = new_timestamp
+
+ self.next(self.__line, duration, self.__timestamp)
+
+ self.__event.wait(1 / self.__fps)
+
+
+ def start(self):
+ '''
+ Starts the animation
+ '''
+ self.__running = True
+ self.__event.clear()
+ self.__thread.start()
+
+
+ def stop(self):
+ '''
+ Stops the animation
+ '''
+ if self.__running:
+ self.__running = False
+ self.__event.set()
+
+
+ @property
+ def line(self):
+ return self.__line
+
+ @property
+ def fps(self):
+ return self.__fps
+
+ @property
+ def running(self):
+ return self.__running
diff --git a/mood/src/mood/Animation.pyc b/mood/src/mood/Animation.pyc
new file mode 100644
index 0000000..8c903e0
--- a/dev/null
+++ b/mood/src/mood/Animation.pyc
Binary files differ
diff --git a/mood/src/mood/Color.py b/mood/src/mood/Color.py
new file mode 100644
index 0000000..08aa8fe
--- a/dev/null
+++ b/mood/src/mood/Color.py
@@ -0,0 +1,33 @@
+class Color(object):
+ '''
+ A Color.
+ '''
+
+ def __init__(self, r, g, b):
+ '''
+ Creates a color
+ '''
+ self.__r = r;
+ self.__g = g;
+ self.__b = b;
+
+
+ @property
+ def r(self):
+ return self.__r
+
+ @property
+ def g(self):
+ return self.__g
+
+ @property
+ def b(self):
+ return self.__b
+
+ @classmethod
+ def black(clazz):
+ return Color(0x00, 0x00, 0x00)
+
+ @classmethod
+ def white(clazz):
+ return Color(0xFF, 0xFF, 0xFF) \ No newline at end of file
diff --git a/mood/src/mood/Color.pyc b/mood/src/mood/Color.pyc
new file mode 100644
index 0000000..8d6dac6
--- a/dev/null
+++ b/mood/src/mood/Color.pyc
Binary files differ
diff --git a/mood/src/mood/Light.py b/mood/src/mood/Light.py
new file mode 100644
index 0000000..b13d01f
--- a/dev/null
+++ b/mood/src/mood/Light.py
@@ -0,0 +1,42 @@
+from mood.Color import Color
+from mood.Packet import Packet
+
+class Light(object):
+ '''
+ A light on a line.
+ '''
+
+
+ def __init__(self, line, id):
+ '''
+ Creates a light for the given line with the given id
+ '''
+ self.__line = line
+
+ self.__id = id;
+
+ self.__color = Color(0x00, 0x00, 0x00)
+
+
+ def __update(self):
+ pkg = Packet(self.__id, self.__color)
+ self.__line.send(pkg)
+
+
+ @property
+ def line(self):
+ return self.__line
+
+ @property
+ def id(self):
+ return self.__id
+
+ @property
+ def color(self):
+ return self.__color
+
+ @color.setter
+ def color(self, value):
+ self.__color = value
+ self.__update()
+ \ No newline at end of file
diff --git a/mood/src/mood/Light.pyc b/mood/src/mood/Light.pyc
new file mode 100644
index 0000000..5231f78
--- a/dev/null
+++ b/mood/src/mood/Light.pyc
Binary files differ
diff --git a/mood/src/mood/Line.py b/mood/src/mood/Line.py
new file mode 100644
index 0000000..55fcfba
--- a/dev/null
+++ b/mood/src/mood/Line.py
@@ -0,0 +1,50 @@
+from mood.Light import Light
+
+import serial
+
+class Line(object):
+ '''
+ Controller for line of mood lights.
+ '''
+
+ def __init__(self, port, light_count = 0xFF):
+ '''
+ Creates a line controller with the given port
+ '''
+ self.__port = port;
+ self.__s = serial.Serial(port = port,
+ baudrate = 9600,
+ bytesize = serial.EIGHTBITS,
+ parity = serial.PARITY_NONE,
+ stopbits = serial.STOPBITS_ONE,
+ timeout = None)
+
+ self.__lights = [Light(self, id) for id in range(0, light_count)]
+
+
+ def __del__(self):
+ '''
+ Destroys the line controller with the given port
+ '''
+ self.__s.close()
+
+
+ def send(self, pkg):
+ '''
+ Sends a package thru the line
+ '''
+ data = bytearray([pkg.id,
+ pkg.color.r,
+ pkg.color.g,
+ pkg.color.b])
+
+ self.__s.write(str(data))
+ self.__s.flush()
+
+
+ def __getitem__(self, id):
+ return self.__lights[id]
+
+ @property
+ def lights(self):
+ return self.__lights
diff --git a/mood/src/mood/Line.pyc b/mood/src/mood/Line.pyc
new file mode 100644
index 0000000..eb0ee65
--- a/dev/null
+++ b/mood/src/mood/Line.pyc
Binary files differ
diff --git a/mood/src/mood/Packet.py b/mood/src/mood/Packet.py
new file mode 100644
index 0000000..e5e5717
--- a/dev/null
+++ b/mood/src/mood/Packet.py
@@ -0,0 +1,20 @@
+class Packet(object):
+ '''
+ A Packet for transmission over a line.
+ '''
+
+ def __init__(self, id, color):
+ '''
+ Creates a packet
+ '''
+ self.__id = id;
+ self.__color = color
+
+
+ @property
+ def id(self):
+ return self.__id
+
+ @property
+ def color(self):
+ return self.__color
diff --git a/mood/src/mood/Packet.pyc b/mood/src/mood/Packet.pyc
new file mode 100644
index 0000000..4272fad
--- a/dev/null
+++ b/mood/src/mood/Packet.pyc
Binary files differ
diff --git a/mood/src/mood/__init__.py b/mood/src/mood/__init__.py
new file mode 100644
index 0000000..0c5e82f
--- a/dev/null
+++ b/mood/src/mood/__init__.py
@@ -0,0 +1,8 @@
+from mood.Light import Light
+from mood.Line import Line
+from mood.Packet import Packet
+from mood.Color import Color
+from mood.Animation import Animation
+
+if __name__ == "__main__":
+ pass \ No newline at end of file
diff --git a/mood/src/mood/__init__.pyc b/mood/src/mood/__init__.pyc
new file mode 100644
index 0000000..9ab12d4
--- a/dev/null
+++ b/mood/src/mood/__init__.pyc
Binary files differ