Ejemplo n.º 1
0
    public virtual void Dispose()
    {
        UnityEngine.Object.Destroy(_mindReaderProxy);

        UnityThinkGear.StopStream();
        UnityThinkGear.Close();
    }
Ejemplo n.º 2
0
 /**
  * Singleton
  **/
 public static UnityThinkGear getInstance()
 {
     if(thinkGear == null){
         thinkGear = new UnityThinkGear();
     }
     return thinkGear;
 }
 // Use this for initialization
 void Start()
 {
     sendRawEnable    = UnityThinkGear.GetSendRawEnable();
     sendEEGEnable    = UnityThinkGear.GetSendEEGEnable();
     sendESenseEnable = UnityThinkGear.GetSendESenseEnable();
     sendBlinkEnable  = UnityThinkGear.GetSendBlinkEnable();
 }
Ejemplo n.º 4
0
 /**
  * Singleton
  **/
 public static UnityThinkGear getInstance()
 {
     if (thinkGear == null)
     {
         thinkGear = new UnityThinkGear();
     }
     return(thinkGear);
 }
 // Use this for initialization
 void Start()
 {
     sendRawEnable          = UnityThinkGear.GetSendRawEnable();
     sendEEGEnable          = UnityThinkGear.GetSendEEGEnable();
     sendESenseEnable       = UnityThinkGear.GetSendESenseEnable();
     sendBlinkEnable        = UnityThinkGear.GetSendBlinkEnable();
     UpdateMeditationEvent += OnUpdateMeditationEvent;
 }
 void Start()
 {
     sendRawEnable    = UnityThinkGear.GetSendRawEnable();
     sendEEGEnable    = UnityThinkGear.GetSendEEGEnable();
     sendESenseEnable = UnityThinkGear.GetSendESenseEnable();
     sendBlinkEnable  = UnityThinkGear.GetSendBlinkEnable();
     checkUpdate      = true;
 }
    void CheckUpdateEvent()
    {
        if (!sendRawEnable && (UpdateRawdataEvent != null))
        {
            sendRawEnable = true;
            UnityThinkGear.SetSendRawEnable(true);
        }
        if (sendRawEnable && UpdateRawdataEvent == null)
        {
            sendRawEnable = false;
            UnityThinkGear.SetSendRawEnable(false);
        }

        if (!sendEEGEnable &&
            (UpdateDeltaEvent != null || UpdateThetaEvent != null ||
             UpdateLowAlphaEvent != null || UpdateLowBetaEvent != null ||
             UpdateLowGammaEvent != null || UpdateHighAlphaEvent != null ||
             UpdateHighBetaEvent != null || UpdateHighGammaEvent != null))
        {
            sendEEGEnable = true;
            UnityThinkGear.SetSendEEGEnable(true);
        }
        if (sendEEGEnable &&
            UpdateDeltaEvent == null && UpdateThetaEvent == null &&
            UpdateLowAlphaEvent == null && UpdateLowBetaEvent == null &&
            UpdateLowGammaEvent == null && UpdateHighAlphaEvent == null &&
            UpdateHighBetaEvent == null && UpdateHighGammaEvent == null)
        {
            sendEEGEnable = false;
            UnityThinkGear.SetSendEEGEnable(false);
        }

        if (!sendESenseEnable &&
            (UpdateAttentionEvent != null || UpdateMeditationEvent != null))
        {
            sendESenseEnable = true;
            UnityThinkGear.SetSendESenseEnable(true);
        }
        if (sendESenseEnable &&
            UpdateAttentionEvent == null && UpdateMeditationEvent == null)
        {
            sendESenseEnable = false;
            UnityThinkGear.SetSendESenseEnable(false);
        }

        if (!sendBlinkEnable && (UpdateBlinkEvent != null))
        {
            sendBlinkEnable = true;
            UnityThinkGear.SetSendBlinkEnable(true);
        }
        if (sendBlinkEnable && UpdateBlinkEvent == null)
        {
            sendBlinkEnable = false;
            UnityThinkGear.SetSendBlinkEnable(false);
        }
    }
