Permalink
Browse files

Supported tACS device and NZT-48 channel for ADHD training.

  • Loading branch information...
IAmCoder committed May 22, 2014
1 parent bf996a3 commit ef9a2f91a45a2c6fd83e0200282777e58d7360e7
Showing with 32,577 additions and 81 deletions.
  1. +3 −3 Installer/Lucid Scribe ThinkGear EEG.vdproj
  2. BIN Lucid Scribe - ThinkGear EEG.suo
  3. +222 −54 ThinkGear EEG/PluginHandler.cs
  4. +119 −7 ThinkGear EEG/PortForm.Designer.cs
  5. +133 −13 ThinkGear EEG/PortForm.cs
  6. +2 −2 ThinkGear EEG/PortForm.resx
  7. +2 −2 ThinkGear EEG/Properties/AssemblyInfo.cs
  8. BIN ThinkGear EEG/References/YocoWrapper.dll
  9. BIN ThinkGear EEG/References/yapi.dll
  10. +4 −0 ThinkGear EEG/ThinkGear EEG.csproj
  11. +36 −0 ThinkGear EEG/YoctoWrapper/Properties/AssemblyInfo.cs
  12. +99 −0 ThinkGear EEG/YoctoWrapper/YocoWrapper.csproj
  13. +20 −0 ThinkGear EEG/YoctoWrapper/YocoWrapper.sln
  14. BIN ThinkGear EEG/YoctoWrapper/YocoWrapper.suo
  15. +2 −0 ThinkGear EEG/YoctoWrapper/yocto_api/dll/README.txt
  16. BIN ThinkGear EEG/YoctoWrapper/yocto_api/dll/amd64/yapi.dll
  17. BIN ThinkGear EEG/YoctoWrapper/yocto_api/dll/yapi.dll
  18. +419 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_accelerometer.cs
  19. +413 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_altitude.cs
  20. +804 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_anbutton.cs
  21. +7,961 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_api.cs
  22. +317 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_carbondioxide.cs
  23. +608 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_colorled.cs
  24. +374 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_compass.cs
  25. +317 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_current.cs
  26. +999 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_datalogger.cs
  27. +940 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_digitalio.cs
  28. +1,965 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_display.cs
  29. +418 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_dualpower.cs
  30. +534 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_files.cs
  31. +538 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_genericsensor.cs
  32. +1,135 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_gyro.cs
  33. +419 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_hubport.cs
  34. +317 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_humidity.cs
  35. +469 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_led.cs
  36. +356 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_lightsensor.cs
  37. +419 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_magnetometer.cs
  38. +918 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_motor.cs
  39. +1,461 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_network.cs
  40. +336 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_oscontrol.cs
  41. +448 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_power.cs
  42. +317 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_pressure.cs
  43. +805 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_pwmoutput.cs
  44. +346 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_pwmpowersource.cs
  45. +471 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_realtimeclock.cs
  46. +1,102 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_refframe.cs
  47. +789 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_relay.cs
  48. +736 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_servo.cs
  49. +405 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_temperature.cs
  50. +340 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_tilt.cs
  51. +317 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_voc.cs
  52. +317 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_voltage.cs
  53. +690 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_wakeupmonitor.cs
  54. +711 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_wakeupschedule.cs
  55. +1,071 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_watchdog.cs
  56. +633 −0 ThinkGear EEG/YoctoWrapper/yocto_api/yocto_wireless.cs
@@ -2210,14 +2210,14 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Lucid Scribe ThinkGear EEG"
"ProductCode" = "8:{FD30C0A8-CF53-4205-B3C8-A21FE7FF50B3}"
"PackageCode" = "8:{417BBF1E-6993-43F7-AC3A-A38ED5A1065E}"
"ProductCode" = "8:{B7BBD380-8DDD-47CF-A45A-231978ABAEAB}"
"PackageCode" = "8:{FAAFE6AF-2450-4A43-BCFD-11E3D8025E2F}"
"UpgradeCode" = "8:{9B1E2A82-9D73-4675-9717-2311206ABC4E}"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.0.9"
"ProductVersion" = "8:1.1.0"
"Manufacturer" = "8:lucidcode"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://www.lucidcode.com/Contact"
BIN +0 Bytes (100%) Lucid Scribe - ThinkGear EEG.suo
Binary file not shown.
@@ -8,6 +8,8 @@
using System.Runtime.InteropServices;
using System.Drawing;
using System.Linq;
using System.IO;
using System.Xml;

