org.bluemelon.bluesense
Class OCOutputDevice

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

public class OCOutputDevice
extends Device


Field Summary
static int OCOUTPUT_PA_1
          Port pin value for pin A1
static int OCOUTPUT_PA_2
          Port pin value for pin A2
static int OCOUTPUT_PA_3
          Port pin value for pin A3
static int OCOUTPUT_PA_4
          Port pin value for pin A4
static int OCOUTPUT_PA_5
          Port pin value for pin A5
static int OCOUTPUT_PA_6
          Port pin value for pin A6
static int OCOUTPUT_PA_7
          Port pin value for pin A7
static int OCOUTPUT_PA_8
          Port pin value for pin A8
static int OCOUTPUT_PB_1
          Port pin value for pin B1
static int OCOUTPUT_PB_2
          Port pin value for pin B2
static int OCOUTPUT_PB_3
          Port pin value for pin B3
static int OCOUTPUT_PB_4
          Port pin value for pin B4
static int OCOUTPUT_PB_5
          Port pin value for pin B5
static int OCOUTPUT_PB_6
          Port pin value for pin B6
static int OCOUTPUT_PB_7
          Port pin value for pin B7
static int OCOUTPUT_PB_8
          Port pin value for pin B8
static int OUTPUTCOUNT
           
static int PROXY_ID
           
static java.lang.String PROXY_TITLE
           
static int[] SUPPORTS
           
 
Constructor Summary
OCOutputDevice(Master master, int deviceId)
          Creates a bluesense device with id 'deviceid'
 
Method Summary
 boolean getCurrentOutput(int port)
          returns output state of a pin
 int getCurrentOutputs()
          Returns the current output states (in a multiplexed value)
 int getCurrentPWMDutyCycle(int port)
          Firmware: 2+ Returns the current set duty cycle of a specific port.
 void getCurrentPWMDutyCycles(int[] dutyCycles)
          Firmware: 2+ Fills an array with the current set PWM duty cycles.
 boolean getPendingOutput(int port)
          Returns the 'tobe set' state of an output
 int getPendingOutputs()
          Returns a bitmask containing which outputs are be set after the request finishes
 int getPendingPWMDutyCycle(int port)
          Firmware: 2+ Returns the angle of a specific servo, which is currently underway to the device
 void getPendingPWMDutyCycles(int[] dutyCycles)
          Firmware: 2+ Fills an array with duty cycle values which are currently underway to the device
 boolean getRequestSetOutputsDone()
          Checks if the output set request is finished
 long getTimeOutUs()
          Returns the current set time out delay.
 void requestGetOutputs()
          Sends a request to retrieve the current set output states
 void requestSetOutput(int port, boolean state)
          Sends a request to set a single output to a new state
 void requestSetOutputs(int mask, int states)
          Sends a request to update the output states of the device.
 void requestSetPWMDutyCycle(int port, int dutyCycle)
          Firmware: version 2+ Sets the dutycycle for PWM (pulse width modulation) for the specified pin
 void requestSetPWMDutyCycles(int relevantDutyCycles, int[] duryCycle)
          Firmware: version 2+ Sets the duty cycles of pwm (pulse width modulation) pins
 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

OUTPUTCOUNT

public static final int OUTPUTCOUNT

OCOUTPUT_PA_1

public static final int OCOUTPUT_PA_1
Port pin value for pin A1


OCOUTPUT_PA_2

public static final int OCOUTPUT_PA_2
Port pin value for pin A2


OCOUTPUT_PA_3

public static final int OCOUTPUT_PA_3
Port pin value for pin A3


OCOUTPUT_PA_4

public static final int OCOUTPUT_PA_4
Port pin value for pin A4


OCOUTPUT_PA_5

public static final int OCOUTPUT_PA_5
Port pin value for pin A5


OCOUTPUT_PA_6

public static final int OCOUTPUT_PA_6
Port pin value for pin A6


OCOUTPUT_PA_7

public static final int OCOUTPUT_PA_7
Port pin value for pin A7


OCOUTPUT_PA_8

public static final int OCOUTPUT_PA_8
Port pin value for pin A8


OCOUTPUT_PB_1

public static final int OCOUTPUT_PB_1
Port pin value for pin B1


OCOUTPUT_PB_2

public static final int OCOUTPUT_PB_2
Port pin value for pin B2


OCOUTPUT_PB_3