Ejemplo n.º 8
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label("Demo App");
        GUILayout.Space(Screen.width - 250);
        GUILayout.Label(signalIcons[(int)indexSignalIcons]);
        GUILayout.EndHorizontal();

        if (GUI.Button(new Rect(190, 20, 100, 80), "Init"))
        {
            UnityThinkGear.Init(true);
        }

        if (GUI.Button(new Rect(190, 140, 100, 80), "Connect"))
        {
            print("Connect Button CLick");
                        #if UNITY_IPHONE
            clearDataArr();
            UnityThinkGear.ScanDevice();
            showListViewFlag = true;
                        #elif UNITY_ANDROID
            UnityThinkGear.StartStream();
                        #endif
        }

        if (GUI.Button(new Rect(190, 250, 100, 80), "Quit"))
        {
            Application.Quit();
        }

        if (showListViewFlag)
        {
            //andrew code;  show device list view;
            GUILayout.BeginArea(new Rect(rectX, rectY, rectWidth, rectHeight));
            windowRect = GUILayout.Window(0, new Rect(rectX, rectY, rectWidth, rectHeight), DeviceListWindow, "Device List");
            GUILayout.EndArea();
        }


        GUILayout.BeginVertical();
        GUILayout.Label("Raw:" + Raw);
        GUILayout.Label("PoorSignal:" + PoorSignal);
        GUILayout.Label("Attention:" + Attention);
        GUILayout.Label("Meditation:" + Meditation);
        GUILayout.Label("Blink:" + Blink);
        GUILayout.Label("Delta:" + Delta);
        GUILayout.Label("Theta:" + Theta);
        GUILayout.Label("LowAlpha:" + LowAlpha);
        GUILayout.Label("HighAlpha:" + HighAlpha);
        GUILayout.Label("LowBeta:" + LowBeta);
        GUILayout.Label("HighBeta:" + HighBeta);
        GUILayout.Label("LowGamma:" + LowGamma);
        GUILayout.Label("HighGamma:" + HighGamma);

        GUILayout.EndVertical();
    }
Ejemplo n.º 9
0
    public MindReader()
    {
        _meditation = new FloatReference {
            useConstantValue = true
        };
        _focus = new FloatReference {
            useConstantValue = true
        };

        UnityThinkGear.Init(true);
        UnityThinkGear.StartStream();

        _mindReaderProxy = SetupProxy();
    }
Ejemplo n.º 10
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label("Demo App");
        GUILayout.Space(Screen.width - 250);
        GUILayout.Label(signalIcons[(int)indexSignalIcons]);
        GUILayout.EndHorizontal();

        if (GUI.Button(new Rect(90, 20, 100, 80), "Init"))
        {
            UnityThinkGear.Init(true);
        }

        if (GUI.Button(new Rect(90, 140, 100, 80), "Start"))
        {
            UnityThinkGear.StartStream();
        }

        if (GUI.Button(new Rect(90, 250, 100, 80), "Quit"))
        {
            Application.Quit();
        }

        GUILayout.BeginVertical();
        GUILayout.Label("Raw:" + Raw);
        GUILayout.Label("PoorSignal:" + PoorSignal);
        GUILayout.Label("Attention:" + Attention);
        GUILayout.Label("Meditation:" + Meditation);
        GUILayout.Label("Blink:" + Blink);
        GUILayout.Label("Delta:" + Delta);
        GUILayout.Label("Theta:" + Theta);
        GUILayout.Label("LowAlpha:" + LowAlpha);
        GUILayout.Label("HighAlpha:" + HighAlpha);
        GUILayout.Label("LowBeta:" + LowBeta);
        GUILayout.Label("HighBeta:" + HighBeta);
        GUILayout.Label("LowGamma:" + LowGamma);
        GUILayout.Label("HighGamma:" + HighGamma);

        GUILayout.EndVertical();
    }
