Holiday lights

From Noisebridge
(Difference between revisions)
Jump to: navigation, search
(New page: We put up some holiday lights in the Mission Street windows. (We call them Holiday Lights both as an ecumenical gesture of goodwill as well as to annoy the "War on Christmas" wingnuts.) ...)
 
Line 1: Line 1:
 
 
We put up some holiday lights in the Mission Street windows. (We call them Holiday Lights both as an ecumenical gesture of goodwill as well as to annoy the "War on Christmas" wingnuts.)
 
We put up some holiday lights in the Mission Street windows. (We call them Holiday Lights both as an ecumenical gesture of goodwill as well as to annoy the "War on Christmas" wingnuts.)
  
Line 7: Line 6:
  
 
Basic info:
 
Basic info:
<nowiki>
 
/home/lights/server/filelooop.py
 
  
This is the script that runs forever, and does the Actual
+
  /home/lights/server/filelooop.py
Work of switching the lights on and off. It reads the
+
file /home/lights/sequence, which defines the light
+
sequence, and then uses the RelayControl class to
+
communicate with the external relay bank.
+
  
/home/lights/sequence
+
This is the script that runs forever, and does the Actual
 +
Work of switching the lights on and off.  It reads the
 +
file /home/lights/sequence, which defines the light
 +
sequence, and then uses the RelayControl class to
 +
communicate with the external relay bank.
  
The file read by filelooop.py that defines the light
+
/home/lights/sequence
sequence currently active.  The first line of this file
+
defines how long (in milliseconds) we should sleep before
+
advancing to the next state.  The rest of the file is a
+
list of states to iterate through.  For example:
+
  
1000
+
The file read by filelooop.py that defines the light
10000000
+
sequence currently active.  The first line of this file
01000000
+
defines how long (in milliseconds) we should sleep before
00100000
+
advancing to the next state.  The rest of the file is a
00010000
+
list of states to iterate through.  For example:
00001000
+
00000100
+
00000010
+
00000001
+
  
We sleep for 1 second (1000 milliseconds) between states.
+
1000
In the first state, the first light is on, and the rest
+
10000000
are off. In the second state, the second light is on, and
+
01000000
the rest are off. In the third state, the third light is
+
00100000
on, and the rest are off. etc.
+
00010000
 +
00001000
 +
  00000100
 +
  00000010
 +
  00000001
  
(There's code in place in filelooop.py to also support
+
We sleep for 1 second (1000 milliseconds) between states.
state lines in the syntax of "<state> <delay>", to sleep
+
In the first state, the first light is on, and the rest
for an amount of time different than the "global delay",
+
are off.  In the second state, the second light is on, and
but I haven't actually tested this behavior yet.)
+
the rest are off.  In the third state, the third light is
 +
on, and the rest are off.  etc.
  
/home/lights/*.seq
+
(There's code in place in filelooop.py to also support
 +
state lines in the syntax of "<state> <delay>", to sleep
 +
for an amount of time different than the "global delay",
 +
but I haven't actually tested this behavior yet.)
  
A list of pre-programed sequences.
+
/home/lights/*.seq
  
/home/lights/server/webserver.py
+
A list of pre-programed sequences.
  
A full webserver/framework implementation, currently
+
  /home/lights/server/webserver.py
configured to listen on port 8080. When you request "/",
+
it returns a list of hyperlinks to each of the *.seq files
+
in lights's home directory.  If you click on one of those
+
links, it copies the contents from the *.seq file to
+
/home/lights/sequence, so filelooop.py will start
+
processing it instead of whatever it was previously
+
processing.
+
  
/home/lights/set.html
+
A full webserver/framework implementation, currently
 +
configured to listen on port 8080.  When you request "/",
 +
it returns a list of hyperlinks to each of the *.seq files
 +
in lights's home directory.  If you click on one of those
 +
links, it copies the contents from the *.seq file to
 +
/home/lights/sequence, so filelooop.py will start
 +
processing it instead of whatever it was previously
 +
processing.
  
When you use webserver.py to request a *.seq file, it
+
/home/lights/set.html
returns the contents of /home/lights/set.html to the
+
browser.  Right now, this file contains just
+
"<h1>Thanks!</h1>".  We should make it look pretty, and
+
probably also have a meta refresh to redirect the user
+
back to / (the directory listing) after a few seconds,
+
or something.
+
  
If we want to get fancy, we should also look into using
+
When you use webserver.py to request a *.seq file, it
one of the python templating libraries, so we can have a
+
<nowiki>"<h1>Thanks!</h1>"</nowiki>. We should make it look pretty, and
static index.html page independent of the code, and then
+
probably also have a meta refresh to redirect the user
make that index.html file look pretty, too.  We just need
+
back to / (the directory listing) after a few seconds,
to find out how to interpolate a list of files to display
+
or something.
in he the directory listing.
+
</nowiki>
+

Revision as of 01:49, 9 December 2009

We put up some holiday lights in the Mission Street windows. (We call them Holiday Lights both as an ecumenical gesture of goodwill as well as to annoy the "War on Christmas" wingnuts.)

Naturally, you can control them on the web using the bare-bones interface at URL: http://lights.netisland.net:8080/

This is served by a pure Python webserver running on a Fit-PC Ubuntu micro-PC.

Basic info:

/home/lights/server/filelooop.py

This is the script that runs forever, and does the Actual Work of switching the lights on and off. It reads the file /home/lights/sequence, which defines the light sequence, and then uses the RelayControl class to communicate with the external relay bank.

/home/lights/sequence

The file read by filelooop.py that defines the light sequence currently active. The first line of this file defines how long (in milliseconds) we should sleep before advancing to the next state. The rest of the file is a list of states to iterate through. For example:

1000
10000000
01000000
00100000
00010000
00001000
00000100
00000010
00000001

We sleep for 1 second (1000 milliseconds) between states. In the first state, the first light is on, and the rest are off. In the second state, the second light is on, and the rest are off. In the third state, the third light is on, and the rest are off. etc.

(There's code in place in filelooop.py to also support state lines in the syntax of "<state> <delay>", to sleep for an amount of time different than the "global delay", but I haven't actually tested this behavior yet.)

/home/lights/*.seq

A list of pre-programed sequences.

/home/lights/server/webserver.py

A full webserver/framework implementation, currently configured to listen on port 8080. When you request "/", it returns a list of hyperlinks to each of the *.seq files in lights's home directory. If you click on one of those links, it copies the contents from the *.seq file to /home/lights/sequence, so filelooop.py will start processing it instead of whatever it was previously processing.

/home/lights/set.html

When you use webserver.py to request a *.seq file, it "<h1>Thanks!</h1>". We should make it look pretty, and probably also have a meta refresh to redirect the user back to / (the directory listing) after a few seconds, or something.

Personal tools