Controlling the uDMX from a Webserver

12 décembre 2006 | Research
Tags: | | |

Using the uDMX commandline interface and PHP it is fairly easy to build a system to control your lights from a ordinary web browser. In this post I show you how to put a slider on a web page that controls the first channel of your DMX light dimmer. This is not a very useful application, but throw in some more Ajax and a database of your choice, et voilà: A web based lighting desk…

Ingredients

1. Compile the command line interface

Compile the uDMX command line tool for your operating system


cd UDMX_SOURCE/commandline/
make 

Move the command line tool to a directory thats accessible by PHP (for example into your web directory, something like /var/www/ on LINUX or /Library/WebServer/Documents/ on MacOSX) and make sure it is executable


mv uDMX /var/www/uDMX
sudo chmod a+x /var/www/uDMX

2. The php script

Next we’ll write a php script that takes some arguments and calls the udmx command line tool

file udmx.php:


<?php
	if (isset($_GET['start_channel'])) {
		// get the arguments to our script and make sure we get only
		// numbers, to prevent arbitrary code execution
		$cmd = preg_replace('/\D/i','',$_GET['start_channel']).' ';
		$cmd .= implode(preg_replace('/\D/i','',$_GET['value']),' ');

		//run the command line tool with our arguments
		exec('./uDMX '. $cmd);
	}
?>

3. The HTML file

include the scriptaculous and protpotype libraries in the header of your html and put this slider on your page:


<div id="slider" style="position:relative;width:255px;
						height:20px;border:1px solid black">
	<div id="handle" style="position:relative;width:18px;
						height:18px;border:1px solid black">
	</div>
</div>
<div id='response'></div>

 <script type="text/javascript" language="javascript">
var slider = new Control.Slider('handle','slider',{
		axis:	'horizontal',
		sliderValue : 	.0,
		onChange	:	function(v){
			v = parseInt(v*255);
			new Ajax.Updater('response','udmx.php?start_channel=0&value[]='+v)
		}
});
 </script>

Comments

Leave a comment | RSS | TrackBack

  1. […] the uDMX from MIDI uDMX 1.2 released !! Buy a fully assembled uDMX Stay informed: Subscribe to the uDMX mailing list Article: Control uDMXfrom a web browser […]

    Pingback par [ a n y m a ] - uDMX 1.2 released — 1 avril 2007 @ 14:01

  2. …heyaa there,
    found you on the way seeking around to control my LEDs by PC *overtheweb*. great work, swiss made as well!! ;-) will have an eye on you…!

    Commentaire par hoewe — 11 septembre 2007 @ 11:40

Leave a comment

appenzell art avr awards basel basicstamp beautiful leopard belluard berlin bern blog classic concert dance danse development do-it documentary documentation editing emission ethnology film fribourg geneve hid improvisation india installation interactive i^n kaleidochord kids lausanne live making of marseille max/msp medicine midi mobile multimedia music nature paris performance photos poland programming project prévention racisme reportage robot russia santé schaffhausen science softVNS software streetv synkie theatre tibet trogen tv udmx video videobass visuals wattwil workshop zürich
Creative Commons License
All content - unless otherwise noted - is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Powered by WordPress