summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Eefting <edwin@datux.nl>2011-08-13 14:11:58 (GMT)
committer Edwin Eefting <edwin@datux.nl>2011-08-13 14:11:58 (GMT)
commitd0a804af661c926ada7ad7e725763ff9962f655f (patch)
tree84560b6dac7c92140e4bf9de66ede7261ca39000
parentb27cad119aed8f9f657e8d1e69d6d11f14f16ba6 (diff)
added draggable sliders and background
-rw-r--r--modules/dmx.module/module.cpp38
-rw-r--r--wwwdir/dmx.html81
2 files changed, 100 insertions, 19 deletions
diff --git a/modules/dmx.module/module.cpp b/modules/dmx.module/module.cpp
index d1eb91a..e9260db 100644
--- a/modules/dmx.module/module.cpp
+++ b/modules/dmx.module/module.cpp
@@ -64,6 +64,15 @@ SYNAPSE_REGISTER(module_Init)
out["recvGroup"]= "modules";
out.send();
+ //anyone can set positions
+ out.clear();
+ out.event="core_ChangeEvent";
+ out["event"]= "dmx_SetPosition";
+ out["modifyGroup"]= "modules";
+ out["sendGroup"]= "anonymous";
+ out["recvGroup"]= "modules";
+ out.send();
+
//anyone can receive updates
out.clear();
out.event="core_ChangeEvent";
@@ -225,16 +234,35 @@ SYNAPSE_REGISTER(dmx_Set)
net.doWrite(msg["id"], s);
Cmsg out;
+ out=msg;
out.event="dmx_Update";
- out["channel"]=msg["channel"];
- out["value"]=msg["value"];
+ out.src=0;
+ out.dst=0;
out.send();
dmxValues[msg["channel"]]["value"]=msg["value"];
- dmxValues[msg["channel"]]["channel"]=msg["channel"];
}
+/** Set dmx position
+ *
+ */
+SYNAPSE_REGISTER(dmx_SetPosition)
+{
+ if (msg["channel"]>1024 || msg["channel"]<0)
+ throw(synapse::runtime_error("Illegal channel"));
+
+ dmxValues[msg["channel"]]["left"]=msg["left"];
+ dmxValues[msg["channel"]]["top"]=msg["top"];
+
+ Cmsg out;
+ out=msg;
+ out.event="dmx_Update";
+ out.src=0;
+ out.dst=0;
+ out.send();
+}
+
SYNAPSE_REGISTER(dmx_Get)
{
FOREACH_VARMAP(value, dmxValues)
@@ -242,8 +270,8 @@ SYNAPSE_REGISTER(dmx_Get)
Cmsg out;
out.dst=msg.src;
out.event="dmx_Update";
- out["channel"]=value.second["channel"];
- out["value"]=value.second["value"];
+ out=value.second;
+ out["channel"]=value.first;
out.send();
}
diff --git a/wwwdir/dmx.html b/wwwdir/dmx.html
index 0c4b365..491920c 100644
--- a/wwwdir/dmx.html
+++ b/wwwdir/dmx.html
@@ -45,9 +45,31 @@
});
+ $(".draggable").draggable({
+ drag:function(event,ui)
+ {
+ send(0,"dmx_SetPosition",{
+ id:1,
+ channel:$(this).attr('_channel'),
+ left:ui.offset.left,
+ top:ui.offset.top
+ });
+ }
+ });
+
synapse_register("dmx_Update",function(msg_src, msg_dst, msg_event, msg)
{
- $("[_channel="+msg["channel"]+"]").slider("option", "value", msg["value"]);
+ if (msg.value!=null)
+ {
+ $(".slider[_channel="+msg.channel+"]").slider("option", "value", msg.value);
+ }
+
+ if (msg.top!=null)
+ {
+ $(".draggable[_channel="+msg.channel+"]").css("top", msg.top);
+ $(".draggable[_channel="+msg.channel+"]").css("left", msg.left);
+ }
+
});
@@ -57,10 +79,25 @@
</script>
<style>
+ body
+ {
+ background: url("http://internetpapier.nl/p/1v2zte2s/paper.png?386");
+ background-repeat:no-repeat;
+ background-position: 50px 100px;
+ }
+
.slider {
float:left;
- margin:2em;
- height: 255px;
+ margin:1em;
+ height: 128px;
+ }
+
+ .draggable
+ {
+ border-style:solid;
+ border-color:#aaaaaa;
+ border-width:1px;
+ position:absolute;
}
</style>
@@ -71,22 +108,38 @@
<h1>Dyne village light controller</h1>
<div>
- <div class='slider' _channel='5'>red</div>
- <div class='slider' _channel='7'>green</div>
- <div class='slider' _channel='6'>white</div>
- <div class='slider' _channel='8'>blue</div>
-</div>
+ <div class='draggable' _channel='5'>
+ <div class='slider' _channel='5'></div>
+ </div>
-<p>
-Yeah...this actually controls our lights..please turn at least the white light back on after you're done playing :D
+ <div class='draggable' _channel='7'>
+ <div class='slider' _channel='7'></div>
+ </div>
-<p>
-Powered by <a href='http://lanbox.com/'>LanBox DMX controllers</a>.
+ <div class='draggable' _channel='6'>
+ <div class='slider' _channel='6'></div>
+ </div>
+
+ <div class='draggable' _channel='8'>
+ <div class='slider' _channel='8'></div>
+ </div>
+</div>
-<p>
-<a href='http://events.ccc.de/camp/2011/wiki/Dyne#Projects'>Dyne village</a>
+<div style='
+ position:fixed;
+ bottom:0px;'>
+ Powered by <a href='http://lanbox.com/'>LanBox DMX controllers</a>.
+
+ <p>
+ <a href='http://events.ccc.de/camp/2011/wiki/Dyne#Projects'>Dyne village</a>
+ <p>
+ <a href='http://internetpapier.nl/p/1v2zte2s/edit.html'>Change background</a>
+
+ <p>
+ You can also drag the sliders and see how other people drag. Please put them back to the correct place when you're done playing. :) Also dont try to screwup the background too much.
+</div>
</body>
</html>