Win32::AmbientOrb

This page describes a Perl module I wrote to support a serial-port controlled Ambient Orb. See the Original Post for details. If you just want to get the package, you can download it directly or grab a PPD.

Manipulate an Ambient Orb through a serial port

NAME

Win32::AmbientOrb - Manipulate an Ambient Orb through a serial port

SYNOPSIS

  use Win32::AmbientOrb;

EXAMPLE

  use Win32::AmbientOrb qw(:ALL);

  my $port = "COM1:";
  Win32::AmbientOrb::Port($port); #set port to COM1
  InitializePort();               #set serial port settings
  PagerIgnore(1);                 #don't listen to the pager network

  # go straight to red
  my @red = (176, 0, 0);
  DirectColor(\@red);

  # quick transition from blue to red
  my @blue = (0, 0, 176);
  TransitionColor(\@blue, \@red, 20, 5);

  # slow transition from red to blue
  TransitionColor(\@red, \@blue, 50, 100);

  # clean up
  CloseOrb();

DESCRIPTION

The Win32::AmbientOrb module lets you manipulate an Ambient Orb connected to a Win32 machine through a serial port.

It uses Win32::SerialPort for serial port communication.

EXPORTED HASHES

Two hashes are exported by default, %OrbColor and %OrbRGB.

%OrbColor
Maps from color names to Color IDs useful for ColorAnim( ). Available color names are:

 • Red          => 0
 • LightRed     => 1
 • DarkOrange   => 2
 • Orange       => 3
 • LightOrange  => 4
 • DarkYellow   => 5
 • Yellow       => 6
 • LimeGreen    => 7
 • PaleGreen    => 8
 • GreenMinus3  => 9
 • GreenMinus2  => 10
 • GreenMinus1  => 11
 • Green        => 12
 • GreenPlus1   => 13
 • GreenPlus2   => 14
 • PaleAqua     => 15
 • Aqua         => 16
 • DarkAqua     => 17
 • Cyan         => 18
 • DarkCyan     => 19
 • LightBlue    => 20
 • SkyBlue      => 21
 • BlueMinus2   => 22
 • BlueMinus1   => 23
 • Blue         => 24
 • DeepBlue     => 25
 • VeryDeepBlue => 26
 • Violet       => 27
 • Purple       => 28
 • LightPurple  => 29
 • Magenta      => 30
 • MagentaPlus1 => 31
 • MagentaPlus2 => 32
 • MagentaPlus3 => 33
 • MagentaPlus4 => 34
 • MagentaPlus5 => 35
 • White        => 36
%OrbRGB
Contains the mapping of color ids to RGB arrays useful for DirectColor( ).

METHODS

Port( [$port] )
Sets or returns the port that the Ambient Orb is connected to. Default is COM1:

InitializePort( )
Initializes the serial port for communication with the Ambient Orb. Settings are:

 • BAUD: 19200
 • PARITY: N
 • DATA: 8
 • STOP: 1
ClosePort( )
Cleans up the port object.

ColorAnim( [$color], [$animation] )
Changes the color of the Orb using the default color and animation settings. Colors are listed above in %OrbColor Animations are 0-9

        ANIMATION
 • 0 almost imperceptibly slow
        ...
 • 7 very fast
 • 8 crescendo effect
 • 9 heartbeat effect
DirectColor( \@rgb )
Sets the orb instantly to the color specified in the 3-element array @rgb. Red, green and blue values should be between 0 and 176.

TransitionColor( \@rgb0, \@rgb1, $steps, $wait )
Performs a slow transition from the color in @rgb0 to the one in @rgb1. Sets the orb instantly to the color specified in the 3-element array @rgb0, then sends $steps updates, one update every $wait milliseconds until it reaches the color specified in @rgb1. Red, green and blue values should be between 0 and 176.

PagerIgnore( $ignore )
Instructs the orb not to listen to the pager network. If you don't call this, the orb will keep changing its color to reflect whatever channel it was listening to before you plugged in the serial port.

AUTHOR

Andy Allen