motion


Motion는 3.0.0 버전 이상 부터 제공되며 해당 라이브러리를 추가하여 사용해야 된다.

getCurrent

현재 단말의 동작 정보를 얻는다. 

successCallback

필드필드설명
result Motion 상세 정보
x단말의 x 값 
y단말의 y 값
z단말의 z 값
timestamp이벤트 발생 시간
   

errorCallback

필드설명
없음없음
  

Example

hone.channel.execute('motion', 'getCurrent', [],
   function (result) {
        alert(JSON.stringify(result));
    }, function (e) {
        alert(JSON.stringify(e));
    }
);

Result

{
"timestamp": 1491281499376,
"x": -1.7764976,
"y": 8.027759,
"z": 5.357026
}

watch

현재 단말 동작 정보를 주기적으로 얻는다.

options

필드설명
motionId이벤트 아이디 (반드시 hone.util.getMotionWatchId(); 으로 아이디를 얻어야 한다.)
delay

화면 갱신 시간 설정

0 : FASTEST (18 ~ 20ms)

1 : GAME (37 ~ 39ms)

2 : UI (85 ~ 87ms)

3 : NORMAL (215 ~ 230ms)

  

successCallback

필드필드설명
result Motion 상세 정보
x단말의 x 값 
y단말의 y 값
z단말의 z 값
timestamp이벤트 발생 시간
   

errorCallback

필드설명
없음없음
  

Example

var motionId = hone.util.getMotionWatchId();
var delay    = 3;

hone.channel.execute('motion', 'watch', [motionId, delay],
   function (result) {
        console.log(JSON.stringify(result));
    }, function (e) {
        alert(JSON.stringify(e));
    }
);

Result

{
"timestamp": 1491281499376,
"x": -1.7764976,
"y": 8.027759,
"z": 5.357026
}

clearWatch

동작중인 watch를 종료한다.

options

필드설명
watchId동작중인 watchId
  

successCallback

필드설명
없음없음
  

errorCallback

필드설명
없음없음
  

Example

// motionId 는 watch 에서 생성한 hone.util.getMotionWatchId(); 값을 사용한다.
var motionId = '10';
hone.util.clearMotionWatchId(motionId);
hone.channel.execute('motion', 'clearWatch', [motionId],
   function (result) {
        alert(JSON.stringify(result));
    }, function (e) {
        alert(JSON.stringify(e));
    }
);