Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui improvements #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions BrainWaveOSC/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,34 @@ void ofApp::setup(){
allData.eegTheta = 0;
allData.elapsed = 0;
allData.blinkStrength = 0;

normaliseMaxToCurrentSet = false;

// default device settings
deviceName = "/dev/tty.BrainBand-DevB"; // osx address, windows is com6 or something
normaliseMaxToCurrentSet = false;

setupGui();
refreshDevices();
updateDeviceInfo();
// default device settings // TODO automatize setup
if (devicesList.empty()) {
#if defined(TARGET_OSX)
deviceName = "/dev/tty.BrainBand-DevB";
#elif defined(TARGET_LINUX)
deviceName = "/dev/rfcomm0";
#elif defined(TARGET_WIN32)
deviceName = "COM6";
#endif
} else {
deviceName = devicesList[0];
}
deviceBaudRate = 57600;

ofLog() << "Initial values: \n"
<< "Device name: " << deviceName << "\n"
<< "Baudrate: " << deviceBaudRate << "\n";

// osc settings
host = "127.0.0.1"; // change via xml
port = 7771; // change via xml
receivePort=7772; // change via xml

setupGui();

// setup thinkgear hardware using serial streamer or comms driver (osx only tested).
// TG_STREAM_PARSER is default
Expand All @@ -91,11 +106,23 @@ void ofApp::setup(){
// change in settings.xml to launch minimised window with no logging
if(smallWindow) {
ofSetLogLevel(OF_LOG_SILENT);
ofSetWindowShape(250, 75);
setSmallWindow();
settings.hide();
} else {
setNormalWindow();
}
}

void ofApp::setSmallWindow() {
ofSetWindowShape(250, 75);
smallWindow = true;
}

void ofApp::setNormalWindow() {
ofSetWindowShape(1280, 850);
smallWindow = false;
}

void ofApp::setupGui() {

// setup gui
Expand Down
22 changes: 19 additions & 3 deletions BrainWaveOSC/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class ofApp : public ofBaseApp {
void setupGui();
BrainWaveGUI settings;
void onGUIChanged(ofxTouchGUIEventArgs& args);
void setSmallWindow();
void setNormalWindow();
bool smallWindow;


Expand All @@ -79,13 +81,17 @@ class ofApp : public ofBaseApp {
EegFrequencyGraph* frequencyGraph;
ofxTouchGUISlider* timeline;
vector<EegTimeGraph*> eegSet;

ofxTouchGUIDropDown* deviceChooser;
ofxTouchGUIDropDown* baudrateChooser;
ofxTouchGUIButton* refreshButton;
ofxTouchGUIButton* disconnectButton;
ofxTouchGUIButton* connectButton;

bool normaliseMaxToCurrentSet;

float startTime;
float timeElapsed;


// file saving
ofFile output;
bool isRecording;
Expand All @@ -103,9 +109,20 @@ class ofApp : public ofBaseApp {
int receivePort;

// mindplay brainband bluetooth device
void updateDeviceInfo();
void refreshDevices();
void setupDevice(int id);
void setupBaudrate(int id);
void connectDevice();
void disconnectDevice();
bool deviceIsConnected = false;
ofxThinkgear tg;
ofxThinkgearEventArgs data;
string deviceName;
string deviceInfoString;

vector<string> devicesList;
vector<string> baudrateList;
int deviceBaudRate;

// custom eeg data struct to capture all the data from thinkgear events
Expand All @@ -119,5 +136,4 @@ class ofApp : public ofBaseApp {
int playhead;
vector<EegData> dataEntries;


};