Garmin Data Fields作ってみた(1)

GarminのData Fields を作ってみました。

Data Fieldsとは

Data Fieldsとは、アプリケーションのタイプの一つで、ガーミンアクティビティーアプリ(ランとかバイク等)にpluginして画面を拡張できるアプリタイプです。

Data Fields と Simple Data Fieldsの2種類があります。

  • Simple Data Fieldsは単一の数値や文字列を表示する機能が実現できます。Simpleとあるように画面レイアウトなどを考えなくてよい利点があります。
  • Data Fieldsは複数のデータを表示できます。画面レイアウトなどを自分で実装する必要がある分だけ、すこし複雑です。

作るアプリ

横浜マラソン2022の関門(チェックポイント)を表示するData Fieldsを作ってみます。

表示したいデータは3種類あるのですが、Simple Data Filedsを3つ作ることで簡単に済ませましょう(※注:これはあとで痛い目を・・・)

  • 次の関門までの距離
  • 次の関門までの時間
  • 次の関門の通過予定の余裕時間(先行/遅れ)

 

コード

WatchUi.SimpleDataFieldを派生したクラスを作ります。

computeメソッドで表示したい文字列を返します

class CheckpointYokohama2022View1 extends WatchUi.SimpleDataField {
    private var _yokohama as Yokohama2022;

    // Set the label of the data field here.
    function initialize() {
        SimpleDataField.initialize();
        label = "CP to go";
        _yokohama = new Yokohama2022();
    }

    // The given info object contains all the current workout
    // information. Calculate a value and return it in this method.
    // Note that compute() and onUpdate() are asynchronous, and there is no
    // guarantee that compute() will be called before onUpdate().
    function compute(info as Activity.Info) as Numeric or Duration or String or Null {
        // See Activity.Info in the documentation for available information.
        var distance = _yokohama.RemainDistanceToCP((info.elapsedDistance != null) ? info.elapsedDistance : 0.0);
        return _yokohama.FormatDistance(distance);
    }
}

これと似たメソッドを計3個準備して、別のアプリとしてデバイスにインストールします。

これで準備完了

 

本体設定

Garminの本体取説を見ながら Data Fieldsを設定します。

 

3つのData Fieldsを設定します・・・・

  • 次の関門までの距離 → OK
  • 次の関門までの時間 → OK
  • 次の関門の通過予定の余裕時間 → NG! あれ?

「Connect IQデータ項目設定を削除するか、入れ替えてください」

なん、、だと、、!

 

意味が分からないので調べてみると、どうもCustom Data Fieldsは2個までしか使えないらしい!

 

終わった・・・続く