<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
-import BaseHTTPServer, urlparse, serial, ConfigParser
+import BaseHTTPServer, urlparse, serial, ConfigParser, re
 
 config = ConfigParser.ConfigParser()
 config.read(('lighted.conf', '/etc/lighted.conf'))
@@ -24,15 +24,15 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
     bits = path.split('/')
     bits.pop(0) # Crap
 
-    if len(bits) != 4:
+    if len(bits) != 2:
         self.send_error(500)
         self.end_headers()
         self.send_header('Content-Type', 'text/html')
-        self.wfile.write('Bad request, should be in the format foo.com/device/r/g/b')
+        self.wfile.write('Bad request, should be in the format foo.com/device/r,g,b')
         return 
 
     devices = []
-    device = bits.pop(0)
+    device = bits.pop(0) # Device
     if (device == '_'):
         devices = dmxDevices.keys()
     else:
@@ -48,7 +48,13 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
             self.wfile.write(', '.join(str(x) for x in dmxDevices.keys()))
             return 
 
-    for val in bits:
+    colour = bits.pop(0) # Colour
+    if re.match('\d+,\d+,\d+', colour):
+        rgb = colour.split(',')
+    elif re.match('[0-9ABCDEF]{,6}', colour):
+        rgb = [int(x, 16) for x in (colour[0:2], colour[2:4], colour[4:6])]
+
+    for val in rgb:
         if int(val) &lt; 0 or int(val) &gt; 255:
             self.send_error(500)
             self.end_headers()
@@ -56,6 +62,9 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
             self.wfile.write('RGB value out of range, should be 0 &lt;&gt; 255')
             return 
 
+    from pprint import pprint
+    pprint(rgb)
+
     self.send_response(200)
     self.send_header('Content-type', 'text/html')
     self.end_headers()
@@ -63,7 +72,8 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
 
     for device in devices:
         for i in range(0, 3):
-            port.write(&quot;%sc%sw&quot; % (dmxDevices[device] + i, bits[i]))
+            port.write(&quot;%sc%sw&quot; % (dmxDevices[device] + i, rgb[i]))
+
 
 PORT = 8000
 httpd = BaseHTTPServer.HTTPServer((&quot;&quot;, PORT), Handler)</diff>
      <filename>lighted.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>10996202590042471d604a34f59138c0a941772b</id>
    </parent>
  </parents>
  <author>
    <name>Jonty</name>
    <email>jonty@jonty.co.uk</email>
  </author>
  <url>http://github.com/Jonty/Lighted/commit/947cb553964073c660697adf53fe64769ec7b33b</url>
  <id>947cb553964073c660697adf53fe64769ec7b33b</id>
  <committed-date>2009-11-03T12:54:27-08:00</committed-date>
  <authored-date>2009-11-03T12:54:27-08:00</authored-date>
  <message>Change colour formatting, add support for hex codes</message>
  <tree>25f762e148e2cdb242436906289d33c59a4ba913</tree>
  <committer>
    <name>Jonty</name>
    <email>jonty@jonty.co.uk</email>
  </committer>
</commit>