namespace lucidcode.LucidScribe.Plugin.NeuroSky.MindSet
{
@@ -42,6 +44,12 @@ public static class Device
private static double DisplayValue;
private static double HighscoreValue;
public static Boolean TCMP = false;
public static Boolean NZT48 = false;
public static Boolean tACS = false;
public static String Target = "ANY";
public static String StateOn = "A";
public static String StateOff = "A";
public static Boolean REMDetected = false;

public static EventHandler<ThinkGearChangedEventArgs> ThinkGearChanged;

@@ -64,6 +72,12 @@ public static Boolean Initialize()
Algorithm = formPort.Algorithm;
Threshold = formPort.Threshold;
TCMP = formPort.TCMP;
NZT48 = formPort.NZT48;
tACS = formPort.tACS;
Target = formPort.Target;
StateOn = formPort.StateOn;
StateOff = formPort.StateOff;

m_boolInitialized = true;
}
else
@@ -136,7 +150,7 @@ static void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEv
}
}



public static void Dispose()
{
@@ -497,7 +511,103 @@ public override double Value
}

if (boolDreaming)
{ return 888; }
{
// Check if we need to turn on a tACS device
if (Device.tACS)
{
try
{
YocoWrapper.YRelay relay;
string errorMessage = "";

if (YocoWrapper.YAPI.RegisterHub("usb", ref errorMessage) != YocoWrapper.YAPI.SUCCESS)
{
MessageBox.Show("tACS RegisterHub error: " + errorMessage, "LucidScribe.ThinkGearEEG.DetectREM()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

if (Device.Target == "ANY")
{
relay = YocoWrapper.YRelay.FirstRelay();
if (relay == null)
{
MessageBox.Show("tACS RegisterHub error: No module connected (check USB cable).", "LucidScribe.ThinkGearEEG.DetectREM()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else relay = YocoWrapper.YRelay.FindRelay(Device.Target + ".relay1");

if (relay.isOnline())
{
if (Device.StateOn == "A")
{
relay.set_state(YocoWrapper.YRelay.STATE_A);
}
else
{
relay.set_state(YocoWrapper.YRelay.STATE_B);
}
}
else
{
MessageBox.Show("tACS RegisterHub error: Module not connected (check USB cable).", "LucidScribe.ThinkGearEEG.DetectREM()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{ }
}

Device.REMDetected = true;
return 888;
}
else
{
if (Device.REMDetected)
{
Device.REMDetected = false;

// Check if we need to turn off a tACS device
if (Device.tACS)
{
try
{
YocoWrapper.YRelay relay;
string errorMessage = "";

if (YocoWrapper.YAPI.RegisterHub("usb", ref errorMessage) != YocoWrapper.YAPI.SUCCESS)
{
MessageBox.Show("tACS RegisterHub error: " + errorMessage, "LucidScribe.ThinkGearEEG.DetectREM()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

if (Device.Target == "ANY")
{
relay = YocoWrapper.YRelay.FirstRelay();
if (relay == null)
{
MessageBox.Show("tACS RegisterHub error: No module connected (check USB cable).", "LucidScribe.ThinkGearEEG.DetectREM()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else relay = YocoWrapper.YRelay.FindRelay(Device.Target + ".relay1");

if (relay.isOnline())
{
if (Device.StateOff == "A")
{
relay.set_state(YocoWrapper.YRelay.STATE_A);
}
else
{
relay.set_state(YocoWrapper.YRelay.STATE_B);
}
}
else
{
MessageBox.Show("tACS RegisterHub error: Module not connected (check USB cable).", "LucidScribe.ThinkGearEEG.DetectREM()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{ }
}
}
}

if (intBlinks > 10) { intBlinks = 10; }
return intBlinks * 100;
@@ -547,7 +657,7 @@ public override bool Initialize()
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
}
}

private static String Morse = "";
Dictionary<char, String> Code = new Dictionary<char, String>()
{
@@ -626,7 +736,7 @@ public override double Value

if (!FirstTick && (tempValue > dotHeight))
{
m_arrHistory.Add(Convert.ToInt32(tempValue));
m_arrHistory.Add(Convert.ToInt32(tempValue));
}

if (!FirstTick && m_arrHistory.Count > 0)
@@ -654,79 +764,79 @@ public override double Value

if (!FirstTick && m_arrHistory.Count > 32)
{
int nextOffset = 0;
do
int nextOffset = 0;
do
{
int fivePointValue = 0;
for (int i = nextOffset; i < m_arrHistory.Count; i++)
{
int fivePointValue = 0;
for (int i = nextOffset; i < m_arrHistory.Count; i++)
for (int x = i; x < m_arrHistory.Count; x++)
{
for (int x = i; x < m_arrHistory.Count; x++)
if (m_arrHistory[x] > fivePointValue)
{
if (m_arrHistory[x] > fivePointValue)
{
fivePointValue = m_arrHistory[x];
}

if (m_arrHistory[x] < 300)
{
nextOffset = x + 1;
break;
}

if (x == m_arrHistory.Count - 1)
{
nextOffset = -1;
}
fivePointValue = m_arrHistory[x];
}

if (fivePointValue >= dashHeight)
if (m_arrHistory[x] < 300)
{
signal += "-";
signalLength++;
break;
}
else if (fivePointValue >= dotHeight)
{
signal += ".";
signalLength++;
nextOffset = x + 1;
break;
}

if (i == m_arrHistory.Count - 1)
{
if (x == m_arrHistory.Count - 1)
{
nextOffset = -1;
}

}

if (nextOffset < 0 | nextOffset == m_arrHistory.Count)
if (fivePointValue >= dashHeight)
{
signal += "-";
signalLength++;
break;
}
else if (fivePointValue >= dotHeight)
{
signal += ".";
signalLength++;
break;
}

} while (true);
if (i == m_arrHistory.Count - 1)
{
nextOffset = -1;
}

m_arrHistory.RemoveAt(0);
}

// Check if the signal is morse
try
if (nextOffset < 0 | nextOffset == m_arrHistory.Count)
{
// Make sure that we have a signal
if (signal != "")
{
var myValue = Code.First(x => x.Value == signal);
Morse = myValue.Key.ToString();
SendKeys.Send(myValue.Key.ToString());
signal = "";
m_arrHistory.Clear();
SpaceSent = false;
TicksSinceSpace = 0;
}
break;
}
catch (Exception ex)

} while (true);

m_arrHistory.RemoveAt(0);

// Check if the signal is morse
try
{
// Make sure that we have a signal
if (signal != "")
{
String err = ex.Message;
var myValue = Code.First(x => x.Value == signal);
Morse = myValue.Key.ToString();
SendKeys.Send(myValue.Key.ToString());
signal = "";
m_arrHistory.Clear();
SpaceSent = false;
TicksSinceSpace = 0;
}
}
catch (Exception ex)
{
String err = ex.Message;
}
}

if (m_arrHistory.Count > 0)
@@ -754,6 +864,64 @@ public override void Dispose()
}
}

namespace NZT48
{
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
{

public override string Name
{
get
{
return "NZT-48";
}
}

public override bool Initialize()
{
try
{
return Device.Initialize();
}
catch (Exception ex)
{
throw (new Exception("The '" + Name + "' plugin failed to initialize: " + ex.Message));
}
}

public override double Value
{
get
{
if (!Device.NZT48) { return 0; }

double tempValue = 0;

if (Device.Algorithm == "Beta")
{
tempValue = Device.GetBeta();
}

if (tempValue > 999) { tempValue = 999; }
if (tempValue < 0) { tempValue = 0; }

if (tempValue > Device.Threshold)
{
return 888;
}

return 0;
}
}

public override void Dispose()
{
Device.Dispose();
}

}
}

namespace Attention
{
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
Oops, something went wrong.

0 comments on commit ef9a2f9

Please sign in to comment.