ketai.sensors

## Class KetaiSensor

- java.lang.Object
- - ketai.sensors.KetaiSensor

- All Implemented Interfaces:
    android.hardware.SensorEventListener

      public class KetaiSensor
      extends java.lang.Object
      implements android.hardware.SensorEventListener

  The KetaiSensor class provides access to android sensors. To receive sensor data the following methods can be defined in your sketch:
  void onSensorEvent(SensorEvent e) - raw android sensor event
  void onAccelerometerEvent(float x, float y, float z, long a, int b): x,y,z force in m/s^2, a=timestamp(nanos), b=accuracy
  void onAccelerometerEvent(float x, float y, float z): x,y,z force in m/s2
  void onOrientationEvent(float x, float y, flaot z, long a, int b): x,y,z rotation in degrees, a=timestamp(nanos), b=accuracy
  void onOrientationEvent(float x, float y, float z) : x,y,z rotation in degrees
  void onMagneticFieldEvent(float x, float y, float z, long a, int b) : x,y,z geomag field in uT, a=timestamp(nanos), b=accuracy
  void onMagneticFieldEvent(float x, float y, float z): x,y,z geomagnetic field in uT
  void onGyroscopeEvent(float x, float y, float z, long a, int b):x,y,z rotation in rads/sec, a=timestamp(nanos), b=accuracy
  void onGyroscopeEvent(float x, float y, float z): x,y,z rotation in rads/sec
  void onGravityEvent(float x, float y, float z, long a, int b): x,y,z force of gravity in m/s^2, a=timestamp(nanos), b=accuracy
  void onGravityEvent(float x, float y, float z): x,y,z rotation in m/s^s
  void onProximityEvent(float d, long a, int b): d distance from sensor (typically 0,1), a=timestamp(nanos), b=accuracy
  void onProximityEvent(float d): d distance from sensor (typically 0,1)
  void onLightEvent(float d, long a, int b): d illumination from sensor in lx
  void onLightEvent(float d): d illumination from sensor in lx
  void onPressureEvent(float p, long a, int b): p ambient pressure in hPa or mbar, a=timestamp(nanos), b=accuracy
  void onPressureEvent(float p): p ambient pressure in hPa or mbar
  void onTemperatureEvent(float t, long a, int b): t temperature in degrees in degrees Celsius, a=timestamp(nanos), a=timestamp(nanos), b=accuracy
  void onTemperatureEvent(float t): t temperature in degrees in degrees Celsius
  void onLinearAccelerationEvent(float x, float y, float z, long a, int b): x,y,z acceleration force in m/s^2, minus gravity, a=timestamp(nanos), b=accuracy
  void onLinearAccelerationEvent(float x, float y, float z): x,y,z acceleration force in m/s^2, minus gravity
  void onRotationVectorEvent(float x, float y, float z, long a, int b): x,y,z rotation vector values, a=timestamp(nanos), b=accuracy
  void onRotationVectorEvent(float x, float y, float z):x,y,z rotation vector values
  void onAmibentTemperatureEvent(float t): same as temp above (newer API)
  void onRelativeHumidityEvent(float h): h ambient humidity in percentage

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.lang.Object` | `callbackdelegate`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KetaiSensor(processing.core.PApplet pParent)` Instantiates a new ketai sensor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `disableAccelerometer()` Disable accelerometer.
    `void` | `disableAmibentTemperature()` Disable ambient temperature.
    `void` | `disableGameRotationSensor()` Disable game rotation sensor.
    `void` | `disableGeomagneticRotationVectorSensor()` Disable geomagnetic rotation sensor.
    `void` | `disableGyroscope()` Disable gyroscope.
    `void` | `disableHeartRateSensor()` Disable heart rate sensor.
    `void` | `disableLight()` Disable light.
    `void` | `disablelinearAcceleration()` Disable linear acceleration.
    `void` | `disableMagneticField()` Disable magnetic field.
    `void` | `disableOrientation()` Disable orientation.
    `void` | `disablePressure()` Disable pressure.
    `void` | `disableProximity()` Disable proximity.
    `void` | `disableRelativeHumiditySensor()` Disable relative humidity sensor.
    `void` | `disableRotationVector()` Disable rotation vector.
    `void` | `disableSignificantMotionSensor()` Disable Significant Motion sensor.
    `void` | `disableStepCounterSensor()` Disable Step counter sensor.
    `void` | `disableStepDetectorSensor()` Disable Step counter sensor.
    `void` | `disableTemperature()` Disable temperature.
    `void` | `dispose()`
    `void` | `enableAccelerometer()` Enable accelerometer.
    `void` | `enableAllSensors()` Enable all sensors.
    `void` | `enableAmibentTemperature()` Enable ambient temperature.
    `void` | `enableGameRotationSensor()` Enable ambient game rotation sensor.
    `void` | `enableGeomagneticRotationVectorSensor()` Enable geomagnetic rotation sensor.
    `void` | `enableGyroscope()` Enable gyroscope.
    `void` | `enableHeartRateSensor()` Enable heart rate sensor.
    `void` | `enableLight()` Enable light.
    `void` | `enableLinearAcceleration()` Enable linear acceleration.
    `void` | `enableMagenticField()` Enable magentic field.
    `void` | `enableOrientation()` Enable orientation.
    `void` | `enablePressure()` Enable pressure.
    `void` | `enableProximity()` Enable proximity.
    `void` | `enableRelativeHumiditySensor()` Enable relative humidity sensor.
    `void` | `enableRotationVector()` Enable rotation vector.
    `void` | `enableSignificantMotionSensor()` Enable Significant Motion sensor.
    `void` | `enableStepCounterSensor()` Enable Step counter sensor.
    `void` | `enableStepDetectorSensor()` Enable Step counter sensor.
    `void` | `enableTemperature()` Enable temperature.
    `float[]` | `getOrientation()` Gets the orientation.
    `float[]` | `getOrientation(float[] v)` Gets the orientation.
    `void` | `getQuaternionFromVector(float[] Q, float[] rv)` Gets the quaternion from vector.
    `static void` | `getRotationMatrixFromVector(float[] R, float[] rotationVector)` Gets the rotation matrix from vector.
    `java.lang.String` | `getServiceDescription()` Gets the service description.
    `int` | `getStatus()` Gets the status.
    `boolean` | `isAccelerometerAvailable()` Checks if is accelerometer available.
    `boolean` | `isAmbientTemperatureAvailable()` Checks if is ambient temperature available.
    `boolean` | `isGameRotationAvailable()` Checks if is game rotation sensor is available.
    `boolean` | `isGeomagneticRotationVectorAvailable()` Checks if is geomagnetic rotation vector sensor is available.
    `boolean` | `isGyroscopeAvailable()` Checks if is gyroscope available.
    `boolean` | `isLightAvailable()` Checks if is light available.
    `boolean` | `isLinearAccelerationAvailable()` Checks if is linear acceleration available.
    `boolean` | `isMagenticFieldAvailable()` Checks if is magentic field available.
    `boolean` | `isOrientationAvailable()` Checks if is orientation available.
    `boolean` | `isPressureAvailable()` Checks if is pressure available.
    `boolean` | `isProximityAvailable()` Checks if is proximity available.
    `boolean` | `isRelativeHumidityAvailable()` Checks if is relative humidity available.
    `boolean` | `isRotationVectorAvailable()` Checks if is rotation vector available.
    `boolean` | `isSignificantMotionAvailable()` Checks if is significant motion sensor is available.
    `boolean` | `isStarted()` Checks if is started.
    `boolean` | `isStepCounterAvailable()` Checks if is step counter sensor is available.
    `boolean` | `isStepDetectorAvailable()` Checks if is step detector sensor is available.
    `boolean` | `isTemperatureAvailable()` Checks if is temperature available.
    `java.util.Collection<? extends java.lang.String>` | `list()` List.
    `void` | `onAccuracyChanged(android.hardware.Sensor sensor, int accuracy)`
    `void` | `onSensorChanged(android.hardware.SensorEvent arg0)`
    `void` | `post()`
    `void` | `register(java.lang.Object delegate)`
    `static boolean` | `remapCoordinateSystem(float[] inR, int X, int Y, float[] outR)`
    `void` | `setDelayInterval(long pDelayInterval)` Sets the delay interval.
    `void` | `start()` Start services.
    `void` | `startService()` Start service.
    `void` | `stop()` Stop services.
    `void` | `stopService()` Stop service.
    `void` | `useSimulator(boolean flag)` Use simulator.
    `boolean` | `usingSimulator()` Using simulator.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### callbackdelegate

          public java.lang.Object callbackdelegate

  - ### Constructor Detail

    - #### KetaiSensor

          public KetaiSensor(processing.core.PApplet pParent)

      Instantiates a new ketai sensor.
      Parameters:
        `pParent` - PApplet/sketch instance

  - ### Method Detail

    - #### remapCoordinateSystem

          public static boolean remapCoordinateSystem(float[] inR,
                                                      int X,
                                                      int Y,
                                                      float[] outR)

    - #### useSimulator

          public void useSimulator(boolean flag)

      Use simulator.
      Parameters:
        `flag` - the flag

    - #### usingSimulator

          public boolean usingSimulator()

      Using simulator.
      Returns:
        true, if successful

    - #### setDelayInterval

          public void setDelayInterval(long pDelayInterval)

      Sets the delay interval.
      Parameters:
        `pDelayInterval` - the new delay interval

    - #### enableAccelerometer

          public void enableAccelerometer()

      Enable accelerometer.

    - #### enableRotationVector

          public void enableRotationVector()

      Enable rotation vector.

    - #### enableLinearAcceleration

          public void enableLinearAcceleration()

      Enable linear acceleration.

    - #### disableAccelerometer

          public void disableAccelerometer()

      Disable accelerometer.

    - #### enableMagenticField

          public void enableMagenticField()

      Enable magentic field.

    - #### disableMagneticField

          public void disableMagneticField()

      Disable magnetic field.

    - #### enableOrientation

          public void enableOrientation()

      Enable orientation.

    - #### disableOrientation

          public void disableOrientation()

      Disable orientation.

    - #### enableProximity

          public void enableProximity()

      Enable proximity.

    - #### disableProximity

          public void disableProximity()

      Disable proximity.

    - #### disablelinearAcceleration

          public void disablelinearAcceleration()

      Disable linear acceleration.

    - #### disableRotationVector

          public void disableRotationVector()

      Disable rotation vector.

    - #### enableLight

          public void enableLight()

      Enable light.

    - #### disableLight

          public void disableLight()

      Disable light.

    - #### enablePressure

          public void enablePressure()

      Enable pressure.

    - #### disablePressure

          public void disablePressure()

      Disable pressure.

    - #### enableTemperature

          public void enableTemperature()

      Enable temperature.

    - #### disableTemperature

          public void disableTemperature()

      Disable temperature.

    - #### enableGyroscope

          public void enableGyroscope()

      Enable gyroscope.

    - #### disableGyroscope

          public void disableGyroscope()

      Disable gyroscope.

    - #### disableAmibentTemperature

          public void disableAmibentTemperature()

      Disable ambient temperature.

    - #### disableRelativeHumiditySensor

          public void disableRelativeHumiditySensor()

      Disable relative humidity sensor.

    - #### enableAmibentTemperature

          public void enableAmibentTemperature()

      Enable ambient temperature.

    - #### enableRelativeHumiditySensor

          public void enableRelativeHumiditySensor()

      Enable relative humidity sensor.

    - #### enableStepDetectorSensor

          public void enableStepDetectorSensor()

      Enable Step counter sensor.

    - #### disableStepDetectorSensor

          public void disableStepDetectorSensor()

      Disable Step counter sensor.

    - #### enableStepCounterSensor

          public void enableStepCounterSensor()

      Enable Step counter sensor.

    - #### disableStepCounterSensor

          public void disableStepCounterSensor()

      Disable Step counter sensor.

    - #### enableSignificantMotionSensor

          public void enableSignificantMotionSensor()

      Enable Significant Motion sensor.

    - #### disableSignificantMotionSensor

          public void disableSignificantMotionSensor()

      Disable Significant Motion sensor.

    - #### enableHeartRateSensor

          public void enableHeartRateSensor()

      Enable heart rate sensor.

    - #### disableHeartRateSensor

          public void disableHeartRateSensor()

      Disable heart rate sensor.

    - #### enableGeomagneticRotationVectorSensor

          public void enableGeomagneticRotationVectorSensor()

      Enable geomagnetic rotation sensor.

    - #### disableGeomagneticRotationVectorSensor

          public void disableGeomagneticRotationVectorSensor()

      Disable geomagnetic rotation sensor.

    - #### enableGameRotationSensor

          public void enableGameRotationSensor()

      Enable ambient game rotation sensor.

    - #### disableGameRotationSensor

          public void disableGameRotationSensor()

      Disable game rotation sensor.

    - #### enableAllSensors

          public void enableAllSensors()

      Enable all sensors.

    - #### isAccelerometerAvailable

          public boolean isAccelerometerAvailable()

      Checks if is accelerometer available.
      Returns:
        true, if is accelerometer available

    - #### isLinearAccelerationAvailable

          public boolean isLinearAccelerationAvailable()

      Checks if is linear acceleration available.
      Returns:
        true, if is linear acceleration available

    - #### isRotationVectorAvailable

          public boolean isRotationVectorAvailable()

      Checks if is rotation vector available.
      Returns:
        true, if is rotation vector available

    - #### isMagenticFieldAvailable

          public boolean isMagenticFieldAvailable()

      Checks if is magentic field available.
      Returns:
        true, if is magentic field available

    - #### isOrientationAvailable

          public boolean isOrientationAvailable()

      Checks if is orientation available.
      Returns:
        true, if is orientation available

    - #### isProximityAvailable

          public boolean isProximityAvailable()

      Checks if is proximity available.
      Returns:
        true, if is proximity available

    - #### isLightAvailable

          public boolean isLightAvailable()

      Checks if is light available.
      Returns:
        true, if is light available

    - #### isPressureAvailable

          public boolean isPressureAvailable()

      Checks if is pressure available.
      Returns:
        true, if is pressure available

    - #### isTemperatureAvailable

          public boolean isTemperatureAvailable()

      Checks if is temperature available.
      Returns:
        true, if is temperature available

    - #### isGyroscopeAvailable

          public boolean isGyroscopeAvailable()

      Checks if is gyroscope available.
      Returns:
        true, if is gyroscope available

    - #### isAmbientTemperatureAvailable

          public boolean isAmbientTemperatureAvailable()

      Checks if is ambient temperature available.
      Returns:
        true, if is ambient temperature available

    - #### isRelativeHumidityAvailable

          public boolean isRelativeHumidityAvailable()

      Checks if is relative humidity available.
      Returns:
        true, if is relative humidity available

    - #### isStepDetectorAvailable

          public boolean isStepDetectorAvailable()

      Checks if is step detector sensor is available.
      Returns:
        true, if heart rate sensor is available

    - #### isStepCounterAvailable

          public boolean isStepCounterAvailable()

      Checks if is step counter sensor is available.
      Returns:
        true, if step counter sensor is available

    - #### isSignificantMotionAvailable

          public boolean isSignificantMotionAvailable()

      Checks if is significant motion sensor is available.
      Returns:
        true, if significant motion sensor is available

    - #### isGeomagneticRotationVectorAvailable

          public boolean isGeomagneticRotationVectorAvailable()

      Checks if is geomagnetic rotation vector sensor is available.
      Returns:
        true, if geomagnetic rotation vector sensor is available

    - #### isGameRotationAvailable

          public boolean isGameRotationAvailable()

      Checks if is game rotation sensor is available.
      Returns:
        true, if game rotation sensor is available

    - #### list

          public java.util.Collection<? extends java.lang.String> list()

      List.
      Returns:
        the collection

    - #### isStarted

          public boolean isStarted()

      Checks if is started.
      Returns:
        true, if is started

    - #### start

          public void start()

      Start services.

    - #### stop

          public void stop()

      Stop services.

    - #### dispose

          public void dispose()

    - #### onSensorChanged

          public void onSensorChanged(android.hardware.SensorEvent arg0)

      Specified by:
        `onSensorChanged` in interface `android.hardware.SensorEventListener`

    - #### post

          public void post()

    - #### onAccuracyChanged

          public void onAccuracyChanged(android.hardware.Sensor sensor,
                                        int accuracy)

      Specified by:
        `onAccuracyChanged` in interface `android.hardware.SensorEventListener`

    - #### startService

          public void startService()

      Start service.

    - #### getStatus

          public int getStatus()

      Gets the status.
      Returns:
        the status (not used)

    - #### stopService

          public void stopService()

      Stop service.

    - #### getServiceDescription

          public java.lang.String getServiceDescription()

      Gets the service description.
      Returns:
        the service description

    - #### getRotationMatrixFromVector

          public static void getRotationMatrixFromVector(float[] R,
                                                         float[] rotationVector)

      Gets the rotation matrix from vector.
      Parameters:
        `R` - the r
        `rotationVector` - the rotation vector

    - #### getQuaternionFromVector

          public void getQuaternionFromVector(float[] Q,
                                              float[] rv)

      Gets the quaternion from vector.
      Parameters:
        `Q` - the q
        `rv` - the rv

    - #### getOrientation

          public float[] getOrientation()

      Gets the orientation.
      Returns:
        the orientation

    - #### getOrientation

          public float[] getOrientation(float[] v)

      Gets the orientation.
      Parameters:
        `v` - the vector to hold the orientation values
      Returns:
        the orientation vector

    - #### register

          public void register(java.lang.Object delegate)