j3d.org Code

org.j3d.device.input.spaceball
Class Spaceball4000Packet

java.lang.Object
  extended byorg.j3d.device.input.spaceball.SpaceballPacket
      extended byorg.j3d.device.input.spaceball.Spaceball4000Packet

public class Spaceball4000Packet
extends SpaceballPacket

Generates and decodes data packets for Labtec's Spaceball 4000 device according to the Spaceball 4000 Packet Protocol v1.2.

NOTE: Some data packets will contain an additional "special character" ('^' - 0x5e) inserted within the data stream. This escape character notifies the system to modify the following byte. If the following byte is 'Q', (0x51), 'S' (0x53), or an 'M' (0x4d) the seventh bit should be cleared. (Which should result in 0x11, 0x13, 0x0d respectively.) If the following character is a second '^' (0x5e) then no modification should be made. (Do not forget to remove the '^' character from the packet buffer.). This is currently not implemented. Therefore certain data packets may be ignored, specially if buttons 3 and 4 are pressed at the same time.

NOTE: The Ignore Packet is not implemented.

Spaceball and Spaceball 4000 are Trademarks of Labtec Inc.

Version:
20. Aug. 2001 Copyright (c) Dipl. Ing. Paul Szawlowski

Author:
Dipl. Ing. Paul Szawlowski - University of Vienna, Dept. of Medical Computer Sciences

Field Summary
static byte ADVANCED_BUTTON_DATA
          This command causes the Spaceball to RESET.
static byte AUTO_REZERO_RESPONSE
           
static byte CHANGE_AUTOMATIC_ZERO_PARAMETERS
           
static int COMMAND_UNRECOGNIZED_ERROR_CODE
           
static byte CUBIC_SENSITIVITY_ENABLE_DISABLE
           
static byte CUBIC_SENSITIVITY_ENABLED
          constant for cubic sensitivity
static byte DISABLE_BALL_DATA
          This command disables data packets.
static int ECLIPSE_REGISTER_ERROR_CODE
           
static int ECLIPSE_TIMED_OUT_ERROR_CODE
           
static int EEPROM_CHECKSUM_INCORRECT_ERROR_CODE
           
static byte EMIT_SINGLE_BEEP
          This command causes the Spaceball 4000 to single beep.
static byte ENABLE_BALL_DATA
          This command enables data packets.
static byte ENABLE_DISABLE_AUTO_REZERO
           
static byte GET_DEVICE_DESCRIPTOR
          This command requests the Spaceball 4000-specific reset string.
static byte GET_DEVICE_INFORMATION
          This command requests the firmware version and build date.
static byte GET_DEVICE_INFORMATION_RESPONSE
           
static byte GET_REZERO_BALL
          This command causes the Spaceball to rezero.
static int LEFT
          constant for left handedness
static int PACKET_IGNORED_ERROR_CODE
           
static int PACKET_TOO_LONG_ERROR_CODE
           
static int RECEIVE_ERROR_ERROR_CODE
           
static int RECEIVE_QUEUE_OVERFLOW_ERROR_CODE
           
static int RIGHT
          constant for right handedness
static byte STANDARD_SENSITIVITY_ENABLED
          constant for standard sensitivity
static int TRANSMIT_TIMEOUT_ERROR_CODE
           
 
Fields inherited from class org.j3d.device.input.spaceball.SpaceballPacket
BALL_DATA, BUTTON_DATA, BUTTON_DATA_PACKET_LENGTH, BUTTON_MASK, ECHO, ERROR, PACKET_TERMINATOR, PATTERNED_BEEP, POSITION_DATA_PACKET_LENGTH, RESET_DEVICE
 
Constructor Summary
Spaceball4000Packet()
           
 
Method Summary
static int createChangeAutomaticZeroParametersPacket(byte[] data, int offset, int autoZeroPeriod, int autoZeroWindow)
          Sets a flag in the EEPROM to enable automatic rezero.
static int createCubicSensitivityEnableDisablePacket(byte[] data, int offset, boolean enable)
          This command causes the Spaceball 4000 to use or not to use the cubic sensitivity curve for the ball data transmitted.
static int createEnableDisableAutoRezeroPacket(byte[] data, int offset, boolean enable)
          This command causes the Spaceball 4000 not to use the auto-rezero function in the device.
static void decodeButtonEvent(int[] buttonData, byte[] readBuffer, Spaceball4000CallbackInterface caller, int packetStart)
           
static void doCallBacks(byte[] readBuffer, Spaceball4000CallbackInterface caller, int dataStart, int dataLength, int header)
           
 
Methods inherited from class org.j3d.device.input.spaceball.SpaceballPacket
createEchoPacket, createPatternedBeepPacket, createSimpleRequestPacket, decodeBallData, decodeButtonData, makeWord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ECLIPSE_REGISTER_ERROR_CODE

public static final int ECLIPSE_REGISTER_ERROR_CODE
See Also:
Constant Field Values

EEPROM_CHECKSUM_INCORRECT_ERROR_CODE

public static final int EEPROM_CHECKSUM_INCORRECT_ERROR_CODE
See Also:
Constant Field Values

ECLIPSE_TIMED_OUT_ERROR_CODE

public static final int ECLIPSE_TIMED_OUT_ERROR_CODE
See Also:
Constant Field Values

TRANSMIT_TIMEOUT_ERROR_CODE

public static final int TRANSMIT_TIMEOUT_ERROR_CODE
See Also:
Constant Field Values

RECEIVE_QUEUE_OVERFLOW_ERROR_CODE

public static final int RECEIVE_QUEUE_OVERFLOW_ERROR_CODE
See Also:
Constant Field Values

RECEIVE_ERROR_ERROR_CODE

public static final int RECEIVE_ERROR_ERROR_CODE
See Also:
Constant Field Values