public static final int OCOUTPUT_PB_3
Port pin value for pin B3


OCOUTPUT_PB_4

public static final int OCOUTPUT_PB_4
Port pin value for pin B4


OCOUTPUT_PB_5

public static final int OCOUTPUT_PB_5
Port pin value for pin B5


OCOUTPUT_PB_6

public static final int OCOUTPUT_PB_6
Port pin value for pin B6


OCOUTPUT_PB_7

public static final int OCOUTPUT_PB_7
Port pin value for pin B7


OCOUTPUT_PB_8

public static final int OCOUTPUT_PB_8
Port pin value for pin B8

Constructor Detail

OCOutputDevice

public OCOutputDevice(Master master,
                      int deviceId)
Creates a bluesense device with id 'deviceid'

Parameters:
deviceId - the new device has getFound() set to false until the device has been physically detected!
Method Detail

requestGetOutputs

public void requestGetOutputs()
Sends a request to retrieve the current set output states


getCurrentOutput

public boolean getCurrentOutput(int port)
returns output state of a pin

Parameters:
port - port pin value. @see bsOCOutput_pA_1

getCurrentOutputs

public int getCurrentOutputs()
Returns the current output states (in a multiplexed value)


getCurrentPWMDutyCycle

public int getCurrentPWMDutyCycle(int port)
Firmware: 2+ Returns the current set duty cycle of a specific port. A duty cycle of 0 indicates that PWM is disabled.

Parameters:
port - one of the port pin values. @see bsServo_p1
Returns:
the duty cycle of the PWM signal.

getCurrentPWMDutyCycles

public void getCurrentPWMDutyCycles(int[] dutyCycles)
Firmware: 2+ Fills an array with the current set PWM duty cycles. A duty cycle of 0 indicates that PWM is disabled.

Parameters:
dutyCycles - a pointer to an array of uint8_t values with enough space for all pins. @see OUTPUTCOUNT

requestSetOutput

public void requestSetOutput(int port,
                             boolean state)
Sends a request to set a single output to a new state

Parameters:
port - port pin value. @see bsOCOutput_pA_1
state - the new state of the output. 1 activates, 0 disables.

requestSetPWMDutyCycles

public void requestSetPWMDutyCycles(int relevantDutyCycles,
                                    int[] duryCycle)
Firmware: version 2+ Sets the duty cycles of pwm (pulse width modulation) pins

Parameters:
relevantDutyCycles - a bit mask indicating which pwm duty Cycle to update
duryCycle - an array of size OUTPUTCOUNT containing byte values (0-255) of the new duty cycles. A duty cycle of 0 will disable pwm for the coreesponding pin. @see OCOutputDevice.OUTPUTCOUNT

requestSetPWMDutyCycle

public void requestSetPWMDutyCycle(int port,
                                   int dutyCycle)
Firmware: version 2+ Sets the dutycycle for PWM (pulse width modulation) for the specified pin

Parameters:
port - port pin value. @see bsOCOutput_pA_1
dutyCycle - the new dutyCycle value (0-255). A dutyCycle of 0 disables PWM for the corresponding pin

getRequestSetOutputsDone

public boolean getRequestSetOutputsDone()
Checks if the output set request is finished

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

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.

requestSetOutputs

public void requestSetOutputs(int mask,
                              int states)
Sends a request to update the output states of the device.

Parameters:
mask - a bit mask indicating which outputs to update
states - an uint16_t bit mask containing the new output states. Only those outputs will be updated for which a bit is set in the relevantBits parameter

getPendingOutputs

public int getPendingOutputs()
Returns a bitmask containing which outputs are be set after the request finishes

Returns:
an uint16_t containing for each output a bit. If the bit is 1, then the output will be set when the request is completed

getPendingPWMDutyCycles

public void getPendingPWMDutyCycles(int[] dutyCycles)
Firmware: 2+ Fills an array with duty cycle values which are currently underway to the device

Parameters:
dutyCycles - a pointer to an array of uint8_t values with enough space for all pins. @see OUTPUTCOUNT

getPendingPWMDutyCycle

public int getPendingPWMDutyCycle(int port)
Firmware: 2+ 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.

getPendingOutput

public boolean getPendingOutput(int port)
Returns the 'tobe set' state of an output

Parameters:
port - port pin value. @see bsOCOutput_pA_1
Returns:
true if the output will be activated, or false when it will be deactivated.