Control Capabilities:
Name = Logitech Orbit
Type = Local
Command = zmcontrol-pwc.pl
Move Options:
Can Move
Can Move Diagonally
Can Move Mapped
Can Move Absolute
Can Move Relative
Pan Options:
Can Pan
Min Pan Range 0
Max Pan Range 6500
Min Pan Step 100
Max Pan Step 500
Has Pan Speed
Min Pan Speed 1
Max Pan Speed 1
Tilt Options:
Can Tilt
Min Tilt Range 0
Max Tilt Range 2500
Min Tilt Step 100
Max Tilt Step 500
Has Tilt Speed
Min Tilt Speed 1
Max Tilt Speed 1
ALL OTHER CONTROL CAPABILITIES OFF
Monitor Control options:
Controllable
Control Type Logitech Orbit
Control Device /sys/class/video4linux/video0/pan_tilt
NB: The above Control Device is the key to being able to control the Orbit without direct access to the device (which is taken up by ZoneMinder).
Remember to make sure that the control device is writable by the ZoneMinder user (apache), e.g. chmod 777 /sys/class/video4linux/video0/pan_tilt
zmcontrol-pwc.pl:
Code: Select all
#!/usr/bin/perl -wT
#
# ==========================================================================
#
# ZoneMinder PWC Control Script, $Date: 2007/07/15 12:37:48 $, $Revision: 1.0 $
# Copyright (C) 2007 Denis Cheong
# Portions Copyright (C) 2003, 2004, 2005, 2006 Philip Coombes
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This script continuously monitors the recorded events for the given
# monitor and applies any filters which would delete and/or upload
# matching events
#
use strict;
# ==========================================================================
#
# These are the elements you can edit to suit your installation
#
# ==========================================================================
use constant DBG_ID => "zmctrl-pwc"; # Tag that appears in debug to identify source
use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug
use ZoneMinder;
use Getopt::Long;
$| = 1;
$ENV{PATH} = '/bin:/usr/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
sub Usage
{
print( "
Usage: zmcontrol-pwc.pl <various options>
");
exit( -1 );
}
zmDbgInit( DBG_ID, level=>DBG_LEVEL );
my $arg_string = join( " ", @ARGV );
my $pan_min = 0;
my $pan_max = 6500;
my $tilt_min = 0;
my $tilt_max = 2500;
my $address;
my $device;
my $command;
my ( $speed, $step );
my ( $xcoord, $ycoord );
my ( $width, $height );
my ( $panspeed, $tiltspeed );
my ( $panstep, $tiltstep );
my $preset;
Debug( $arg_string."\n" );
if ( !GetOptions(
'device=s'=>\$device,
'command=s'=>\$command,
'speed=i'=>\$speed,
'step=i'=>\$step,
'xcoord=i'=>\$xcoord,
'ycoord=i'=>\$ycoord,
'width=i'=>\$width,
'height=i'=>\$height,
'panstep=i'=>\$panstep,
'panspeed=i'=>\$panspeed,
'tiltstep=i'=>\$tiltstep,
'tiltspeed=i'=>\$tiltspeed
)
)
{
Debug ("Incorrect parameters");
Usage();
}
if ( !$device )
{
Usage();
}
# We have a device ... where is it now?
open(DAT, $device) || Debug ("Could not open $device");
my ($pan_cur,$tilt_cur)=split(/\ /,<DAT>);
$tilt_cur = $tilt_cur + 0;
close(DAT);
Debug ( "Currently at $pan_cur,$tilt_cur" );
srand( time() );
sub printMsg
{
my $msg = shift;
my $msg_len = length($msg);
Debug( $msg."[".$msg_len."]\n" );
}
sub moveUp
{
Debug( "Move Up\n" );
setPanTilt($pan_cur, $tilt_cur + $tiltstep);
}
sub moveDown
{
Debug( "Move Down\n" );
setPanTilt($pan_cur, $tilt_cur - $tiltstep);
}
sub moveLeft
{
Debug( "Move Left\n" );
setPanTilt($pan_cur - $panstep, $tilt_cur);
}
sub moveRight
{
Debug( "Move Right\n" );
setPanTilt($pan_cur + $panstep, $tilt_cur);
}
sub moveUpRight
{
setPanTilt($pan_cur + $panstep, $tilt_cur + $tiltstep);
}
sub moveUpLeft
{
setPanTilt($pan_cur - $panstep, $tilt_cur + $tiltstep);
}
sub moveDownRight
{
setPanTilt($pan_cur + $panstep, $tilt_cur - $tiltstep);
}
sub moveDownLeft
{
setPanTilt($pan_cur - $panstep, $tilt_cur - $tiltstep);
}
sub setPanTilt
{
my ( $pan, $tilt ) = @_;
if ($pan > $pan_max) {
$pan = $pan_max;
};
if ($pan < 0) {
$pan = 0;
};
if ($tilt > $tilt_max) {
$tilt = $tilt_max;
};
if ($tilt < 0) {
$tilt = 0;
};
Debug( "Moving from $pan_cur,$tilt_cur to $pan,$tilt\n" );
open(DAT,">$device") || die("Cannot open $device");
print(DAT "$pan $tilt");
close(DAT);
}
sub stepUp
{
my $step = shift;
Debug( "Step Up $step\n" );
setPanTilt($pan_cur, $tilt_cur+$step);
}
if ( $command eq "move_rel_up" )
{
moveUp();
}
elsif ( $command eq "move_rel_down" )
{
moveDown();
}
elsif ( $command eq "move_rel_left" )
{
moveLeft();
}
elsif ( $command eq "move_rel_right" )
{
moveRight();
}
elsif ( $command eq "move_rel_upleft" )
{
moveUpLeft();
}
elsif ( $command eq "move_rel_upright" )
{
moveUpRight();
}
elsif ( $command eq "move_rel_downleft" )
{
moveDownLeft();
}
elsif ( $command eq "move_rel_downright" )
{
moveDownRight();
}
elsif ( $command eq "preset_home" )
{
setPanTilt( $pan_max / 2 , $tilt_max / 2);
}
else
{
Error( "Can't handle command $command\n" );
}
Disclaimer: My perl is very very very rusty, and I'm too impatient to fix all of the things that are missing. And there are a few of them.