Ejemplo n.º 11
0
    void DeviceListWindow(int windowID)
    {
        var buttonStyle = new GUIStyle("Button");

        buttonStyle.fontSize = 40;


        scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(rectWidth), GUILayout.Height(rectHeight));
        for (int i = 0; i < deviceList.Count; i++)
        {
            if (GUILayout.Button(displayedStrArr[i] + "", buttonStyle))
            {
                print("Click " + deviceList[i]);
                                #if UNITY_IPHONE
                UnityThinkGear.ConnectDevice(deviceList[i] + "");
                                #endif
                dismissListView();
            }
        }

        // End the scrollview we began above.
        GUILayout.EndScrollView();
    }
Ejemplo n.º 12
0
 void Awake()
 {
     thinkGear = UnityThinkGear.getInstance();
 }
Ejemplo n.º 13
0
 public void Connect()
 {
     Debug.Log("Connect Button Click");
     UnityThinkGear.StartStream();
 }
Ejemplo n.º 14
0
 public void Init()
 {
     Debug.Log("Init Button Click");
     UnityThinkGear.Init(true);
 }
Ejemplo n.º 15
0
 void OnApplicationQuit()
 {
     checkUpdate = false;
     UnityThinkGear.StopStream();
     UnityThinkGear.Close();
 }
    //====================


    void OnApplicationQuit()
    {
        UnityThinkGear.StopStream();
        UnityThinkGear.Close();
    }
Ejemplo n.º 17
0
 void Awake()
 {
     UnityThinkGear.Init(true);
     StartCoroutine(CheckUpdateCoroutine());
 }
 void Awake()
 {
     UnityThinkGear.Init(true);
     InvokeRepeating("CheckUpdateEvent", 0.0f, 1.0f);
 }
Ejemplo n.º 19
0
    IEnumerator CheckUpdateCoroutine()
    {
        while (checkUpdate)
        {
            if (!sendRawEnable && (UpdateRawdataEvent != null))
            {
                sendRawEnable = true;
                UnityThinkGear.SetSendRawEnable(sendRawEnable);
            }

            if (sendRawEnable && UpdateRawdataEvent == null)
            {
                sendRawEnable = false;
                UnityThinkGear.SetSendRawEnable(sendRawEnable);
            }

            if (!sendEEGEnable &&
                (UpdateDeltaEvent != null || UpdateThetaEvent != null ||
                 UpdateLowAlphaEvent != null || UpdateLowBetaEvent != null ||
                 UpdateLowGammaEvent != null || UpdateHighAlphaEvent != null ||
                 UpdateHighBetaEvent != null || UpdateHighGammaEvent != null))
            {
                sendEEGEnable = true;
                UnityThinkGear.SetSendEEGEnable(sendEEGEnable);
            }

            if (sendEEGEnable &&
                UpdateDeltaEvent == null && UpdateThetaEvent == null &&
                UpdateLowAlphaEvent == null && UpdateLowBetaEvent == null &&
                UpdateLowGammaEvent == null && UpdateHighAlphaEvent == null &&
                UpdateHighBetaEvent == null && UpdateHighGammaEvent == null)
            {
                sendEEGEnable = false;
                UnityThinkGear.SetSendEEGEnable(sendEEGEnable);
            }

            if (!sendESenseEnable && (UpdateAttentionEvent != null || UpdateMeditationEvent != null))
            {
                sendESenseEnable = true;
                UnityThinkGear.SetSendESenseEnable(sendESenseEnable);
            }

            if (sendESenseEnable && UpdateAttentionEvent == null && UpdateMeditationEvent == null)
            {
                sendESenseEnable = false;
                UnityThinkGear.SetSendESenseEnable(sendESenseEnable);
            }

            if (!sendBlinkEnable && (UpdateBlinkEvent != null))
            {
                sendBlinkEnable = true;
                UnityThinkGear.SetSendBlinkEnable(sendBlinkEnable);
            }

            if (sendBlinkEnable && UpdateBlinkEvent == null)
            {
                sendBlinkEnable = false;
                UnityThinkGear.SetSendBlinkEnable(sendBlinkEnable);
            }

            yield return(new WaitForSeconds(1f));
        }
    }
Ejemplo n.º 20
0
 public void connect()
 {
     UnityThinkGear.StartStream();
 }
Ejemplo n.º 21
0
 void Awake()
 {
     thinkGear = UnityThinkGear.getInstance();
 }