Permalink
Browse files

Merged Jef's tweaks and added Arduino output.

  • Loading branch information...
IAmCoder committed Jun 27, 2014
1 parent b26b1fd commit 83c100979571d79782373bd7852f4898a7f111fe
@@ -688,14 +688,14 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Lucid Scribe Zeo"
"ProductCode" = "8:{4D90A9B6-4D96-4F61-AE79-92AD576E51F5}"
"PackageCode" = "8:{7119841F-AD0D-4020-AC4E-852B33BAA180}"
"ProductCode" = "8:{DA057EF6-624F-4888-A215-9C9FE698C4F8}"
"PackageCode" = "8:{C439F669-27CB-495C-AF20-8630CB36F7D0}"
"UpgradeCode" = "8:{7FC45659-EDA9-401F-A2DB-7EE30232BDE8}"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:0.9.5"
"ProductVersion" = "8:0.9.6"
"Manufacturer" = "8:lucidcode"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://www.lucid-code.com/Support"
13 LICENSE

This file was deleted.

Oops, something went wrong.
BIN +2.5 KB (120%) Lucid Scribe - Zeo.suo
Binary file not shown.
@@ -19,6 +19,12 @@ public static class Device
private static ZeoStream zeoStream;
private static ManualResetEvent exitEvent = new ManualResetEvent(false);

public static Boolean Arduino = false;
public static String ArduinoPort = "COM1";
public static String ArduinoDelay = "1";
public static String ArduinoOn = "1";
public static String ArduinoOff = "0";

public static Boolean Initialize()
{
try
@@ -32,6 +38,12 @@ public static Boolean Initialize()
PortForm formPort = new PortForm();
if (formPort.ShowDialog() == DialogResult.OK)
{
Arduino = formPort.Arduino;
ArduinoPort = formPort.ArduinoPort;
ArduinoDelay = formPort.ArduinoDelay;
ArduinoOn = formPort.ArduinoOn;
ArduinoOff = formPort.ArduinoOff;

if (zeoStream.OpenLiveStream(formPort.SelectedPort))
{
m_boolInitialized = true;
@@ -61,27 +73,20 @@ public static void Dispose()

public static Double GetValueEEG()
{
float total = 0;

ChannelData[] channels = zeoStream.ReadEegFromLastPosition(ref eegLastPosition, 100);

foreach (ChannelData channelData in channels)
ChannelData[] channels = zeoStream.ReadEegFromLastPosition(ref eegLastPosition, 1);
if (channels.Length > 0)
{
foreach (float value in channelData.Values)
{
total += value;
}
return channels[0].Values[0] * 1000;
}

return total;
return 0;
}

public static Double GetValueStage()
{
ChannelData[] channels = zeoStream.ReadStageDataFromLastPosition(ref stageLastPosition, 100);
ChannelData[] channels = zeoStream.ReadStageDataFromLastPosition(ref stageLastPosition, 1);
if (channels.Length > 0)
{
return channels[0].Values[0] * 100;
return channels[0].Values[0] * -100;
}
return 0;
}
@@ -121,6 +126,7 @@ namespace Stage
{
public class PluginHandler : lucidcode.LucidScribe.Interface.LucidPluginBase
{
Thread ArduinoThread;
public override string Name
{
get { return "Stage"; }
@@ -134,11 +140,44 @@ public override double Value
get
{
double dblValue = Device.GetValueStage();

// Check if we are dreaming
if (dblValue == 200)
{
// Check if we need to send a message to an arduino
if (Device.Arduino)
{
Device.Arduino = false; // Set false so we don't call it again before the thread completes / after the delay
ArduinoThread = new Thread(TriggerArduino);
ArduinoThread.Start();
}
}

if (dblValue > 999) { dblValue = 999; }
if (dblValue < 0) { dblValue = 0; }
return dblValue;
}
}

private void TriggerArduino()
{
SerialPort arduinoPort = new SerialPort();
arduinoPort.PortName = Device.ArduinoPort;
arduinoPort.BaudRate = 9600;
arduinoPort.Open();

arduinoPort.WriteLine(Device.ArduinoOn);

int arduinoDelay = Convert.ToInt32(Device.ArduinoDelay) * 60000;
Thread.Sleep(arduinoDelay);

arduinoPort.WriteLine(Device.ArduinoOff);

arduinoPort.Close();
arduinoPort.Dispose();

Device.Arduino = true;
}
}
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 83c1009

Please sign in to comment.