?>

Hard Copy World

HCW

Q&A

Home > Forum >

Q&A

코드입니다!

페이지 정보

작성자 기린 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 작성일16-05-21 01:25 조회733회 댓글1건

본문

package viewapp.lecture.com.mindwave_example2;

import android.bluetooth.BluetoothAdapter;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;


import com.neurosky.thinkgear.TGDevice;
import com.neurosky.thinkgear.TGEegPower;

public class MainActivity extends AppCompatActivity {

    private TGDevice tgDevice;
    final boolean rawEnabled = false;

    private BluetoothAdapter bluetoothAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        int deta = 0;

        TextView textView = (TextView) findViewById(R.id.text);
        textView.setText(deta);

        initialize();
    }

    private void initialize() {
        setupBT();
        doStuff();
    }

    private void setupBT() {
        bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (bluetoothAdapter == null) {
            // Alert user that Bluetooth is not available
            Toast.makeText(this, "Bluetooth not available", Toast.LENGTH_LONG).show();
            finish();
            return;
        } else {
           /* create the TGDevice */
            tgDevice = new TGDevice(bluetoothAdapter, mHandler);
        }
    }

    private void doStuff() {
        if (tgDevice.getState() != TGDevice.STATE_CONNECTING
                && tgDevice.getState() != TGDevice.STATE_CONNECTED)
            tgDevice.connect(rawEnabled);
    }

    private final Handler mHandler = new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.what) {

                case TGDevice.MSG_EEG_POWER:

                    TGEegPower ep = (TGEegPower) msg.obj;
                    TGEegPower ep_normalized = new TGEegPower();
                    int deta = 0;

                    ep_normalized.lowBeta = deta;





            }
        }
    };
}



댓글목록