public class CompassSensor extends I2CSensor
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ABOUT |
static byte |
ANGLE |
static byte |
ANGLESTEPSMODE |
static double |
AXE_LENGTH
Axe length (in m) used by Gear.leftArc(), Gear.rightArc()
|
static byte |
BOOLEANMODE |
static byte |
BOOT |
static byte |
BRAKE |
static byte |
CELSIUSMODE |
static byte |
CLOSE |
static int |
COMPASS_SENSOR_POLL_DELAY |
static double |
CRAWLER_ROTATION_FACTOR
Factor between crawler robot angle (in degrees) and motor rotation count
|
static int |
CRAWLER_ROTATION_SPEED
Turtle crawler speed for rotations
|
static int |
CRAWLER_SPEED
Turtle crawler speed for straight movements
|
static double |
CRAWLER_STEP_FACTOR
Factor between turtle crawler steps and motor rotation count
|
static byte |
CUSTOM |
static byte |
DELETE |
static byte |
DELETE_USER_FLASH |
static byte |
DIRECT_COMMAND_NOREPLY |
static byte |
DIRECT_COMMAND_REPLY |
static byte |
FAHRENHEITMODE |
static byte |
FIND_FIRST |
static byte |
FIND_NEXT |
static int |
GEAR_ACCELERATION_DELAY
Time to wait between increasing/decreasing speed steps in Gear.moveTo()
|
static int |
GEAR_BRAKE_DELAY
Time to wait between succeeding movement calls before stop
|
static int |
GEAR_SPEED
Default gear speed
|
static byte |
GET_BATTERY_LEVEL |
static byte |
GET_CURRENT_PROGRAM_NAME |
static byte |
GET_DEVICE_INFO |
static byte |
GET_FIRMWARE_VERSION |
static byte |
GET_INPUT_VALUES |
static byte |
GET_OUTPUT_STATE |
static byte |
HIGH_SPEED_BUFFER |
static byte |
KEEP_ALIVE |
static byte |
LIGHT_ACTIVE |
static byte |
LIGHT_INACTIVE |
static int |
LIGHT_SENSOR_POLL_DELAY |
static byte |
LOWSPEED |
static byte |
LOWSPEED_9V |
static byte |
LS_GET_STATUS |
static byte |
LS_READ |
static byte |
LS_WRITE |
static byte |
MESSAGE_READ |
static byte |
MESSAGE_WRITE |
static byte |
MODEMASK |
static int |
MOTION_DETECTOR_POLL_DELAY |
static byte |
MOTOR_RUN_STATE_IDLE |
static byte |
MOTOR_RUN_STATE_RAMPDOWN |
static byte |
MOTOR_RUN_STATE_RAMPUP |
static byte |
MOTOR_RUN_STATE_RUNNING |
static int |
MOTOR_SPEED
Default motor speed
|
static double |
MOTOR_SPEED_FACTOR
Factor between speed and velocity (in m/s): velocity = MotorSpeedFactor * speed
|
static byte |
MOTORON |
static byte |
NO_OF_SENSOR_TYPES |
static byte |
NO_SENSOR |
static byte |
NXJ_FIND_FIRST |
static byte |
NXJ_FIND_NEXT |
static byte |
OPEN_APPEND_DATA |
static byte |
OPEN_READ |
static byte |
OPEN_READ_LINEAR |
static byte |
OPEN_WRITE |
static byte |
OPEN_WRITE_DATA |
static byte |
OPEN_WRITE_LINEAR |
static byte |
PCTFULLSCALEMODE |
static byte |
PERIODCOUNTERMODE |
static byte |
PLAY_SOUND_FILE |
static byte |
PLAY_TONE |
static byte |
POLL |
static byte |
POLL_BUFFER |
static byte |
POLL_LENGTH |
static byte |
RAWMODE |
static byte |
READ |
static byte |
REFLECTION |
static byte |
REGULATED |
static byte |
REGULATION_MODE_IDLE |
static byte |
REGULATION_MODE_MOTOR_SPEED |
static byte |
REGULATION_MODE_MOTOR_SYNC |
static byte |
REPLY_COMMAND |
static byte |
RESET_MOTOR_POSITION |
static byte |
RESET_SCALED_INPUT_VALUE |
static byte |
SET_BRICK_NAME |
static byte |
SET_INPUT_MODE |
static byte |
SET_OUTPUT_STATE |
static byte |
SLOPEMASK |
static byte |
SOUND_DB |
static byte |
SOUND_DBA |
static int |
SOUND_SENSOR_POLL_DELAY
Wait time (in ms) between polling the sensor value when registering an event handler
|
static byte |
START_PROGRAM |
static byte |
STOP_PROGRAM |
static byte |
STOP_SOUND_PLAYBACK |
static byte |
SWITCH |
static byte |
SYSTEM_COMMAND_NOREPLY |
static byte |
SYSTEM_COMMAND_REPLY |
static byte |
TEMPERATURE |
static int |
TOUCH_SENSOR_POLL_DELAY |
static byte |
TRANSITIONCNTMODE |
static double |
TURTLE_ROTATION_FACTOR
Factor between turtle angle (in degrees) and motor rotation count
|
static int |
TURTLE_ROTATION_SPEED
Turtle speed for rotations
|
static int |
TURTLE_SPEED
Turtle speed for straight movements
|
static double |
TURTLE_STEP_FACTOR
Factor between turtle steps and motor rotation count
|
static int |
ULTRASONIC_SENSOR_POLL_DELAY |
static byte |
WRITE |
Constructor and Description |
---|
CompassSensor()
Creates a sensor instance connected to port S1 at location with
50 Hz household current frequency (e.g.
|
CompassSensor(SensorPort port)
Creates a sensor instance connected to the given port at location with
50 Hz household current frequency (e.g.
|
CompassSensor(SensorPort port,
boolean is50)
Creates a sensor instance connected to the given port at location with either
50 Hz or 60 Hz household current frequency.
|
Modifier and Type | Method and Description |
---|---|
void |
addCompassListener(CompassListener compassListener)
Registers the given compass listener with default trigger level 180.
|
void |
addCompassListener(CompassListener compassListener,
int triggerLevel)
Registers the given compass listener for the given trigger level.
|
byte[] |
getData(byte register,
int length)
Overrides I2CSensor.getData() because of unreliability when retrieving more than a single
byte at a time with some I2C sensors.
|
double |
getDegrees()
Polls the sensor.
|
int |
setTriggerLevel(int triggerLevel)
Sets a new trigger level and returns the previous one.
|
void |
startCalibration()
Starts calibration process.
|
void |
stopCalibration()
Stops calibration process.
|
getProductID, getSensorType, getVersion, sendData, sendData
public static final int MOTOR_SPEED
public static final double MOTOR_SPEED_FACTOR
public static final int GEAR_SPEED
public static final int GEAR_BRAKE_DELAY
public static final int GEAR_ACCELERATION_DELAY
public static final double AXE_LENGTH
public static final int TURTLE_SPEED
public static final double TURTLE_STEP_FACTOR
public static final int TURTLE_ROTATION_SPEED
public static final double TURTLE_ROTATION_FACTOR
public static final int CRAWLER_SPEED
public static final double CRAWLER_STEP_FACTOR
public static final int CRAWLER_ROTATION_SPEED
public static final double CRAWLER_ROTATION_FACTOR
public static final int SOUND_SENSOR_POLL_DELAY
public static final int LIGHT_SENSOR_POLL_DELAY
public static final int TOUCH_SENSOR_POLL_DELAY
public static final int ULTRASONIC_SENSOR_POLL_DELAY
public static final int MOTION_DETECTOR_POLL_DELAY
public static final int COMPASS_SENSOR_POLL_DELAY
public static final java.lang.String ABOUT
public static final byte DIRECT_COMMAND_REPLY
public static final byte SYSTEM_COMMAND_REPLY
public static final byte REPLY_COMMAND
public static final byte DIRECT_COMMAND_NOREPLY
public static final byte SYSTEM_COMMAND_NOREPLY
public static final byte OPEN_READ
public static final byte OPEN_WRITE
public static final byte READ
public static final byte WRITE
public static final byte CLOSE
public static final byte DELETE
public static final byte FIND_FIRST
public static final byte FIND_NEXT
public static final byte GET_FIRMWARE_VERSION
public static final byte OPEN_WRITE_LINEAR
public static final byte OPEN_READ_LINEAR
public static final byte OPEN_WRITE_DATA
public static final byte OPEN_APPEND_DATA
public static final byte BOOT
public static final byte SET_BRICK_NAME
public static final byte GET_DEVICE_INFO
public static final byte DELETE_USER_FLASH
public static final byte POLL_LENGTH
public static final byte POLL
public static final byte POLL_BUFFER
public static final byte HIGH_SPEED_BUFFER
public static final byte START_PROGRAM
public static final byte STOP_PROGRAM
public static final byte PLAY_SOUND_FILE
public static final byte PLAY_TONE
public static final byte SET_OUTPUT_STATE
public static final byte SET_INPUT_MODE
public static final byte GET_OUTPUT_STATE
public static final byte GET_INPUT_VALUES
public static final byte RESET_SCALED_INPUT_VALUE
public static final byte MESSAGE_WRITE
public static final byte RESET_MOTOR_POSITION
public static final byte GET_BATTERY_LEVEL
public static final byte STOP_SOUND_PLAYBACK
public static final byte KEEP_ALIVE
public static final byte LS_GET_STATUS
public static final byte LS_WRITE
public static final byte LS_READ
public static final byte GET_CURRENT_PROGRAM_NAME
public static final byte MESSAGE_READ
public static final byte MOTORON
public static final byte BRAKE
public static final byte REGULATED
public static final byte REGULATION_MODE_IDLE
public static final byte REGULATION_MODE_MOTOR_SPEED
public static final byte REGULATION_MODE_MOTOR_SYNC
public static final byte MOTOR_RUN_STATE_IDLE
public static final byte MOTOR_RUN_STATE_RAMPUP
public static final byte MOTOR_RUN_STATE_RUNNING
public static final byte MOTOR_RUN_STATE_RAMPDOWN
public static final byte NO_SENSOR
public static final byte SWITCH
public static final byte TEMPERATURE
public static final byte REFLECTION
public static final byte ANGLE
public static final byte LIGHT_ACTIVE
public static final byte LIGHT_INACTIVE
public static final byte SOUND_DB
public static final byte SOUND_DBA
public static final byte CUSTOM
public static final byte LOWSPEED
public static final byte LOWSPEED_9V
public static final byte NO_OF_SENSOR_TYPES
public static final byte RAWMODE
public static final byte BOOLEANMODE
public static final byte TRANSITIONCNTMODE
public static final byte PERIODCOUNTERMODE
public static final byte PCTFULLSCALEMODE
public static final byte CELSIUSMODE
public static final byte FAHRENHEITMODE
public static final byte ANGLESTEPSMODE
public static final byte SLOPEMASK
public static final byte MODEMASK
public static final byte NXJ_FIND_FIRST
public static final byte NXJ_FIND_NEXT
public CompassSensor(SensorPort port, boolean is50)
port
- the port where the sensor is plugged-inis50
- true, if current frequency is 50 Hz (e.g. Europe) false, if current frequency is 60 Hz (e.g. USA)public CompassSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic CompassSensor()
public void addCompassListener(CompassListener compassListener, int triggerLevel)
compassListener
- the CompassListener to become registered.triggerLevel
- the trigger level where the callback is triggeredpublic void addCompassListener(CompassListener compassListener)
compassListener
- the CompassListener to become registered.public int setTriggerLevel(int triggerLevel)
triggerLevel
- the new trigger levelpublic double getDegrees()
public void startCalibration()
stopCalibration()
public void stopCalibration()
startCalibration()
public byte[] getData(byte register, int length)