Gyrometer クラス

定義

x、y、z 軸に対して角速度値を提供するジャイロメーター センサーを表します。

public ref class Gyrometer sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Gyrometer final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class Gyrometer
Public NotInheritable Class Gyrometer
継承
Object Platform::Object IInspectable Gyrometer
属性

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

実装例については、ジャイロメーターのサンプルをご覧ください。

注釈

センサー データは、デバイスの固定センサー座標系に対して提供され、表示の向きに依存しません。 入力制御や画面上の要素の操作にセンサー データに依存するアプリケーションの場合、開発者は現在の表示方向を考慮し、データを適切に補正する必要があります。 センサー座標系の詳細については、「 センサー データと表示の向き」を参照してください。

次の例では、XAML と C# で構築された UWP アプリで GetDefault メソッドを使用してジャイロメーターへの接続を確立する方法を示します。 統合されたジャイロメーターが見つからない場合、メソッドは null 値を返します。

_gyrometer = Gyrometer.GetDefault();

次の例では、XAML で構築された UWP アプリが ReadingChanged イベント ハンドラーを登録する方法を示します。

private void ScenarioEnable(object sender, RoutedEventArgs e)
{
    if (_gyrometer != null)
    {
        // Establish the report interval
        _gyrometer.ReportInterval = _desiredReportInterval;

        Window.Current.VisibilityChanged += new WindowVisibilityChangedEventHandler(VisibilityChanged);
        _gyrometer.ReadingChanged += new TypedEventHandler<Gyrometer, GyrometerReadingChangedEventArgs>(ReadingChanged);

        ScenarioEnableButton.IsEnabled = false;
        ScenarioDisableButton.IsEnabled = true;
    }
    else
    {
        rootPage.NotifyUser("No gyrometer found", NotifyType.StatusMessage);
    }
}

次の例は、 ReadingChanged イベント ハンドラーを示しています。

async private void ReadingChanged(object sender, GyrometerReadingChangedEventArgs e)
{
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        GyrometerReading reading = e.Reading;
        ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.AngularVelocityX);
        ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.AngularVelocityY);
        ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.AngularVelocityZ);
    });
}

バージョン履歴

Windows のバージョン SDK バージョン 追加された値
1709 16299 FromIdAsync
1709 16299 GetDeviceSelector
1709 16299 MaxBatchSize
1709 16299 ReportLatency
2004 19041 ReportThreshold

プロパティ

DeviceId

デバイス識別子を取得します。

MaxBatchSize

センサーによってバッチ処理できるイベントの最大数を取得します。

MinimumReportInterval

ジャイロメーターでサポートされている最小レポート間隔を取得します。

ReadingTransform

センサー データに適用する必要がある変換を取得または設定します。 適用する変換は、センサー データの配置に使用する表示方向に関連付けられます。

ReportInterval

ジャイロメーターの現在のレポート間隔を取得または設定します。

ReportLatency

センサー情報のバッチ間の遅延を取得または設定します。

ReportThreshold

ジャイロメーター センサーの GyrometerDataThreshold を取得します。

メソッド

FromIdAsync(String)

センサーをその識別子から非同期に取得します。

GetCurrentReading()

現在のジャイロメーターの読み取り値を取得します。

GetDefault()

既定のジャイロメーターを返します。

GetDeviceSelector()

デバイス セレクターを取得します。

イベント

ReadingChanged

ジャイロメーターが現在のセンサーの読み取り値を報告するたびに発生します。

適用対象

こちらもご覧ください