org.jraf.jlibibuddy
Class IBuddy

java.lang.Object
  extended by org.jraf.jlibibuddy.IBuddy

public class IBuddy
extends java.lang.Object

Main entry point to i-Buddy commanding. Note: currently, one and only one i-Buddy can be manipulated with this library. Therefore, this class should be used as a singleton, even if this not enforced by the code.


Nested Class Summary
static class IBuddy.Color
          Different colors for the head (all possible combinations of the blue, green and red LEDs).
static class IBuddy.Rotate
          Different rotation states.
static class IBuddy.Wings
          Different wing positions.
 
Method Summary
static IBuddy getIBuddy()
          Gets the i-Buddy.
 void sendAllOff()
          Turns everything off.
 void sendHeadBlue(boolean headBlue)
          Turns the head blue LED on or off.
 void sendHeadColor(boolean headBlue, boolean headGreen, boolean headRed)
          Turns the head LEDs on or off.
 void sendHeadColor(IBuddy.Color color)
          Sets a color on the head by turning the LEDs on or off.
 void sendHeadGreen(boolean headGreen)
          Turns the head green LED on or off.
 void sendHeadRed(boolean headRed)
          Turns the head red LED on or off.
 void sendHeart(boolean heart)
          Turns the heart LED on or off.
 void sendRotate(boolean rotateRight, boolean rotateLeft)
          Turns the "rotate right" and "rotate left" states on or off.
 void sendRotate(IBuddy.Rotate rotate)
          Sets the rotate state.
 void sendRotateLeft(boolean rotateLeft)
          Turns the "rotate left" state on or off.
 void sendRotateRight(boolean rotateRight)
          Turns the "rotate right" state on or off.
 void sendState(boolean heart, boolean headBlue, boolean headGreen, boolean headRed, boolean wingsDown, boolean wingsUp, boolean rotateRight, boolean rotateLeft)
          General purpose send state method.
 void sendWings(boolean wingsDown, boolean wingsUp)
          Turns the "wings up" and "wings down" states on or off.
 void sendWings(IBuddy.Wings wings)
          Sets the wings state.
 void sendWingsDown(boolean wingsDown)
          Turns the "wings down" state on or off.
 void sendWingsUp(boolean wingsUp)
          Turns the "wings up" state on or off.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getIBuddy

public static IBuddy getIBuddy()
Gets the i-Buddy.

Returns:
the i-Buddy.

sendState

public void sendState(boolean heart,
                      boolean headBlue,
                      boolean headGreen,
                      boolean headRed,
                      boolean wingsDown,
                      boolean wingsUp,
                      boolean rotateRight,
                      boolean rotateLeft)
               throws IBuddyException
General purpose send state method.

Parameters:
heart - true to turn the heart LED on, false to turn it off.
headBlue - true to turn the head blue LED on, false to turn it off.
headGreen - true to turn the head green LED on, false to turn it off.
headRed - true to turn the head red LED on, false to turn it off.
wingsDown - true to turn the "wings down" state on, false to turn it off.
wingsUp - true to turn the "wings up" state on, false to turn it off.
rotateRight - true to turn the "rotate right" state on, false to turn it off.
rotateLeft - true to turn the "rotate left" state on, false to turn it off.
Throws:
IBuddyException - in case of problem while sending the usb command.
java.lang.IllegalArgumentException - if wingsUp and wingsDown are both true, or if rotateRight and rotateLeft are both true.

sendAllOff

public void sendAllOff()
                throws IBuddyException
Turns everything off.

Throws:
IBuddyException - in case of problem while sending the usb command.

sendHeart

public void sendHeart(boolean heart)
               throws IBuddyException
Turns the heart LED on or off.

Parameters:
heart - whether to turn the heart LED on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendHeadBlue

public void sendHeadBlue(boolean headBlue)
                  throws IBuddyException
Turns the head blue LED on or off.

Parameters:
headBlue - whether to turn the head blue LED on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendHeadGreen

public void sendHeadGreen(boolean headGreen)
                   throws IBuddyException
Turns the head green LED on or off.

Parameters:
headGreen - whether to turn the head green LED on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendHeadRed

public void sendHeadRed(boolean headRed)
                 throws IBuddyException
Turns the head red LED on or off.

Parameters:
headRed - whether to turn the head red LED on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendHeadColor

public void sendHeadColor(boolean headBlue,
                          boolean headGreen,
                          boolean headRed)
                   throws IBuddyException
Turns the head LEDs on or off.

Parameters:
headBlue - whether to turn the head blue LED on (true) or off (false).
headGreen - whether to turn the head green LED on (true) or off (false).
headRed - whether to turn the head red LED on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendHeadColor

public void sendHeadColor(IBuddy.Color color)
                   throws IBuddyException
Sets a color on the head by turning the LEDs on or off.

Parameters:
color - the color to set on the head.
Throws:
IBuddyException - in case of problem while sending the usb command.

sendWingsDown

public void sendWingsDown(boolean wingsDown)
                   throws IBuddyException
Turns the "wings down" state on or off. This also automatically turns the "wings up" state to the opposite value.

Parameters:
wingsDown - whether to turn the "wings down" on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendWingsUp

public void sendWingsUp(boolean wingsUp)
                 throws IBuddyException
Turns the "wings up" state on or off. This also automatically turns the "wings down" state to the opposite value.

Parameters:
wingsUp - whether to turn the "wings up" on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendWings

public void sendWings(boolean wingsDown,
                      boolean wingsUp)
               throws IBuddyException
Turns the "wings up" and "wings down" states on or off.

Parameters:
wingsUp - whether to turn the "wings up" on (true) or off (false).
wingsDown - whether to turn the "wings down" on (true) or off (false).
Throws:
java.lang.IllegalArgumentException - if wingsUp and wingsDown are both true.
IBuddyException - in case of problem while sending the usb command.

sendWings

public void sendWings(IBuddy.Wings wings)
               throws IBuddyException
Sets the wings state.

Parameters:
wings - the wings state.
Throws:
IBuddyException - in case of problem while sending the usb command.

sendRotateRight

public void sendRotateRight(boolean rotateRight)
                     throws IBuddyException
Turns the "rotate right" state on or off. This also automatically turns the "rotate left" state to the opposite value.

Parameters:
rotateRight - whether to turn the "rotate right" on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendRotateLeft

public void sendRotateLeft(boolean rotateLeft)
                    throws IBuddyException
Turns the "rotate left" state on or off. This also automatically turns the "rotate right" state to the opposite value.

Parameters:
rotateLeft - whether to turn the "rotate left" on (true) or off (false).
Throws:
IBuddyException - in case of problem while sending the usb command.

sendRotate

public void sendRotate(boolean rotateRight,
                       boolean rotateLeft)
                throws IBuddyException
Turns the "rotate right" and "rotate left" states on or off.

Parameters:
rotateRight - whether to turn the "rotate right" on (true) or off (false).
rotateLeft - whether to turn the "rotate left" on (true) or off (false).
Throws:
java.lang.IllegalArgumentException - if rotateRight and rotateLeft are both true.
IBuddyException - in case of problem while sending the usb command.

sendRotate

public void sendRotate(IBuddy.Rotate rotate)
                throws IBuddyException
Sets the rotate state.

Parameters:
rotate - the rotate state.
Throws:
IBuddyException - in case of problem while sending the usb command.


Copyright © 2008 JRAF.org. All Rights Reserved.