org.bluemelon.bluesense
Class ServoDevice

java.lang.Object
  extended by org.bluemelon.bluesense.Device
      extended by org.bluemelon.bluesense.ServoDevice

public class ServoDevice
extends Device

Interface to the servo motor module BM7004. The BM7004 can be used to control up to 8 servo motors.


Field Summary
static int BSSERVO_P1
          Port value for pin 1
static int BSSERVO_P2
          Port value for pin 2
static int BSSERVO_P3
          Port value for pin 3
static int BSSERVO_P4
          Port value for pin 4
static int BSSERVO_P5
          Port value for pin 5
static int BSSERVO_P6
          Port value for pin 6
static int BSSERVO_P7
          Port value for pin 7
static int BSSERVO_P8
          Port value for pin 8
static int PROXY_ID
           
static java.lang.String PROXY_TITLE
           
static int SERVOCOUNT
          The number of servos that can be controlled
static int[] SUPPORTS
           
 
Constructor Summary
ServoDevice(Master master, int deviceId)
          Creates a 'software' servo motor device proxy with a given id.
 
Method Summary
 boolean configPending()
          Checks if a configuration is being currently being set or being retrieved
 int getCurrentAngle(int port)
          Returns the current set angle of a specific servo.
 void getCurrentAngles(int[] angleArray)
          Fills an array with the current set angles.
 int getCurrentOffset()
          Returns the current set offset configuration parameter
 int getPendingAngle(int port)
          Returns the angle of a specific servo, which is currently underway to the device
 void getPendingAngles(int[] angles)
          Fills an array with angles which are currently underway to the device
 boolean getRequestGetConfigDone()
          Checks if the configuration request is finished
 boolean getRequestSetAnglesDone()
          Checks if the angle set request is finished
 boolean getRequestSetConfigDone()
          Checks if the configuration set request is finished
 long getTimeOutUs()
          Returns the current set time out delay.
 void requestGetAngles()
          Sends a request to retrieve the current set angles
 void requestGetConfiguration()
          Request to obtain the configuration settings from a servo Device.
 void requestSetAngle(int port, int angle)
          Requests the servo device to set one of its servos to a new angle
 void requestSetAngles(int relevantAngles, int[] angles)
          Requests the servo device to set its servos to new angles
 void requestSetConfiguration(int offset)
          Requests to set the configuration of a servo device.
 void setTimeOutUs(int timeOutUs)
          Sets the time out value which is used to check if a request was acknowledged in the set time.
 
Methods inherited from class org.bluemelon.bluesense.Device
addDeviceEventListener, detect, getFirmwareVersion, getId, getType, getTypeName, isAccessible, removeDeviceEventListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_TITLE

public static final java.lang.String PROXY_TITLE

PROXY_ID

public static final int PROXY_ID

SUPPORTS

public static final int[] SUPPORTS

SERVOCOUNT

public static final int SERVOCOUNT
The number of servos that can be controlled


BSSERVO_P1

public static final int BSSERVO_P1
Port value for pin 1


BSSERVO_P2

public static final int BSSERVO_P2
Port value for pin 2


BSSERVO_P3

public static final int BSSERVO_P3
Port value for pin 3


BSSERVO_P4

public static final int BSSERVO_P4
Port value for pin 4


BSSERVO_P5

public static final int BSSERVO_P5
Port value for pin 5


BSSERVO_P6

public static final int BSSERVO_P6
Port value for pin 6


BSSERVO_P7

public static final int BSSERVO_P7
Port value for pin 7


BSSERVO_P8

public static final int BSSERVO_P8
Port value for pin 8

Constructor Detail

ServoDevice

public ServoDevice(Master master,
                   int deviceId)
Creates a 'software' servo motor device proxy with a given id. The device will inacessible until a physical device with the same id is detected.

Parameters:
master -
deviceId -
Method Detail

requestSetAngles

public void requestSetAngles(int relevantAngles,
                             int[] angles)
Requests the servo device to set its servos to new angles

Parameters:
relevantAngles - a bit mask indicating which servos to update
angles - a pointer to an array of uint8_t angles with enough space for all servos. @see BLUESENSE_SERVOCONTROLLER_SERVOCOUNT Only those angles for which a bit in the bit mask is set will be sent to the device. Note that each angle is value between 0 and 255, the actual physical angle depends on the specifications of the connected servo.

requestSetAngle

public void requestSetAngle(int port,
                            int angle)
Requests the servo device to set one of its servos to a new angle

Parameters:
port - one of the port pin values. @see bsServo_p1
angle - an uint8_t representing the new angle of the servo. Note that each angle is value between 0 and 255, the actual physical angle depends on the specifications of the connected servo.

requestGetAngles

public void requestGetAngles()
Sends a request to retrieve the current set angles


getPendingAngles

public void getPendingAngles(int[] angles)
Fills an array with angles which are currently underway to the device

Parameters:
angles - a pointer to an array of uint8_t angles with enough space for all servos. @see BLUESENSE_SERVOCONTROLLER_SERVOCOUNT

getPendingAngle

public int getPendingAngle(int port)
Returns the angle of a specific servo, which is currently underway to the device

Parameters:
port - one of the port pin values. @see bsServo_p1
Returns:
the angle to be set on the servo.

getRequestSetAnglesDone

public boolean getRequestSetAnglesDone()
Checks if the angle set request is finished

Returns:
1 if request finished, 0 if request still busy

getCurrentAngle

public int getCurrentAngle(int port)
Returns the current set angle of a specific servo.

Parameters:
port - one of the port pin values. @see bsServo_p1
Returns:
the angle off the servo.

getCurrentAngles

public void getCurrentAngles(int[] angleArray)
Fills an array with the current set angles.

Parameters:
angleArray - a pointer to an array of uint8_t angles with enough space for all servos. @see BLUESENSE_SERVOCONTROLLER_SERVOCOUNT

requestSetConfiguration

public void requestSetConfiguration(int offset)
Requests to set the configuration of a servo device.

Parameters:
offset - allows you to disposition the pwm duty cycle so as to fine tune the position of the servos.

requestGetConfiguration

public void requestGetConfiguration()
Request to obtain the configuration settings from a servo Device.


getRequestSetConfigDone

public boolean getRequestSetConfigDone()
Checks if the configuration set request is finished

Returns:
true if request finished, false if request still busy

getRequestGetConfigDone

public boolean getRequestGetConfigDone()
Checks if the configuration request is finished

Returns:
true if configuration was retrieved, false if still busy

configPending

public boolean configPending()
Checks if a configuration is being currently being set or being retrieved

Returns:
true if busy, false if done

getCurrentOffset

public int getCurrentOffset()
Returns the current set offset configuration parameter

Returns:
The offset. The offset allows you to disposition the pwm duty cycle so as to fine tune the position of the servos.

getTimeOutUs

public long getTimeOutUs()
Returns the current set time out delay. The time out delay is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Returns:
the time out value in microseconds.

setTimeOutUs

public void setTimeOutUs(int timeOutUs)
Sets the time out value which is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Parameters:
timeOutUs - the value in microseconds which is the maximum duraion between a request and its answer.