LoginSignup
1
1

More than 5 years have passed since last update.

Samsung Gear での各種センサーについてのメモ

Posted at

はじめに

  • Sumsung Gear で使えるセンサーについて確認し、いくつかのセンサーを試してみましたので、そのメモです。

Gear S/2 での対応状況と対応API

注意: HTML5 はブラウザによって対応状況が違う思われます。

センサー Gear S Gear 2 HTML5 Samsung Extension / Interface
加速度センサー DeviceMotionEvent
ジャイロセンサー DeviceOrientationEvent
近接センサー DeviceProximityEvent Sensor API / ProximitySensor
UVセンサー × Sensor API / UltravioletSensor
気圧計センサー × Sensor API / PressureSensor
地磁気センサー × Sensor API / MagneticSensor
照度センサー × DeviceLightEvent Sensor API / LightSensor
心拍数センサー Motion API / MotionHRMInfo
歩数計 Motion API / MotionPedometerInfo
GPS Geolocation API Motion API / MotionGPSInfo
ゼスチャー Motion API / MotionHandGestureInfo

動作確認

照度センサー

main.js
$(window).load(function(){
    document.addEventListener('tizenhwkey', function(e) {
        if(e.keyName == "back") {
            tizen.application.getCurrentApplication().exit();
        }
    });

    var lightSensor = webapis.sensorservice.getDefaultSensor("LIGHT");

    function onGetSuccess(sensorData) {
        $('#textbox').html(sensorData.lightLevel);
    }

    function lightSensorStart() {
        lightSensor.getLightSensorData(onGetSuccess);
    }

    lightSensor.start(lightSensorStart);
});

UVセンサー

照度センサーと使い方はほとんど同じですね。

main.js
$(window).load(function(){
    document.addEventListener('tizenhwkey', function(e) {
        if(e.keyName == "back") {
            tizen.application.getCurrentApplication().exit();
        }
    });

    var ultravioletSensor = webapis.sensorservice.getDefaultSensor("ULTRAVIOLET");

    function onGetSuccess(sensorData) {
        $('#textbox').html(sensorData.ultravioletLevel);
    }

    function onSuccess() {
        ultravioletSensor.getUltravioletSensorData(onGetSuccess);
    }

    ultravioletSensor.start(onSuccess);
});

感想

  • config.xml で Features や Privileges あたりの設定が必要なのかと思ったけど、そのままで動いてしまったな。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1