PACKET_TOO_LONG_ERROR_CODE

public static final int PACKET_TOO_LONG_ERROR_CODE
See Also:
Constant Field Values

PACKET_IGNORED_ERROR_CODE

public static final int PACKET_IGNORED_ERROR_CODE
See Also:
Constant Field Values

COMMAND_UNRECOGNIZED_ERROR_CODE

public static final int COMMAND_UNRECOGNIZED_ERROR_CODE
See Also:
Constant Field Values

EMIT_SINGLE_BEEP

public static final byte EMIT_SINGLE_BEEP
This command causes the Spaceball 4000 to single beep. This is a simple request packet (packet which consists only of a header). Packet size = 2 bytes.

See Also:
Constant Field Values

ENABLE_BALL_DATA

public static final byte ENABLE_BALL_DATA
This command enables data packets. The Spaceball device will not send any ball movement packets until this command is sent. This is a simple request packet (packet which consists only of a header).Packet size = 2 bytes.

See Also:
Constant Field Values

DISABLE_BALL_DATA

public static final byte DISABLE_BALL_DATA
This command disables data packets. The Spaceball device will cease to send ball movement packets after this command is sent. This is a simple request packet (packet which consists only of a header).Packet size = 2 bytes.

See Also:
Constant Field Values

GET_DEVICE_DESCRIPTOR

public static final byte GET_DEVICE_DESCRIPTOR
This command requests the Spaceball 4000-specific reset string. This is a simple request packet (packet which consists only of a header). Packet size = 2 bytes.

See Also:
Constant Field Values

GET_REZERO_BALL

public static final byte GET_REZERO_BALL
This command causes the Spaceball to rezero. It takes the current position as the Powersensor rest position. All subsequent measurements (until reset) are taken relative to this position. This is a simple request packet (packet which consists only of a header). Packet size = 2 byte.

See Also:
Constant Field Values

ADVANCED_BUTTON_DATA

public static final byte ADVANCED_BUTTON_DATA
This command causes the Spaceball to RESET. This is a simple request packet (packet which consists only of a header).Packet size = 2 bytes.

See Also:
Constant Field Values

CUBIC_SENSITIVITY_ENABLE_DISABLE

public static final byte CUBIC_SENSITIVITY_ENABLE_DISABLE
See Also:
Constant Field Values

ENABLE_DISABLE_AUTO_REZERO

public static final byte ENABLE_DISABLE_AUTO_REZERO
See Also:
Constant Field Values

CHANGE_AUTOMATIC_ZERO_PARAMETERS

public static final byte CHANGE_AUTOMATIC_ZERO_PARAMETERS
See Also:
Constant Field Values

AUTO_REZERO_RESPONSE

public static final byte AUTO_REZERO_RESPONSE
See Also:
Constant Field Values

GET_DEVICE_INFORMATION

public static final byte GET_DEVICE_INFORMATION
This command requests the firmware version and build date. This is a simple request packet (packet which consists only of a header). Packet size = 2 bytes.

See Also:
Constant Field Values

GET_DEVICE_INFORMATION_RESPONSE

public static final byte GET_DEVICE_INFORMATION_RESPONSE
See Also:
Constant Field Values

LEFT

public static final int LEFT
constant for left handedness

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
constant for right handedness

See Also:
Constant Field Values

CUBIC_SENSITIVITY_ENABLED

public static final byte CUBIC_SENSITIVITY_ENABLED
constant for cubic sensitivity

See Also:
Constant Field Values

STANDARD_SENSITIVITY_ENABLED

public static final byte STANDARD_SENSITIVITY_ENABLED
constant for standard sensitivity

See Also:
Constant Field Values
Constructor Detail

Spaceball4000Packet

public Spaceball4000Packet()
Method Detail

createCubicSensitivityEnableDisablePacket

public static int createCubicSensitivityEnableDisablePacket(byte[] data,
                                                            int offset,
                                                            boolean enable)
This command causes the Spaceball 4000 to use or not to use the cubic sensitivity curve for the ball data transmitted.

Parameters:
data - buffer into which the packet will be copied; packet size = 3 byte
offset - first byte of packet will be copied at "data[offset]"
enable - true: cubic sensitivity will be enabled
Returns:
packet size

createEnableDisableAutoRezeroPacket

public static int createEnableDisableAutoRezeroPacket(byte[] data,
                                                      int offset,
                                                      boolean enable)
This command causes the Spaceball 4000 not to use the auto-rezero function in the device.

Parameters:
data - buffer into which the packet will be copied; packet size = 3 byte
offset - first byte of packet will be copied at "data[offset]"
enable - true: auto rezero will be enabled
Returns:
packet size

createChangeAutomaticZeroParametersPacket

public static int createChangeAutomaticZeroParametersPacket(byte[] data,
                                                            int offset,
                                                            int autoZeroPeriod,
                                                            int autoZeroWindow)
Sets a flag in the EEPROM to enable automatic rezero.

Parameters:
data - buffer into which the packet will be copied; packet size = 8 byte
offset - first byte of packet will be copied at "data[offset]"
autoZeroPeriod - [ms] 0 <= "autoZeroPeriod" <= 0xFFFF Set to zero to disable automatic zeroing capabilities.
autoZeroWindow - [raw reading units] 0 <= "autoZeroWindow" <= 0xFF
Returns:
packet size

decodeButtonEvent

public static void decodeButtonEvent(int[] buttonData,
                                     byte[] readBuffer,
                                     Spaceball4000CallbackInterface caller,
                                     int packetStart)

doCallBacks

public static void doCallBacks(byte[] readBuffer,
                               Spaceball4000CallbackInterface caller,
                               int dataStart,
                               int dataLength,
                               int header)

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org