Package com.gluonhq.attach.accelerometer
Interface AccelerometerService
-
- All Known Implementing Classes:
AndroidAccelerometerService,DummyAccelerometerService,IOSAccelerometerService,MobileAccelerometerService
public interface AccelerometerServiceAn accelerometer measures the acceleration force that is applied to a device in all three physical axes (x, y and z).The AccelerometerService provides a read-only
acceleration propertythat is updated at regular intervals by the underlying platform implementation. A user of the AccelerometerService can listen to changes of the acceleration force, by registering aChangeListenerto theacceleration property.Example
AccelerometerService.create().ifPresent(service -> { service.start(); Acceleration acceleration = service.getCurrentAcceleration(); System.out.printf("Current acceleration: %.2f, %.2f, %.2f", acceleration.getX(), acceleration.getY(), acceleration.getZ()); });Android Configuration: none
iOS Configuration: none
- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static ParametersDEFAULT_PARAMETERSDefault frequency is 50 Hz (50 samples per second).
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description javafx.beans.property.ReadOnlyObjectProperty<Acceleration>accelerationProperty()A frequently-updated reading from the accelerometer.static java.util.Optional<AccelerometerService>create()Returns an instance ofAccelerometerService.AccelerationgetCurrentAcceleration()Returns a single reading from the accelerometer.voidstart()Starts the service withDEFAULT_PARAMETERS.voidstart(Parameters parameters)Starts the service with given parameters.voidstop()Stops the service.
-
-
-
Field Detail
-
DEFAULT_PARAMETERS
static final Parameters DEFAULT_PARAMETERS
Default frequency is 50 Hz (50 samples per second). By default, gravity is not filtered.
-
-
Method Detail
-
create
static java.util.Optional<AccelerometerService> create()
Returns an instance ofAccelerometerService.- Returns:
- An instance of
AccelerometerService.
-
getCurrentAcceleration
Acceleration getCurrentAcceleration()
Returns a single reading from the accelerometer.- Returns:
- the current accelerometer reading
-
accelerationProperty
javafx.beans.property.ReadOnlyObjectProperty<Acceleration> accelerationProperty()
A frequently-updated reading from the accelerometer.- Returns:
- A property containing a frequently-updated accelerometer reading.
-
start
void start()
Starts the service withDEFAULT_PARAMETERS.- Since:
- 4.0.11
-
start
void start(Parameters parameters)
Starts the service with given parameters.- Parameters:
parameters- Parameters for configuring the service- Since:
- 4.0.11
-
stop
void stop()
Stops the service.- Since:
- 4.0.11
-
-