#!/usr/bin/perl
system( "logger 'HAL - dmx_prod_rebooted' ");
$inc_up = 5 ;
$inc_down = 5 ;
$min_intensity = 70 ;
while (true)
{
use Device::SerialPort ;
my $port = Device::SerialPort->new("/dev/ttyAMA0") ;
$port->baudrate(9600) ; $port->parity("none") ;
$port->handshake("none") ; $port->databits(8) ;
$port->stopbits(1) ; $port->read_char_time(0) ;
$port->read_const_time(1) ;
#Set Status's
@files = <dmx_set_*.txt> ;
foreach $file (@files) {
$channel = $file ; $channel =~ s/.txt// ;
$channel =~ s/dmx_set_// ;
chomp($channel) ;
open (FILE, $file) ;
$intensity = <FILE> ;
close (FILE) ;
chomp ($intensity) ;
if ( $intensity > 255 ) { $intensity = 0 } ;
if ( $intensity < $min_intensity ) { $intensity = 0 } ;
if ( ${variable_."$channel"} != $intensity )
{
if (${variable_."$channel"} < $intensity )
{
$set_intensity = ${variable_."$channel"} + $inc_up ;
if ( $set_intensity < $min_intensity )
{
$set_intensity = $min_intensity ;
}
}
if (${variable_."$channel"} > $intensity )
{
$set_intensity = ${variable_."$channel"} - $inc_down ;
}
$port->write( pack "C", $channel ) ;
$port->write( pack "C", $set_intensity ) ;
system( "logger 'HAL - dmx_lighting_set $channel - $set_intensity' ");
${variable_."$channel"} = $set_intensity ;
select(undef, undef, undef, 0.05) ; #Sleep a bit
}
}
$port->close() ;
select(undef, undef, undef, 0.1) ; #Sleeep 100 mS
}