Magnetometer Class¶
Description¶
Magnetometer调用了系统提供的磁力计,输出 MagnetometerResult 。
当不再需要该设备时,可以调用close对其进行关闭。close之后不应继续使用。
不建议同时打开多次磁力计,可能会无法使用或精度下降。
Constructor¶
- C
void easyar_Magnetometer__ctor(easyar_Magnetometer * * Return)
- C++
Magnetometer()
- Java
public Magnetometer()
- Kotlin
constructor()
- Objective-C
+ (easyar_Magnetometer *) create
- Swift
public convenience init()
- C#
public Magnetometer()
isAvailable¶
检查是否可用。只在Android或iOS上且硬件支持时返回true。其他操作系统暂不支持。
- C
bool easyar_Magnetometer_isAvailable(easyar_Magnetometer * This)
- C++
bool isAvailable()
- Java
public boolean isAvailable()
- Kotlin
fun isAvailable(): Boolean
- Objective-C
- (bool)isAvailable
- Swift
public func isAvailable() -> Bool
- C#
public virtual bool isAvailable()
output¶
输出端口。
- C
void easyar_Magnetometer_output(easyar_Magnetometer * This, easyar_MagnetometerResultSource * * Return)
- C++
std::shared_ptr<MagnetometerResultSource> output()
- Java
public @Nonnull MagnetometerResultSource output()
- Kotlin
fun output(): MagnetometerResultSource
- Objective-C
- (easyar_MagnetometerResultSource *)output
- Swift
public func output() -> MagnetometerResultSource
- C#
public virtual MagnetometerResultSource output()
open¶
打开设备。采样周期由内部实现所确定。如果打开失败,返回false。
- C
bool easyar_Magnetometer_open(easyar_Magnetometer * This)
- C++
bool open()
- Java
public boolean open()
- Kotlin
fun open(): Boolean
- Objective-C
- (bool)open
- Swift
public func `open`() -> Bool
- C#
public virtual bool open()
openWithSamplingPeriod¶
以特定采样周期打开设备。采样周期会受到硬件限制而可能无法达到指定值。如果打开失败,返回false。
- C
bool easyar_Magnetometer_openWithSamplingPeriod(easyar_Magnetometer * This, int samplingPeriodMilliseconds)
- C++
bool openWithSamplingPeriod(int samplingPeriodMilliseconds)
- Java
public boolean openWithSamplingPeriod(int samplingPeriodMilliseconds)
- Kotlin
fun openWithSamplingPeriod(samplingPeriodMilliseconds: Int): Boolean
- Objective-C
- (bool)openWithSamplingPeriod:(int)samplingPeriodMilliseconds
- Swift
public func openWithSamplingPeriod(_ samplingPeriodMilliseconds: Int32) -> Bool
- C#
public virtual bool openWithSamplingPeriod(int samplingPeriodMilliseconds)
close¶
关闭设备。close之后不应继续使用。
- C
void easyar_Magnetometer_close(easyar_Magnetometer * This)
- C++
void close()
- Java
public void close()
- Kotlin
fun close(): Unit
- Objective-C
- (void)close
- Swift
public func close() -> Void
- C#
public virtual void close()
getCurrentResult¶
获取当前的最新结果。如果结果尚未获取到,返回空。
- C
easyar_OptionalOfMagnetometerResult easyar_Magnetometer_getCurrentResult(easyar_Magnetometer * This)
- C++
std::optional<MagnetometerResult> getCurrentResult()
- Java
public @Nullable MagnetometerResult getCurrentResult()
- Kotlin
fun getCurrentResult(): MagnetometerResult?
- Objective-C
- (easyar_MagnetometerResult *)getCurrentResult
- Swift
public func getCurrentResult() -> MagnetometerResult?
- C#
public virtual Optional<MagnetometerResult> getCurrentResult()