// 데이터가 존재하는 경우
if(m_acc_data != null && m_mag_data != null) {
// 가속 데이터와 자기장 데이터로 회전 매트릭스를 얻는다.
SensorManager.getRotationMatrix(m_rotation, null, m_acc_data, m_mag_data);
// 회전 매트릭스로 방향 데이터를 얻는다.
SensorManager.getOrientation(m_rotation, m_result_data);
String str;
// Radian 값을 Degree 값으로 변환한다.
m_result_data[0] = (float)Math.toDegrees(m_result_data[0]);
// 0 이하의 값인 경우 360을 더한다.
if(m_result_data[0] < 0) m_result_data[0] += 360;
// 첫번째 데이터인 방위값으로 문자열을 구성하여 텍스트뷰에 출력한다.
str = "azimuth(z) : " + (int)m_result_data[0];
m_result_view[0].setText(str);
// 두번째 데이터인 경사도를 Degree 로 변환한 후 문자열을 구성하여 출력한다.
str = "pitch(x) : " + (int)Math.toDegrees(m_result_data[1]);
m_result_view[1].setText(str);
// 세번째 데이터인 좌우 회전 값을 Degree 로 변환한 후 문자열을 구성하여 출력한다.
str = "roll(y) : " + (int)Math.toDegrees(m_result_data[2]);
m_result_view[2].setText(str);
if(m_result_data[2]>20)
{
Toast.makeText(this, "This activity ends.", Toast.LENGTH_SHORT).show();
String message = "S";
BluetoothChat.sendMessage(message);
}
// 함수의 출력횟수를 텍스트뷰에 출력한다.
m_check_count++;
str = "호출 횟수 : " + m_check_count + " 회";
m_check_view.setText(str);
}
}
}
방향센서를 이용해서
부분에서 azimuth(z), pitch(x), roll(y) 값중에서 y값이 20이상이면 토스트 띄우고, 블루투스를 이용해서 문자전송을 할려고 하는데
블루투스 액티비티는 따로 BluetoothChat액티비에 있구요
따로 액티비티를 만들어서 센서 검출 및 테스트 중인데
저 루틴부분이 실행이되지않네요...
int고 배열이라서 토스트라고 뜰줄 알았는데.. 아무런 반응이없네요..
고수분들 부탁드립니다..