Permalink
Browse files

Made the amount of channels configurable and fixed the averaging in t…

…he main channel.
  • Loading branch information...
IAmCoder committed Oct 22, 2013
1 parent 5602c13 commit 3a6e368023fd9b55a2557d9ba439fcecfb41bb43
@@ -970,14 +970,14 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Lucid Scribe OpenEEG"
"ProductCode" = "8:{AD1F7480-2EB0-4042-BB29-468EECD03200}"
"PackageCode" = "8:{7C870E6F-379E-4A16-A4AA-DDE89F1F0130}"
"ProductCode" = "8:{EBDC52BA-A9EF-42C8-9601-9204D306C427}"
"PackageCode" = "8:{05ECB0EF-6F3A-4E64-B226-1A7EEB04F739}"
"UpgradeCode" = "8:{D21B48DC-E942-48EA-9916-C569C46778E4}"
"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"
BIN +0 Bytes (100%) Lucid Scribe - OpenEEG.suo
Binary file not shown.
@@ -33,6 +33,9 @@ public static Boolean Initialize()
{
try
{
// Set the amount of channels
channels = formPort.Channels;

// Open the COM port
serialPort = new SerialPort(formPort.SelectedPort);
serialPort.BaudRate = 57600;
@@ -86,12 +89,15 @@ static void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e
int activeChannels = 0;
for (int i = 0; i < channels; i++)
{
eegChannels[i] = (buffer[(i * 2) + 2] * 256) + buffer[(i * 2) + 3];
total += eegChannels[i];

if (eegChannels[i] > 0)
if (buffer.Length >= (i * 2) + 3)
{
activeChannels++;
eegChannels[i] = (buffer[(i * 2) + 2] * 256) + buffer[(i * 2) + 3];

if (eegChannels[i] > 0)
{
activeChannels++;
total += eegChannels[i];
}
}
}

@@ -100,6 +106,7 @@ static void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e
eegValue = total / activeChannels;
}
}

index++;
lastByte = num;
}
@@ -265,7 +272,7 @@ public override double Value


// Update the mem list
m_arrHistory.Add(Convert.ToInt32(Device.GetChannel1()));
m_arrHistory.Add(Convert.ToInt32(Device.GetEEG()));
if (m_arrHistory.Count > 512) { m_arrHistory.RemoveAt(0); }

// Check for 3 blinks

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

Oops, something went wrong.
@@ -6,13 +6,19 @@
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Xml;
using System.IO;

namespace lucidcode.LucidScribe.Plugin.OpenEEG
{
public partial class PortForm : Form
{

public String SelectedPort = "";
public int Channels = 2;

private Boolean loaded = false;
private string m_strPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\lucidcode\\Lucid Scribe\\";

public PortForm()
{
@@ -22,6 +28,8 @@ public PortForm()
private void PortForm_Load(object sender, EventArgs e)
{
LoadPortList();
LoadSettings();
loaded = true;
}

private void LoadPortList()
@@ -63,6 +71,41 @@ private void LoadPortList()
}
}

private void LoadSettings()
{
XmlDocument xmlSettings = new XmlDocument();

if (!File.Exists(m_strPath + "Plugins\\OpenEEG.User.lsd"))
{
String defaultSettings = "<LucidScribeData>";
defaultSettings += "<Plugin>";
defaultSettings += "<Channels>2</Channels>";
defaultSettings += "</Plugin>";
defaultSettings += "</LucidScribeData>";
File.WriteAllText(m_strPath + "Plugins\\OpenEEG.User.lsd", defaultSettings);
}

xmlSettings.Load(m_strPath + "Plugins\\OpenEEG.User.lsd");
cmbChannels.Text = xmlSettings.DocumentElement.SelectSingleNode("//Channels").InnerText;
}

private void cmbChannels_SelectedIndexChanged(object sender, EventArgs e)
{
if (!loaded) { return; }
Channels = Convert.ToInt32(cmbChannels.Text);
SaveSettings();
}

private void SaveSettings()
{
String defaultSettings = "<LucidScribeData>";
defaultSettings += "<Plugin>";
defaultSettings += "<Channels>" + cmbChannels.Text + "</Channels>";
defaultSettings += "</Plugin>";
defaultSettings += "</LucidScribeData>";
File.WriteAllText(m_strPath + "Plugins\\OpenEEG.User.lsd", defaultSettings);
}

private void lstPlaylists_MouseMove(object sender, MouseEventArgs e)
{
if (lstPorts.GetItemAt(e.X, e.Y) != null)
@@ -89,5 +132,6 @@ private void mnuRefresh_Click(object sender, EventArgs e)
{
LoadPortList();
}

}
}
@@ -125,10 +125,10 @@
</metadata>
<data name="lstImg.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACW
DQAAAk1TRnQBSQFMAwEBAAFoAQABaAEAAR8BAAEcAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABfAMA
DQAAAk1TRnQBSQFMAwEBAAFwAQABcAEAAR8BAAEcAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABfAMA
ARwDAAEBAQABGAUAAbABKBIAXf//ABgABv8B6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHW
AccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHW
AccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6QHWAccB6AHX
@@ -193,7 +193,16 @@
<data name="Label5.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsEAAA7BAbiRa+0AAACXSURBVDhPnZDBDcAgCEU9uFF3YqfePHQc745j860kiGBr
YQUAAAAJcEhZcwAADsAAAA7AAWrWiQkAAACXSURBVDhPnZDBDcAgCEU9uFF3YqfePHQc745j860kiGBr
X0JMLP9JCStKKTWlq+LsV3sgDI6D/gnwMsK/JwDbr2PsVfU2HzRZ5JzbOUn0pj1BjHGoFgYcwL+iPIFk
EOhNs4CIzAKDQCMFkkBnC4JpAoSsCQCCXKaAA3oHnwWrHciwK9CwAE1W8bfePsOCFa8C+aJXT3cIN4jJ
kEFaMsuqAAAAAElFTkSuQmCC
</value>
</data>
<data name="label4.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADrwAAA68AZW8ckkAAACXSURBVDhPnZDBDcAgCEU9uFF3YqfePHQc745j860kiGBr
X0JMLP9JCStKKTWlq+LsV3sgDI6D/gnwMsK/JwDbr2PsVfU2HzRZ5JzbOUn0pj1BjHGoFgYcwL+iPIFk
EOhNs4CIzAKDQCMFkkBnC4JpAoSsCQCCXKaAA3oHnwWrHciwK9CwAE1W8bfePsOCFa8C+aJXT3cIN4jJ
kEFaMsuqAAAAAElFTkSuQmCC
Oops, something went wrong.

0 comments on commit 3a6e368

Please sign in to comment.