Example #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);

    bindService();

    Button btn = (Button) findViewById(R.id.btnBTCtest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnRSteptest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnHRSTtest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnAccTest);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnStop);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnSetRun20);
    btn.setOnClickListener(this);
    btn = (Button) findViewById(R.id.btnSetRunContinue);
    btn.setOnClickListener(this);

    gGraph0 = (ResultGraphDashBoard) findViewById(R.id.rgdb_0);
    gGraph0.setRangeMax(800, 1024);
    gGraph1 = (MultiGraphDashBoard) findViewById(R.id.rgdb_1);

    gGraph1.addSeries(getResources().getColor(R.color.opaque_shadow));
    gGraph1.addSeries(getResources().getColor(R.color.orange));
    gGraph1.addSeries(getResources().getColor(R.color.mint));
    gGraph1.setRangeMax(512, 1024);

    gSoundpool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
    sp1 = gSoundpool.load(this, R.raw.wood1, 1);
    sp2 = gSoundpool.load(this, R.raw.wood2, 1);
  }
Example #2
0
        @Override
        public void rcvedData(M1DATA m1Data) {
          // 데이터가 수신될때마다 호출됨
          // TODO Auto-generated method stub
          switch (m1Data.TYPE) {
            case M1DATA.MSG_HRSTRESS:
              gMsg = String.format("HR = %d, STRESS = %.1f", m1Data.HR, m1Data.STRESS);
              mHandler.sendEmptyMessage(m1Data.TYPE);
              break;
            case M1DATA.MSG_STEP:
              gMsg = String.format("STEP = %d", m1Data.STEP);
              mHandler.sendEmptyMessage(m1Data.TYPE);
              break;
            case M1DATA.MSG_ACC:
              gECG = (m1Data.ECG);
              gGraph0.addValue((double) gECG);

              gAccX = m1Data.ACC_X;
              gAccY = m1Data.ACC_Y;
              gAccZ = m1Data.ACC_Z;
              gGraph1.addValue(0, gAccX);
              gGraph1.addValue(1, gAccY);
              gGraph1.addValue(2, gAccZ);
              break;

            default:
              break;
          }
        }
Example #3
0
        @Override
        public void handleMessage(Message msg) {
          // TODO Auto-generated method stub
          super.handleMessage(msg);

          switch (msg.what) {
            case M1DATA.MSG_HRSTRESS:
              updateText();
              break;
            case M1DATA.MSG_STEP:
              updateText();
              break;
            case M1DATA.MSG_ACC:
              gGraph0.addValue(gECG);
              gGraph1.addValue(gAccX);
              gGraph1.setCurrentValue(gAccX);
              break;

            default:
              break;
          }
        }
Example #4
0
  @Override
  public void onClick(View v) {
    try {
      switch (v.getId()) {
        case R.id.btnBTCtest:
          gSoundpool.play(sp2, 1, 1, 0, 0, 1);
          connectBT();
          break;
        case R.id.btnStop:
          gSoundpool.play(sp1, 1, 1, 0, 0, 1);
          g_BluetoothService.stopDeviceMode();
          break;
        case R.id.btnRSteptest:
          gSoundpool.play(sp2, 1, 1, 0, 0, 1);
          gMsg = "-";
          updateText();
          g_BluetoothService.clearData();
          g_BluetoothService.getStep();
          break;
        case R.id.btnHRSTtest:
          gSoundpool.play(sp1, 1, 1, 0, 0, 1);
          gMsg = "-";
          updateText();

          g_BluetoothService.clearData();
          g_BluetoothService.getHrStress();

          gGraph0.resetData();

          gGraph0.setVisibility(View.VISIBLE);
          gGraph1.setVisibility(View.INVISIBLE);
          gGraph0.drawStart();
          break;
        case R.id.btnAccTest:
          gSoundpool.play(sp1, 1, 1, 0, 0, 1);
          gMsg = "-";
          updateText();
          g_BluetoothService.clearData();
          g_BluetoothService.getAccelerometer();

          gGraph1.resetData();

          gGraph0.setVisibility(View.INVISIBLE);
          gGraph1.setVisibility(View.VISIBLE);

          gGraph1.drawStart();
          break;
        case R.id.btnSetRun20:
          gSoundpool.play(sp2, 1, 1, 0, 0, 1);
          gMsg = "-";
          updateText();
          g_BluetoothService.setRunningTime(BluetoothService.RT_20SEC);
          break;
        case R.id.btnSetRunContinue:
          gSoundpool.play(sp1, 1, 1, 0, 0, 1);
          gMsg = "-";
          updateText();
          g_BluetoothService.setRunningTime(BluetoothService.RT_CONTINUE);
          break;
      }
    } catch (RemoteException e) {

    }
  }