Comparar commits
69 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 2761a5b1a2 | |||
| dc9323b054 | |||
| 0cb4b11e0b | |||
| 509777d3f5 | |||
| dbd834d984 | |||
| 1ff75e6f95 | |||
| 115487d836 | |||
| 8c66932056 | |||
| 1f28dafe94 | |||
| 323e885fc4 | |||
| 5fedeaaba5 | |||
| 5fe2bd05f8 | |||
| a62bca7c1c | |||
| 4d04bd9579 | |||
| dd2d4213f8 | |||
| 8bae43d42d | |||
| f391f81714 | |||
| 3f65c7025e | |||
| a1cbf00e17 | |||
| 1ffaf36773 | |||
| d299144c4d | |||
| 1c10b32370 | |||
| c3cde4a1da | |||
| bf85663aec | |||
| ae2926c5c8 | |||
| b1def1c571 | |||
| 71d89867d8 | |||
| d985991963 | |||
| dcdb26966a | |||
| 3cea932784 | |||
| 0319ac6f74 | |||
| b228461253 | |||
| 059a9361a9 | |||
| d48df5a5ad | |||
| 2e9e78ab32 | |||
| fe88c989e4 | |||
| 04f20ed19b | |||
| d34c9dc2a0 | |||
| f98ffefebf | |||
| f81407334c | |||
| 8293b9d351 | |||
| 9901d7e33d | |||
| 0bb7ec9fbe | |||
| 9bedcde9fd | |||
| ff46af0905 | |||
| 0ca326c631 | |||
| 65af974303 | |||
| 83079cf2c9 | |||
| 9354f353b6 | |||
| e08b8f4083 | |||
| 5acb6fcff0 | |||
| a61c01a775 | |||
| cd4f70e4ec | |||
| 6a08af2712 | |||
| 9467e6b2a2 | |||
| 0132b045d1 | |||
| 3372e1c12a | |||
| e9b30d1441 | |||
| d341697768 | |||
| 8d46b3b8af | |||
| 30411a1c46 | |||
| 49b11027be | |||
| d78d86ee8f | |||
| b52ab1d5ec | |||
| bef37245bf | |||
| 7138b90059 | |||
| 8a69084f8e | |||
| bcb0be39c3 | |||
| 3158f18a04 |
@@ -0,0 +1,21 @@
|
||||
# 2.1.2
|
||||
|
||||
### Bug Fixes
|
||||
* Fix #120 - Locale dependent formatting cause issue with output ODF file.
|
||||
|
||||
# 2.1.1
|
||||
|
||||
### Bug Fixes
|
||||
* Fix #111 - No compatible USB now shows error in output, not an annoying popup.
|
||||
|
||||
# 2.1.0
|
||||
|
||||
### Breaking Changes
|
||||
* Removed space in GanglionHub to be able to kill the hub on windows.
|
||||
|
||||
### Bug Fixes
|
||||
* Issue #111 where Windows users saw error message from Ganglion Hub on start up if no hub selected.
|
||||
|
||||
# 2.0.0
|
||||
|
||||
* Initial Release
|
||||
@@ -33,24 +33,6 @@ CallbackListener cb = new CallbackListener() { //used by ControlP5 to clear text
|
||||
} else if (cp5.isMouseOver(cp5.get(Textfield.class, "fileNameGanglion"))){
|
||||
println("CallbackListener: controlEvent: clearing");
|
||||
cp5.get(Textfield.class, "fileNameGanglion").clear();
|
||||
} else if (cp5.isMouseOver(cp5.get(Textfield.class, "udp_ip"))){
|
||||
println("CallbackListener: controlEvent: clearing");
|
||||
cp5.get(Textfield.class, "udp_ip").clear();
|
||||
} else if (cp5.isMouseOver(cp5.get(Textfield.class, "udp_port"))){
|
||||
println("CallbackListener: controlEvent: clearing");
|
||||
cp5.get(Textfield.class, "udp_port").clear();
|
||||
} else if (cp5.isMouseOver(cp5.get(Textfield.class, "osc_ip"))){
|
||||
println("CallbackListener: controlEvent: clearing");
|
||||
cp5.get(Textfield.class, "osc_ip").clear();
|
||||
} else if (cp5.isMouseOver(cp5.get(Textfield.class, "osc_address"))){
|
||||
println("CallbackListener: controlEvent: clearing");
|
||||
cp5.get(Textfield.class, "osc_address").clear();
|
||||
} else if (cp5.isMouseOver(cp5.get(Textfield.class, "lsl_data"))){
|
||||
println("CallbackListener: controlEvent: clearing");
|
||||
cp5.get(Textfield.class, "lsl_data").clear();
|
||||
} else if (cp5.isMouseOver(cp5.get(Textfield.class, "lsl_aux"))){
|
||||
println("CallbackListener: controlEvent: clearing");
|
||||
cp5.get(Textfield.class, "lsl_aux").clear();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -76,8 +58,6 @@ color isSelected_color = color(184, 220, 105);
|
||||
// Button openClosePort;
|
||||
// boolean portButtonPressed;
|
||||
|
||||
int networkType = 0;
|
||||
|
||||
boolean calledForBLEList = false;
|
||||
|
||||
Button refreshPort;
|
||||
@@ -102,13 +82,13 @@ Button popOut;
|
||||
Button getChannel;
|
||||
Button setChannel;
|
||||
Button ovrChannel;
|
||||
Button getPoll;
|
||||
Button setPoll;
|
||||
Button defaultBAUD;
|
||||
Button highBAUD;
|
||||
// Button getPoll;
|
||||
// Button setPoll;
|
||||
// Button defaultBAUD;
|
||||
// Button highBAUD;
|
||||
Button autoscan;
|
||||
Button autoconnectNoStartDefault;
|
||||
Button autoconnectNoStartHigh;
|
||||
// Button autoconnectNoStartDefault;
|
||||
// Button autoconnectNoStartHigh;
|
||||
Button systemStatus;
|
||||
|
||||
Button synthChanButton4;
|
||||
@@ -127,16 +107,6 @@ RadioConfigBox rcBox;
|
||||
|
||||
public void controlEvent(ControlEvent theEvent) {
|
||||
|
||||
if (theEvent.isFrom("serialListConfig")) {
|
||||
Map bob = ((MenuList)theEvent.getController()).getItem(int(theEvent.getValue()));
|
||||
serialNameEMG = (String)bob.get("headline");
|
||||
println(serialNameEMG);
|
||||
}
|
||||
if (theEvent.isFrom("baudList")) {
|
||||
Map bob = ((MenuList)theEvent.getController()).getItem(int(theEvent.getValue()));
|
||||
baudEMG = (String)bob.get("headline");
|
||||
println(baudEMG);
|
||||
}
|
||||
if (theEvent.isFrom("sourceList")) {
|
||||
|
||||
controlPanel.hideAllBoxes();
|
||||
@@ -154,6 +124,10 @@ public void controlEvent(ControlEvent theEvent) {
|
||||
chanButton16.color_notPressed = autoFileName.color_notPressed; //default color of button
|
||||
} else if(newDataSource == DATASOURCE_GANGLION){
|
||||
updateToNChan(4);
|
||||
if (isWindows() && isHubInitialized == false) {
|
||||
hubInit();
|
||||
timeOfSetup = millis();
|
||||
}
|
||||
} else if(newDataSource == DATASOURCE_PLAYBACKFILE){
|
||||
updateToNChan(8);
|
||||
} else if(newDataSource == DATASOURCE_SYNTHETIC){
|
||||
@@ -189,20 +163,6 @@ public void controlEvent(ControlEvent theEvent) {
|
||||
}
|
||||
verbosePrint("SD setting = " + sdSetting);
|
||||
}
|
||||
if (theEvent.isFrom("networkList")){
|
||||
Map bob = ((MenuList)theEvent.getController()).getItem(int(theEvent.getValue()));
|
||||
String str = (String)bob.get("headline");
|
||||
int index = int(theEvent.getValue());
|
||||
if (index == 0) {
|
||||
networkType = 0;
|
||||
} else if (index ==1){
|
||||
networkType = 1;
|
||||
} else if (index == 2){
|
||||
networkType = 2;
|
||||
} else if (index == 3){
|
||||
networkType = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (theEvent.isFrom("channelList")){
|
||||
int setChannelInt = int(theEvent.getValue()) + 1;
|
||||
@@ -221,14 +181,14 @@ public void controlEvent(ControlEvent theEvent) {
|
||||
|
||||
}
|
||||
|
||||
if (theEvent.isFrom("pollList")){
|
||||
int setChannelInt = int(theEvent.getValue());
|
||||
//Map bob = ((MenuList)theEvent.getController()).getItem(int(theEvent.getValue()));
|
||||
cp5Popup.get(MenuList.class, "pollList").setVisible(false);
|
||||
channelPopup.setClicked(false);
|
||||
set_poll(rcBox,setChannelInt);
|
||||
setPoll.wasPressed = false;
|
||||
}
|
||||
// if (theEvent.isFrom("pollList")){
|
||||
// int setChannelInt = int(theEvent.getValue());
|
||||
// //Map bob = ((MenuList)theEvent.getController()).getItem(int(theEvent.getValue()));
|
||||
// cp5Popup.get(MenuList.class, "pollList").setVisible(false);
|
||||
// channelPopup.setClicked(false);
|
||||
// set_poll(rcBox,setChannelInt);
|
||||
// setPoll.wasPressed = false;
|
||||
// }
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@@ -251,14 +211,8 @@ class ControlPanel {
|
||||
InitBox initBox;
|
||||
SyntheticChannelCountBox synthChannelCountBox;
|
||||
|
||||
NetworkingBox networkingBoxLive;
|
||||
UDPOptionsBox udpOptionsBox;
|
||||
OSCOptionsBox oscOptionsBox;
|
||||
LSLOptionsBox lslOptionsBox;
|
||||
|
||||
PlaybackFileBox playbackFileBox;
|
||||
SDConverterBox sdConverterBox;
|
||||
NetworkingBox networkingBoxPlayback;
|
||||
|
||||
BLEBox bleBox;
|
||||
DataLogBoxGanglion dataLogBoxGanglion;
|
||||
@@ -307,16 +261,10 @@ class ControlPanel {
|
||||
channelCountBox = new ChannelCountBox(x + w, (dataLogBox.y + dataLogBox.h), w, h, globalPadding);
|
||||
synthChannelCountBox = new SyntheticChannelCountBox(x + w, dataSourceBox.y, w, h, globalPadding);
|
||||
sdBox = new SDBox(x + w, (channelCountBox.y + channelCountBox.h), w, h, globalPadding);
|
||||
networkingBoxLive = new NetworkingBox(x + w, (sdBox.y + sdBox.h), w, 135, globalPadding);
|
||||
udpOptionsBox = new UDPOptionsBox(networkingBoxLive.x + networkingBoxLive.w, (sdBox.y + sdBox.h), w-30, networkingBoxLive.h, globalPadding);
|
||||
oscOptionsBox = new OSCOptionsBox(networkingBoxLive.x + networkingBoxLive.w, (sdBox.y + sdBox.h), w-30, networkingBoxLive.h, globalPadding);
|
||||
lslOptionsBox = new LSLOptionsBox(networkingBoxLive.x + networkingBoxLive.w, (sdBox.y + sdBox.h), w-30, networkingBoxLive.h, globalPadding);
|
||||
|
||||
|
||||
//boxes active when eegDataSource = Playback
|
||||
playbackFileBox = new PlaybackFileBox(x + w, dataSourceBox.y, w, h, globalPadding);
|
||||
sdConverterBox = new SDConverterBox(x + w, (playbackFileBox.y + playbackFileBox.h), w, h, globalPadding);
|
||||
//networkingBoxPlayback = new NetworkingBox(x + w, (sdConverterBox.y + sdConverterBox.h), w, h, globalPadding);
|
||||
|
||||
rcBox = new RadioConfigBox(x+w, y, w, h, globalPadding);
|
||||
channelPopup = new ChannelPopup(x+w, y, w, h, globalPadding);
|
||||
@@ -374,8 +322,6 @@ class ControlPanel {
|
||||
sdBox.update();
|
||||
rcBox.update();
|
||||
initBox.update();
|
||||
networkingBoxLive.update();
|
||||
//networkingBoxPlayback.update();
|
||||
|
||||
channelPopup.update();
|
||||
serialList.updateMenu();
|
||||
@@ -387,7 +333,7 @@ class ControlPanel {
|
||||
convertSDFile();
|
||||
}
|
||||
|
||||
if (isGanglion) {
|
||||
if (isHubInitialized && isGanglionObjectInitialized) {
|
||||
if (!calledForBLEList) {
|
||||
calledForBLEList = true;
|
||||
if (ganglion.isHubRunning()) {
|
||||
@@ -453,7 +399,6 @@ class ControlPanel {
|
||||
dataLogBox.draw();
|
||||
channelCountBox.draw();
|
||||
sdBox.draw();
|
||||
networkingBoxLive.draw();
|
||||
cp5.get(Textfield.class, "fileName").setVisible(true); //make sure the data file field is visible
|
||||
cp5.get(Textfield.class, "fileNameGanglion").setVisible(false); //make sure the data file field is visible
|
||||
|
||||
@@ -482,74 +427,17 @@ class ControlPanel {
|
||||
cp5.get(MenuList.class, "serialList").setVisible(true); //make sure the serialList menulist is visible
|
||||
cp5.get(MenuList.class, "bleList").setVisible(false); //make sure the serialList menulist is visible
|
||||
cp5.get(MenuList.class, "sdTimes").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
cp5.get(MenuList.class, "networkList").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
if (networkType == -1){
|
||||
cp5.get(Textfield.class, "udp_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_address").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_data").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_aux").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
} else if (networkType == 0){
|
||||
cp5.get(Textfield.class, "udp_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_address").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_data").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_aux").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
|
||||
} else if (networkType == 1){
|
||||
cp5.get(Textfield.class, "udp_ip").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_port").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_address").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_data").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_aux").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
udpOptionsBox.draw();
|
||||
} else if (networkType == 2){
|
||||
cp5.get(Textfield.class, "udp_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_ip").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_port").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_address").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_data").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_aux").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
|
||||
oscOptionsBox.draw();
|
||||
} else if (networkType == 3){
|
||||
cp5.get(Textfield.class, "udp_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_address").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_data").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_aux").setVisible(true); //make sure the SD time record options menulist is visible
|
||||
lslOptionsBox.draw();
|
||||
}
|
||||
|
||||
} else if (eegDataSource == DATASOURCE_PLAYBACKFILE) { //when data source is from playback file
|
||||
// hideAllBoxes(); //clear lists, so they don't appear
|
||||
playbackFileBox.draw();
|
||||
sdConverterBox.draw();
|
||||
//networkingBoxPlayback.draw();
|
||||
|
||||
//set other CP5 controllers invisible
|
||||
// cp5.get(Textfield.class, "fileName").setVisible(false); //make sure the data file field is visible
|
||||
// cp5.get(Textfield.class, "fileNameGanglion").setVisible(false); //make sure the data file field is visible
|
||||
cp5.get(MenuList.class, "serialList").setVisible(false);
|
||||
cp5.get(MenuList.class, "sdTimes").setVisible(false);
|
||||
cp5.get(MenuList.class, "networkList").setVisible(false);
|
||||
cp5.get(Textfield.class, "udp_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_address").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_data").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_aux").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
|
||||
cp5Popup.get(MenuList.class, "channelList").setVisible(false);
|
||||
cp5Popup.get(MenuList.class, "pollList").setVisible(false);
|
||||
|
||||
@@ -618,14 +506,6 @@ class ControlPanel {
|
||||
cp5.get(MenuList.class, "serialList").setVisible(false);
|
||||
cp5.get(MenuList.class, "bleList").setVisible(false);
|
||||
cp5.get(MenuList.class, "sdTimes").setVisible(false);
|
||||
cp5.get(MenuList.class, "networkList").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "udp_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_ip").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_port").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "osc_address").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_data").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5.get(Textfield.class, "lsl_aux").setVisible(false); //make sure the SD time record options menulist is visible
|
||||
cp5Popup.get(MenuList.class, "channelList").setVisible(false);
|
||||
cp5Popup.get(MenuList.class, "pollList").setVisible(false);
|
||||
}
|
||||
@@ -707,40 +587,40 @@ class ControlPanel {
|
||||
ovrChannel.wasPressed = true;
|
||||
}
|
||||
|
||||
if (getPoll.isMouseHere()){
|
||||
getPoll.setIsActive(true);
|
||||
getPoll.wasPressed = true;
|
||||
}
|
||||
// if (getPoll.isMouseHere()){
|
||||
// getPoll.setIsActive(true);
|
||||
// getPoll.wasPressed = true;
|
||||
// }
|
||||
|
||||
if (setPoll.isMouseHere()){
|
||||
setPoll.setIsActive(true);
|
||||
setPoll.wasPressed = true;
|
||||
}
|
||||
// if (setPoll.isMouseHere()){
|
||||
// setPoll.setIsActive(true);
|
||||
// setPoll.wasPressed = true;
|
||||
// }
|
||||
|
||||
if (defaultBAUD.isMouseHere()){
|
||||
defaultBAUD.setIsActive(true);
|
||||
defaultBAUD.wasPressed = true;
|
||||
}
|
||||
// if (defaultBAUD.isMouseHere()){
|
||||
// defaultBAUD.setIsActive(true);
|
||||
// defaultBAUD.wasPressed = true;
|
||||
// }
|
||||
|
||||
if (highBAUD.isMouseHere()){
|
||||
highBAUD.setIsActive(true);
|
||||
highBAUD.wasPressed = true;
|
||||
}
|
||||
// if (highBAUD.isMouseHere()){
|
||||
// highBAUD.setIsActive(true);
|
||||
// highBAUD.wasPressed = true;
|
||||
// }
|
||||
|
||||
if (autoscan.isMouseHere()){
|
||||
autoscan.setIsActive(true);
|
||||
autoscan.wasPressed = true;
|
||||
}
|
||||
|
||||
if (autoconnectNoStartDefault.isMouseHere()){
|
||||
autoconnectNoStartDefault.setIsActive(true);
|
||||
autoconnectNoStartDefault.wasPressed = true;
|
||||
}
|
||||
// if (autoconnectNoStartDefault.isMouseHere()){
|
||||
// autoconnectNoStartDefault.setIsActive(true);
|
||||
// autoconnectNoStartDefault.wasPressed = true;
|
||||
// }
|
||||
|
||||
if (autoconnectNoStartHigh.isMouseHere()){
|
||||
autoconnectNoStartHigh.setIsActive(true);
|
||||
autoconnectNoStartHigh.wasPressed = true;
|
||||
}
|
||||
// if (autoconnectNoStartHigh.isMouseHere()){
|
||||
// autoconnectNoStartHigh.setIsActive(true);
|
||||
// autoconnectNoStartHigh.wasPressed = true;
|
||||
// }
|
||||
|
||||
|
||||
if (systemStatus.isMouseHere()){
|
||||
@@ -844,8 +724,8 @@ class ControlPanel {
|
||||
}
|
||||
|
||||
if(getChannel.isMouseHere() && getChannel.wasPressed){
|
||||
if(board != null) get_channel( rcBox);
|
||||
|
||||
// if(board != null) // Radios_Config will handle creating the serial port JAM 1/2017
|
||||
get_channel( rcBox);
|
||||
getChannel.wasPressed=false;
|
||||
getChannel.setIsActive(false);
|
||||
}
|
||||
@@ -863,66 +743,66 @@ class ControlPanel {
|
||||
}
|
||||
|
||||
|
||||
if (getPoll.isMouseHere() && getPoll.wasPressed){
|
||||
get_poll(rcBox);
|
||||
getPoll.setIsActive(false);
|
||||
getPoll.wasPressed = false;
|
||||
}
|
||||
// if (getPoll.isMouseHere() && getPoll.wasPressed){
|
||||
// get_poll(rcBox);
|
||||
// getPoll.setIsActive(false);
|
||||
// getPoll.wasPressed = false;
|
||||
// }
|
||||
|
||||
if (setPoll.isMouseHere() && setPoll.wasPressed){
|
||||
pollPopup.setClicked(true);
|
||||
channelPopup.setClicked(false);
|
||||
setPoll.setIsActive(false);
|
||||
}
|
||||
// if (setPoll.isMouseHere() && setPoll.wasPressed){
|
||||
// pollPopup.setClicked(true);
|
||||
// channelPopup.setClicked(false);
|
||||
// setPoll.setIsActive(false);
|
||||
// }
|
||||
|
||||
if (defaultBAUD.isMouseHere() && defaultBAUD.wasPressed){
|
||||
set_baud_default(rcBox,openBCI_portName);
|
||||
defaultBAUD.setIsActive(false);
|
||||
defaultBAUD.wasPressed=false;
|
||||
}
|
||||
// if (defaultBAUD.isMouseHere() && defaultBAUD.wasPressed){
|
||||
// set_baud_default(rcBox,openBCI_portName);
|
||||
// defaultBAUD.setIsActive(false);
|
||||
// defaultBAUD.wasPressed=false;
|
||||
// }
|
||||
|
||||
if (highBAUD.isMouseHere() && highBAUD.wasPressed){
|
||||
set_baud_high(rcBox,openBCI_portName);
|
||||
highBAUD.setIsActive(false);
|
||||
highBAUD.wasPressed=false;
|
||||
}
|
||||
// if (highBAUD.isMouseHere() && highBAUD.wasPressed){
|
||||
// set_baud_high(rcBox,openBCI_portName);
|
||||
// highBAUD.setIsActive(false);
|
||||
// highBAUD.wasPressed=false;
|
||||
// }
|
||||
|
||||
if(autoconnectNoStartDefault.isMouseHere() && autoconnectNoStartDefault.wasPressed){
|
||||
// if(autoconnectNoStartDefault.isMouseHere() && autoconnectNoStartDefault.wasPressed){
|
||||
//
|
||||
// if(board == null){
|
||||
// try{
|
||||
// board = autoconnect_return_default();
|
||||
// rcBox.print_onscreen("Successfully connected to board");
|
||||
// }
|
||||
// catch (Exception e){
|
||||
// rcBox.print_onscreen("Error connecting to board...");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
// else rcBox.print_onscreen("Board already connected!");
|
||||
// autoconnectNoStartDefault.setIsActive(false);
|
||||
// autoconnectNoStartDefault.wasPressed = false;
|
||||
// }
|
||||
|
||||
if(board == null){
|
||||
try{
|
||||
board = autoconnect_return_default();
|
||||
rcBox.print_onscreen("Successfully connected to board");
|
||||
}
|
||||
catch (Exception e){
|
||||
rcBox.print_onscreen("Error connecting to board...");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else rcBox.print_onscreen("Board already connected!");
|
||||
autoconnectNoStartDefault.setIsActive(false);
|
||||
autoconnectNoStartDefault.wasPressed = false;
|
||||
}
|
||||
|
||||
if(autoconnectNoStartHigh.isMouseHere() && autoconnectNoStartHigh.wasPressed){
|
||||
|
||||
if(board == null){
|
||||
|
||||
try{
|
||||
|
||||
board = autoconnect_return_high();
|
||||
rcBox.print_onscreen("Successfully connected to board");
|
||||
}
|
||||
catch (Exception e2){
|
||||
rcBox.print_onscreen("Error connecting to board...");
|
||||
}
|
||||
|
||||
}
|
||||
else rcBox.print_onscreen("Board already connected!");
|
||||
autoconnectNoStartHigh.setIsActive(false);
|
||||
autoconnectNoStartHigh.wasPressed = false;
|
||||
}
|
||||
// if(autoconnectNoStartHigh.isMouseHere() && autoconnectNoStartHigh.wasPressed){
|
||||
//
|
||||
// if(board == null){
|
||||
//
|
||||
// try{
|
||||
//
|
||||
// board = autoconnect_return_high();
|
||||
// rcBox.print_onscreen("Successfully connected to board");
|
||||
// }
|
||||
// catch (Exception e2){
|
||||
// rcBox.print_onscreen("Error connecting to board...");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else rcBox.print_onscreen("Board already connected!");
|
||||
// autoconnectNoStartHigh.setIsActive(false);
|
||||
// autoconnectNoStartHigh.wasPressed = false;
|
||||
// }
|
||||
|
||||
if(autoscan.isMouseHere() && autoscan.wasPressed){
|
||||
autoscan.wasPressed = false;
|
||||
@@ -960,9 +840,13 @@ class ControlPanel {
|
||||
|
||||
//open or close serial port if serial port button is pressed (left button in serial widget)
|
||||
if (refreshBLE.isMouseHere() && refreshBLE.wasPressed) {
|
||||
output("BLE Devices Refreshing");
|
||||
bleList.items.clear();
|
||||
ganglion.searchDeviceStart();
|
||||
if (isGanglionObjectInitialized) {
|
||||
output("BLE Devices Refreshing");
|
||||
bleList.items.clear();
|
||||
ganglion.searchDeviceStart();
|
||||
} else {
|
||||
output("Please wait till BLE is fully initalized");
|
||||
}
|
||||
}
|
||||
|
||||
//open or close serial port if serial port button is pressed (left button in serial widget)
|
||||
@@ -1110,24 +994,6 @@ public void initButtonPressed(){
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
//Network Protocol Initiation -- based on Gabe's Code
|
||||
if (networkType == 1){
|
||||
ip = cp5.get(Textfield.class, "udp_ip").getText();
|
||||
port = int(cp5.get(Textfield.class, "udp_port").getText());
|
||||
println(port);
|
||||
udp = new UDPSend(port, ip);
|
||||
} else if (networkType == 2){
|
||||
ip = cp5.get(Textfield.class, "osc_ip").getText();
|
||||
port = int(cp5.get(Textfield.class, "osc_port").getText());
|
||||
address = cp5.get(Textfield.class, "osc_address").getText();
|
||||
osc = new OSCSend(port, ip, address);
|
||||
} else if (networkType == 3){
|
||||
data_stream = cp5.get(Textfield.class, "lsl_data").getText();
|
||||
aux_stream = cp5.get(Textfield.class, "lsl_aux").getText();
|
||||
lsl = new LSLSend(data_stream, aux_stream);
|
||||
}
|
||||
|
||||
if(eegDataSource == DATASOURCE_GANGLION){
|
||||
fileName = cp5.get(Textfield.class, "fileNameGanglion").getText(); // store the current text field value of "File Name" to be passed along to dataFiles
|
||||
} else if(eegDataSource == DATASOURCE_NORMAL_W_AUX){
|
||||
@@ -1650,48 +1516,6 @@ class SDBox {
|
||||
}
|
||||
};
|
||||
|
||||
class NetworkingBox{
|
||||
int x, y, w, h, padding; //size and position
|
||||
MenuList networkList;
|
||||
|
||||
//boolean initButtonPressed; //default false
|
||||
|
||||
//boolean isSystemInitialized;
|
||||
NetworkingBox(int _x, int _y, int _w, int _h, int _padding){
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = _h;
|
||||
padding = _padding;
|
||||
networkList = new MenuList(cp5, "networkList", w - padding*2, 96, p4);
|
||||
networkList.setPosition(x + padding, y+padding+20);
|
||||
networkList.addItem(makeItem("None"));
|
||||
networkList.addItem(makeItem("UDP"));
|
||||
networkList.addItem(makeItem("OSC"));
|
||||
networkList.addItem(makeItem("LabStreamingLayer (LSL)"));
|
||||
networkList.scrollerLength = 0;
|
||||
networkList.activeItem = 0;
|
||||
}
|
||||
public void update() {
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
pushStyle();
|
||||
fill(boxColor);
|
||||
stroke(boxStrokeColor);
|
||||
strokeWeight(1);
|
||||
rect(x, y, w, h);
|
||||
fill(bgColor);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("NETWORK PROTOCOLS", x + padding, y + padding);
|
||||
fill(bgColor); //set color to green
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
popStyle();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class RadioConfigBox {
|
||||
int x, y, w, h, padding; //size and position
|
||||
@@ -1703,34 +1527,34 @@ class RadioConfigBox {
|
||||
x = _x + _w;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = 355;
|
||||
h = 255;
|
||||
padding = _padding;
|
||||
isShowing = false;
|
||||
|
||||
getChannel = new Button(x + padding, y + padding*2 + 18, (w-padding*3)/2, 24, "GET CHANNEL", fontInfo.buttonLabel_size);
|
||||
setChannel = new Button(x + padding + (w-padding*2)/2, y + padding*2 + 18, (w-padding*3)/2, 24, "SET CHANNEL", fontInfo.buttonLabel_size);
|
||||
ovrChannel = new Button(x + padding, y + padding*3 + 18 + 24, (w-padding*3)/2, 24, "OVERRIDE CHAN", fontInfo.buttonLabel_size);
|
||||
getPoll = new Button(x + padding + (w-padding*2)/2, y + padding*3 + 18 + 24, (w-padding*3)/2, 24, "GET POLL", fontInfo.buttonLabel_size);
|
||||
setPoll = new Button(x + padding, y + padding*4 + 18 + 24*2, (w-padding*3)/2, 24, "SET POLL", fontInfo.buttonLabel_size);
|
||||
defaultBAUD = new Button(x + padding + (w-padding*2)/2, y + padding*4 + 18 + 24*2, (w-padding*3)/2, 24, "DEFAULT BAUD", fontInfo.buttonLabel_size);
|
||||
highBAUD = new Button(x + padding, y + padding*5 + 18 + 24*3, (w-padding*3)/2, 24, "HIGH BAUD", fontInfo.buttonLabel_size);
|
||||
autoscan = new Button(x + padding + (w-padding*2)/2, y + padding*5 + 18 + 24*3, (w-padding*3)/2, 24, "AUTOSCAN CHANS", fontInfo.buttonLabel_size);
|
||||
autoconnectNoStartDefault = new Button(x + padding, y + padding*6 + 18 + 24*4, (w-padding*3 )/2 , 24, "CONNECT 115200", fontInfo.buttonLabel_size);
|
||||
systemStatus = new Button(x + padding + (w-padding*2)/2, y + padding*6 + 18 + 24*4, (w-padding*3 )/2, 24, "STATUS", fontInfo.buttonLabel_size);
|
||||
autoconnectNoStartHigh = new Button(x + padding, y + padding*7 + 18 + 24*5, (w-padding*3 )/2, 24, "CONNECT 230400", fontInfo.buttonLabel_size);
|
||||
systemStatus = new Button(x + padding + (w-padding*2)/2, y + padding*2 + 18, (w-padding*3)/2, 24, "STATUS", fontInfo.buttonLabel_size);
|
||||
setChannel = new Button(x + padding, y + padding*3 + 18 + 24, (w-padding*3)/2, 24, "CHANGE CHANNEL", fontInfo.buttonLabel_size);
|
||||
ovrChannel = new Button(x + padding, y + padding*4 + 18 + 24*2, (w-padding*3)/2, 24, "OVERRIDE DONGLE", fontInfo.buttonLabel_size);
|
||||
autoscan = new Button(x + padding + (w-padding*2)/2, y + padding*4 + 18 + 24*2, (w-padding*3)/2, 24, "AUTOSCAN", fontInfo.buttonLabel_size);
|
||||
// getPoll = new Button(x + padding + (w-padding*2)/2, y + padding*3 + 18 + 24, (w-padding*3)/2, 24, "GET POLL", fontInfo.buttonLabel_size);
|
||||
// highBAUD = new Button(x + padding, y + padding*5 + 18 + 24*3, (w-padding*3)/2, 24, "HIGH BAUD", fontInfo.buttonLabel_size);
|
||||
// setPoll = new Button(x + padding + (w-padding*2)/2, y + padding*5 + 18 + 24*3, (w-padding*3)/2, 24, "", fontInfo.buttonLabel_size);
|
||||
// autoconnectNoStartDefault = new Button(x + padding, y + padding*6 + 18 + 24*4, (w-padding*3 )/2 , 24, "CONNECT 115200", fontInfo.buttonLabel_size);
|
||||
// deraultBaud = new Button(x + padding + (w-padding*2)/2, y + padding*6 + 18 + 24*4, (w-padding*3 )/2, 24, "", fontInfo.buttonLabel_size);
|
||||
// autoconnectNoStartHigh = new Button(x + padding, y + padding*7 + 18 + 24*5, (w-padding*3 )/2, 24, "CONNECT 230400", fontInfo.buttonLabel_size);
|
||||
|
||||
//Set help text
|
||||
getChannel.setHelpText("Gets the current channel that your OpenBCI board and radio is on.");
|
||||
setChannel.setHelpText("Sets the current channel that your OpenBCI board and radio are on.");
|
||||
ovrChannel.setHelpText("Overrides the current channel of the OpenBCI radio, and sets it to that channel.");
|
||||
getPoll.setHelpText("Gets the current POLL value.");
|
||||
setPoll.setHelpText("Sets the current POLL value.");
|
||||
defaultBAUD.setHelpText("Sets the BAUD rate to 115200.");
|
||||
highBAUD.setHelpText("Sets the BAUD rate to 230400.");
|
||||
autoscan.setHelpText("Scans through channels and finds a nearby OpenBCI board, then connects to that board.");
|
||||
systemStatus.setHelpText("Gets the connection status of your OpenBCI board.");
|
||||
autoconnectNoStartDefault.setHelpText("Automatically connects to a board with the DEFAULT (115200) BAUD");
|
||||
autoconnectNoStartHigh.setHelpText("Automatically connects to a board with the HIGH (230400) BAUD");
|
||||
getChannel.setHelpText("Get the current channel of your Cyton and USB Dongle");
|
||||
setChannel.setHelpText("Change the channel of your Cyton and USB Dongle");
|
||||
ovrChannel.setHelpText("Change the channel of the USB Dongle only");
|
||||
autoscan.setHelpText("Scan through channels and connect to a nearby Cyton");
|
||||
systemStatus.setHelpText("Get the connection status of your Cyton system");
|
||||
// getPoll.setHelpText("Gets the current POLL value.");
|
||||
// setPoll.setHelpText("Sets the current POLL value.");
|
||||
// defaultBAUD.setHelpText("Sets the BAUD rate to 115200.");
|
||||
// highBAUD.setHelpText("Sets the BAUD rate to 230400.");
|
||||
// autoconnectNoStartDefault.setHelpText("Automatically connects to a board with the DEFAULT (115200) BAUD");
|
||||
// autoconnectNoStartHigh.setHelpText("Automatically connects to a board with the HIGH (230400) BAUD");
|
||||
|
||||
}
|
||||
public void update() {
|
||||
@@ -1745,19 +1569,20 @@ class RadioConfigBox {
|
||||
fill(bgColor);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("RADIO CONFIGURATION (V2)", x + padding, y + padding);
|
||||
text("RADIO CONFIGURATION (v2)", x + padding, y + padding);
|
||||
popStyle();
|
||||
getChannel.draw();
|
||||
setChannel.draw();
|
||||
ovrChannel.draw();
|
||||
getPoll.draw();
|
||||
setPoll.draw();
|
||||
defaultBAUD.draw();
|
||||
highBAUD.draw();
|
||||
autoscan.draw();
|
||||
autoconnectNoStartDefault.draw();
|
||||
autoconnectNoStartHigh.draw();
|
||||
systemStatus.draw();
|
||||
autoscan.draw();
|
||||
// getPoll.draw();
|
||||
// setPoll.draw();
|
||||
// defaultBAUD.draw();
|
||||
// highBAUD.draw();
|
||||
// autoconnectNoStartDefault.draw();
|
||||
// autoconnectNoStartHigh.draw();
|
||||
|
||||
this.print_onscreen(last_message);
|
||||
|
||||
//the drawing of the sdTimes is handled earlier in ControlPanel.draw()
|
||||
@@ -1767,9 +1592,9 @@ class RadioConfigBox {
|
||||
public void print_onscreen(String localstring){
|
||||
textAlign(LEFT);
|
||||
fill(0);
|
||||
rect(x + padding, y + (padding*8) + 18 + (24*6), (w-padding*3 + 5), 135 - 24 - padding);
|
||||
rect(x + padding, y + (padding*8) + 18 + (24*2), (w-padding*3 + 5), 135 - 24 - padding);
|
||||
fill(255);
|
||||
text(localstring, x + padding + 10, y + (padding*8) + 18 + (24*6) + 15, (w-padding*3 ), 135 - 24 - padding -15);
|
||||
text(localstring, x + padding + 10, y + (padding*8) + 18 + (24*2) + 15, (w-padding*3 ), 135 - 24 - padding -15);
|
||||
this.last_message = localstring;
|
||||
}
|
||||
|
||||
@@ -1782,254 +1607,6 @@ class RadioConfigBox {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class UDPOptionsBox {
|
||||
int x, y, w, h, padding; //size and position
|
||||
|
||||
UDPOptionsBox(int _x, int _y, int _w, int _h, int _padding){
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = _h;
|
||||
padding = _padding;
|
||||
|
||||
cp5.addTextfield("udp_ip")
|
||||
.setPosition(x + 60,y + 50)
|
||||
.setCaptionLabel("")
|
||||
.setSize(100,26)
|
||||
.setFont(f2)
|
||||
.setFocus(false)
|
||||
.setColor(color(26,26,26))
|
||||
.setColorBackground(color(255,255,255)) // text field bg color
|
||||
.setColorValueLabel(color(0,0,0)) // text color
|
||||
.setColorForeground(isSelected_color) // border color when not selected
|
||||
.setColorActive(isSelected_color) // border color when selected
|
||||
.setColorCursor(color(26,26,26))
|
||||
.setText("localhost")
|
||||
.align(5, 10, 20, 40)
|
||||
.onDoublePress(cb)
|
||||
.setVisible(false)
|
||||
.setAutoClear(true)
|
||||
;
|
||||
|
||||
cp5.addTextfield("udp_port")
|
||||
.setPosition(x + 60,y + 82)
|
||||
.setCaptionLabel("")
|
||||
.setSize(100,26)
|
||||
.setFont(f2)
|
||||
.setFocus(false)
|
||||
.setColor(color(26,26,26))
|
||||
.setColorBackground(color(255,255,255)) // text field bg color
|
||||
.setColorValueLabel(color(0,0,0)) // text color
|
||||
.setColorForeground(isSelected_color) // border color when not selected
|
||||
.setColorActive(isSelected_color) // border color when selected
|
||||
.setColorCursor(color(26,26,26))
|
||||
.setText("12345")
|
||||
.align(5, 10, 20, 40)
|
||||
.onDoublePress(cb)
|
||||
.setVisible(false)
|
||||
.setAutoClear(true)
|
||||
;
|
||||
}
|
||||
public void update(){
|
||||
}
|
||||
public void draw(){
|
||||
pushStyle();
|
||||
fill(boxColor);
|
||||
stroke(boxStrokeColor);
|
||||
strokeWeight(1);
|
||||
rect(x, y, w, h);
|
||||
fill(bgColor);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("Options", x + padding, y + padding);
|
||||
pushStyle();
|
||||
fill(boxColor);
|
||||
stroke(boxStrokeColor);
|
||||
strokeWeight(1);
|
||||
rect(x, y, w, h);
|
||||
fill(bgColor);
|
||||
text("UDP OPTIONS", x + padding, y + padding);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("IP", x + padding, y + 50 + padding);
|
||||
textFont(p4, 14);;
|
||||
text("Port", x + padding, y + 82 + padding);
|
||||
popStyle();
|
||||
}
|
||||
};
|
||||
|
||||
class OSCOptionsBox{
|
||||
int x, y, w, h, padding; //size and position
|
||||
|
||||
OSCOptionsBox(int _x, int _y, int _w, int _h, int _padding){
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = _h;
|
||||
padding = _padding;
|
||||
|
||||
cp5.addTextfield("osc_ip")
|
||||
.setPosition(x + 80,y + 35)
|
||||
.setCaptionLabel("")
|
||||
.setSize(100,26)
|
||||
.setFont(f2)
|
||||
.setFocus(false)
|
||||
.setColor(color(26,26,26))
|
||||
.setColorBackground(color(255,255,255)) // text field bg color
|
||||
.setColorValueLabel(color(0,0,0)) // text color
|
||||
.setColorForeground(isSelected_color) // border color when not selected
|
||||
.setColorActive(isSelected_color) // border color when selected
|
||||
.setColorCursor(color(26,26,26))
|
||||
.setText("localhost")
|
||||
.align(5, 10, 20, 40)
|
||||
.onDoublePress(cb)
|
||||
.setVisible(false)
|
||||
.setAutoClear(true)
|
||||
;
|
||||
cp5.addTextfield("osc_port")
|
||||
.setPosition(x + 80,y + 67)
|
||||
.setCaptionLabel("")
|
||||
.setSize(100,26)
|
||||
.setFont(f2)
|
||||
.setFocus(false)
|
||||
.setColor(color(26,26,26))
|
||||
.setColorBackground(color(255,255,255)) // text field bg color
|
||||
.setColorValueLabel(color(0,0,0)) // text color
|
||||
.setColorForeground(isSelected_color) // border color when not selected
|
||||
.setColorActive(isSelected_color) // border color when selected
|
||||
.setColorCursor(color(26,26,26))
|
||||
.setText("12345")
|
||||
.align(5, 10, 20, 40)
|
||||
.onDoublePress(cb)
|
||||
.setVisible(false)
|
||||
.setAutoClear(true)
|
||||
;
|
||||
cp5.addTextfield("osc_address")
|
||||
.setPosition(x + 80,y + 99)
|
||||
.setCaptionLabel("")
|
||||
.setSize(100,26)
|
||||
.setFont(f2)
|
||||
.setFocus(false)
|
||||
.setColor(color(26,26,26))
|
||||
.setColorBackground(color(255,255,255)) // text field bg color
|
||||
.setColorValueLabel(color(0,0,0)) // text color
|
||||
.setColorForeground(isSelected_color) // border color when not selected
|
||||
.setColorActive(isSelected_color) // border color when selected
|
||||
.setColorCursor(color(26,26,26))
|
||||
.setText("/openbci")
|
||||
.align(5, 10, 20, 40)
|
||||
.onDoublePress(cb)
|
||||
.setVisible(false)
|
||||
.setAutoClear(true)
|
||||
;
|
||||
}
|
||||
public void update(){
|
||||
}
|
||||
public void draw(){
|
||||
pushStyle();
|
||||
fill(boxColor);
|
||||
stroke(boxStrokeColor);
|
||||
strokeWeight(1);
|
||||
rect(x, y, w, h);
|
||||
fill(bgColor);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("Options", x + padding, y + padding);
|
||||
pushStyle();
|
||||
fill(boxColor);
|
||||
stroke(boxStrokeColor);
|
||||
strokeWeight(1);
|
||||
rect(x, y, w, h);
|
||||
fill(bgColor);
|
||||
text("OSC OPTIONS", x + padding, y + padding);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("IP", x + padding, y + 35 + padding);
|
||||
textFont(p4, 14);;
|
||||
text("Port", x + padding, y + 67 + padding);
|
||||
text("Address", x + padding, y + 99 + padding);
|
||||
popStyle();
|
||||
}
|
||||
};
|
||||
|
||||
class LSLOptionsBox {
|
||||
int x, y, w, h, padding; //size and position
|
||||
|
||||
LSLOptionsBox(int _x, int _y, int _w, int _h, int _padding){
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
h = _h;
|
||||
padding = _padding;
|
||||
|
||||
cp5.addTextfield("lsl_data")
|
||||
.setPosition(x + 115,y + 50)
|
||||
.setCaptionLabel("")
|
||||
.setSize(100,26)
|
||||
.setFont(f2)
|
||||
.setFocus(false)
|
||||
.setColor(color(26,26,26))
|
||||
.setColorBackground(color(255,255,255)) // text field bg color
|
||||
.setColorValueLabel(color(0,0,0)) // text color
|
||||
.setColorForeground(isSelected_color) // border color when not selected
|
||||
.setColorActive(isSelected_color) // border color when selected
|
||||
.setColorCursor(color(26,26,26))
|
||||
.setText("openbci_data")
|
||||
.align(5, 10, 20, 40)
|
||||
.onDoublePress(cb)
|
||||
.setVisible(false)
|
||||
.setAutoClear(true)
|
||||
;
|
||||
|
||||
cp5.addTextfield("lsl_aux")
|
||||
.setPosition(x + 115,y + 82)
|
||||
.setCaptionLabel("")
|
||||
.setSize(100,26)
|
||||
.setFont(f2)
|
||||
.setFocus(false)
|
||||
.setColor(color(26,26,26))
|
||||
.setColorBackground(color(255,255,255)) // text field bg color
|
||||
.setColorValueLabel(color(0,0,0)) // text color
|
||||
.setColorForeground(isSelected_color) // border color when not selected
|
||||
.setColorActive(isSelected_color) // border color when selected
|
||||
.setColorCursor(color(26,26,26))
|
||||
.setText("openbci_aux")
|
||||
.align(5, 10, 20, 40)
|
||||
.onDoublePress(cb)
|
||||
.setVisible(false)
|
||||
.setAutoClear(true)
|
||||
;
|
||||
}
|
||||
public void update(){
|
||||
}
|
||||
public void draw(){
|
||||
pushStyle();
|
||||
fill(boxColor);
|
||||
stroke(boxStrokeColor);
|
||||
strokeWeight(1);
|
||||
rect(x, y, w, h);
|
||||
fill(bgColor);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("Options", x + padding, y + padding);
|
||||
pushStyle();
|
||||
fill(boxColor);
|
||||
stroke(boxStrokeColor);
|
||||
strokeWeight(1);
|
||||
rect(x, y, w, h);
|
||||
fill(bgColor);
|
||||
text("LSL OPTIONS", x + padding, y + padding);
|
||||
textFont(h3, 16);
|
||||
textAlign(LEFT, TOP);
|
||||
text("Data Stream", x + padding, y + 50 + padding);
|
||||
textFont(p4, 14);;
|
||||
text("Aux Stream", x + padding, y + 82 + padding);
|
||||
popStyle();
|
||||
}
|
||||
};
|
||||
|
||||
class SDConverterBox {
|
||||
int x, y, w, h, padding; //size and position
|
||||
|
||||
|
||||
@@ -87,9 +87,9 @@ void openNewLogFileODF(String _fileName) {
|
||||
*/
|
||||
void playbackSelected(File selection) {
|
||||
if (selection == null) {
|
||||
println("ControlPanel: playbackSelected: Window was closed or the user hit cancel.");
|
||||
println("DataLogging: playbackSelected: Window was closed or the user hit cancel.");
|
||||
} else {
|
||||
println("ControlPanel: playbackSelected: User selected " + selection.getAbsolutePath());
|
||||
println("DataLogging: playbackSelected: User selected " + selection.getAbsolutePath());
|
||||
output("You have selected \"" + selection.getAbsolutePath() + "\" for playback.");
|
||||
playbackData_fname = selection.getAbsolutePath();
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void fileSelected(File selection) { //called by the Open File dialog box after
|
||||
println("fileSelected: no selection so far...");
|
||||
} else {
|
||||
//inputFile = selection;
|
||||
playbackData_fname = selection.getAbsolutePath();
|
||||
playbackData_fname = selection.getAbsolutePath(); //<>//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ public class OutputFile_rawtxt {
|
||||
int nVal = values.length;
|
||||
for (int Ival = 0; Ival < nVal; Ival++) {
|
||||
output.print(", ");
|
||||
output.print(String.format("%.2f", scale_fac * float(values[Ival])));
|
||||
output.print(String.format(Locale.US, "%.2f", scale_fac * float(values[Ival])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public class OutputFile_rawtxt {
|
||||
int nVal = values.length;
|
||||
for (int Ival = 0; Ival < nVal; Ival++) {
|
||||
output.print(", ");
|
||||
output.print(String.format("%.3f", scale_fac * float(values[Ival])));
|
||||
output.print(String.format(Locale.US, "%.3f", scale_fac * float(values[Ival])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1475,4 +1475,4 @@ public void convertSDFile() {
|
||||
dataWriter.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ HashMap<String,float[][]> processed_file;
|
||||
HashMap<Integer,String> index_of_times;
|
||||
HashMap<String,Integer> index_of_times_rev;
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Global Functions
|
||||
//------------------------------------------------------------------------
|
||||
@@ -109,6 +111,8 @@ int getDataIfAvailable(int pointCounter) {
|
||||
//if (eegDataSource==DATASOURCE_PLAYBACKFILE) println("OpenBCI_GUI: getDataIfAvailable: currentTableRowIndex = " + currentTableRowIndex);
|
||||
//println("OpenBCI_GUI: getDataIfAvailable: pointCounter = " + pointCounter);
|
||||
} // close "has enough time passed"
|
||||
else{
|
||||
}
|
||||
}
|
||||
return pointCounter;
|
||||
}
|
||||
@@ -150,10 +154,11 @@ void processNewData() {
|
||||
// ...yLittleBuff_uV[Ichan] is the most recent raw data since the last call to this processing routine
|
||||
// ...dataBuffY_filtY_uV[Ichan] is the full set of filtered data as shown in the time-domain plot in the GUI
|
||||
// ...fftBuff[Ichan] is the FFT data structure holding the frequency spectrum as shown in the freq-domain plot in the GUI
|
||||
// emg_widget.process(yLittleBuff_uV, dataBuffY_uV, dataBuffY_filtY_uV, fftBuff); //%%%
|
||||
// ob_widget.process(); //%%%
|
||||
// w_emg.process(yLittleBuff_uV, dataBuffY_uV, dataBuffY_filtY_uV, fftBuff); //%%%
|
||||
// w_openbionics.process();
|
||||
|
||||
dataProcessing_user.process(yLittleBuff_uV, dataBuffY_uV, dataBuffY_filtY_uV, fftBuff);
|
||||
dataProcessing.newDataToSend = true;
|
||||
|
||||
//look to see if the latest data is railed so that we can notify the user on the GUI
|
||||
for (int Ichan=0; Ichan < nchan; Ichan++) is_railed[Ichan].update(dataPacketBuff[lastReadDataPacketInd].values[Ichan]);
|
||||
@@ -353,18 +358,37 @@ class DataProcessing {
|
||||
FilterConstants[] filtCoeff_bp = new FilterConstants[N_FILT_CONFIGS];
|
||||
final int N_NOTCH_CONFIGS = 3;
|
||||
FilterConstants[] filtCoeff_notch = new FilterConstants[N_NOTCH_CONFIGS];
|
||||
private int currentFilt_ind = 0;
|
||||
private int currentFilt_ind = 3;
|
||||
private int currentNotch_ind = 0; // set to 0 to default to 60Hz, set to 1 to default to 50Hz
|
||||
float data_std_uV[];
|
||||
float polarity[];
|
||||
boolean newDataToSend;
|
||||
private String[] binNames;
|
||||
final int[] processing_band_low_Hz = {
|
||||
1, 4, 8, 13, 30
|
||||
}; //lower bound for each frequency band of interest (2D classifier only)
|
||||
final int[] processing_band_high_Hz = {
|
||||
4, 8, 13, 30, 55
|
||||
}; //upper bound for each frequency band of interest
|
||||
float avgPowerInBins[][];
|
||||
float headWidePower[];
|
||||
int numBins;
|
||||
|
||||
// indexs
|
||||
final int DELTA = 0; // 1-4 Hz
|
||||
final int THETA = 1; // 4-8 Hz
|
||||
final int ALPHA = 2; // 8-13 Hz
|
||||
final int BETA = 3; // 13-30 Hz
|
||||
final int GAMMA = 4; // 30-55 Hz
|
||||
|
||||
DataProcessing(int NCHAN, float sample_rate_Hz) {
|
||||
nchan = NCHAN;
|
||||
fs_Hz = sample_rate_Hz;
|
||||
data_std_uV = new float[nchan];
|
||||
polarity = new float[nchan];
|
||||
|
||||
newDataToSend = false;
|
||||
avgPowerInBins = new float[nchan][processing_band_low_Hz.length];
|
||||
headWidePower = new float[processing_band_low_Hz.length];
|
||||
|
||||
//check to make sure the sample rate is acceptable and then define the filters
|
||||
if (abs(fs_Hz-250.0f) < 1.0) {
|
||||
@@ -626,10 +650,13 @@ class DataProcessing {
|
||||
double foo;
|
||||
|
||||
//update the FFT (frequency spectrum)
|
||||
// println("nchan = " + nchan);
|
||||
for (int Ichan=0; Ichan < nchan; Ichan++) {
|
||||
|
||||
//copy the previous FFT data...enables us to apply some smoothing to the FFT data
|
||||
for (int I=0; I < fftBuff[Ichan].specSize(); I++) prevFFTdata[I] = fftBuff[Ichan].getBand(I); //copy the old spectrum values
|
||||
for (int I=0; I < fftBuff[Ichan].specSize(); I++) {
|
||||
prevFFTdata[I] = fftBuff[Ichan].getBand(I); //copy the old spectrum values
|
||||
}
|
||||
|
||||
//prepare the data for the new FFT
|
||||
float[] fooData;
|
||||
@@ -672,8 +699,25 @@ class DataProcessing {
|
||||
}
|
||||
fftBuff[Ichan].setBand(I, (float)foo); //put the smoothed data back into the fftBuff data holder for use by everyone else
|
||||
} //end loop over FFT bins
|
||||
for (int i = 0; i < processing_band_low_Hz.length; i++) {
|
||||
float sum = 0;
|
||||
for (int j = processing_band_low_Hz[i]; j < processing_band_high_Hz[i]; j++) {
|
||||
sum += fftBuff[Ichan].getBand(j);
|
||||
}
|
||||
avgPowerInBins[Ichan][i] = sum;
|
||||
}
|
||||
} //end the loop over channels.
|
||||
for (int i = 0; i < processing_band_low_Hz.length; i++) {
|
||||
float sum = 0;
|
||||
|
||||
for (int j = 0; j < nchan; j++) {
|
||||
sum += avgPowerInBins[j][i];
|
||||
}
|
||||
headWidePower[i] = sum/nchan;
|
||||
}
|
||||
|
||||
//delta in channel 2 ... avgPowerInBins[1][DELTA];
|
||||
//headwide beta ... headWidePower[BETA];
|
||||
|
||||
//find strongest channel
|
||||
int refChanInd = findMax(data_std_uV);
|
||||
@@ -693,5 +737,12 @@ class DataProcessing {
|
||||
polarity[Ichan]=-1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// println("Brain Wide DELTA = " + headWidePower[DELTA]);
|
||||
// println("Brain Wide THETA = " + headWidePower[THETA]);
|
||||
// println("Brain Wide ALPHA = " + headWidePower[ALPHA]);
|
||||
// println("Brain Wide BETA = " + headWidePower[BETA]);
|
||||
// println("Brain Wide GAMMA = " + headWidePower[GAMMA]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
// Global Functions
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
boolean werePacketsDroppedGang = false;
|
||||
int numPacketsDroppedGang = 0;
|
||||
|
||||
void clientEvent(Client someClient) {
|
||||
// print("Server Says: ");
|
||||
|
||||
@@ -80,6 +83,7 @@ class OpenBCI_Ganglion {
|
||||
|
||||
final static int RESP_ERROR_UNKNOWN = 499;
|
||||
final static int RESP_ERROR_BAD_PACKET = 500;
|
||||
final static int RESP_ERROR_BAD_NOBLE_START = 501;
|
||||
final static int RESP_ERROR_ALREADY_CONNECTED = 408;
|
||||
final static int RESP_ERROR_COMMAND_NOT_RECOGNIZED = 406;
|
||||
final static int RESP_ERROR_DEVICE_NOT_FOUND = 405;
|
||||
@@ -265,11 +269,7 @@ class OpenBCI_Ganglion {
|
||||
println("OpenBCI_Ganglion: Log: " + list[1]);
|
||||
break;
|
||||
case 'q':
|
||||
if (waitingForResponse) {
|
||||
waitingForResponse = false;
|
||||
println("Node process up!");
|
||||
}
|
||||
println("OpenBCI_Ganglion: Status: 200");
|
||||
processStatus(msg);
|
||||
break;
|
||||
default:
|
||||
println("OpenBCI_Ganglion: parseMessage: default: " + msg);
|
||||
@@ -316,7 +316,15 @@ class OpenBCI_Ganglion {
|
||||
if ((dataPacket.sampleIndex - prevSampleIndex) != 1) {
|
||||
if(dataPacket.sampleIndex != 0){ // if we rolled over, don't count as error
|
||||
bleErrorCounter++;
|
||||
|
||||
werePacketsDroppedGang = true; //set this true to activate packet duplication in serialEvent
|
||||
if(dataPacket.sampleIndex < prevSampleIndex){ //handle the situation in which the index jumps from 250s past 255, and back to 0
|
||||
numPacketsDroppedGang = (dataPacket.sampleIndex+200) - prevSampleIndex; //calculate how many times the last received packet should be duplicated...
|
||||
} else {
|
||||
numPacketsDroppedGang = dataPacket.sampleIndex - prevSampleIndex; //calculate how many times the last received packet should be duplicated...
|
||||
}
|
||||
println("OpenBCI_Ganglion: apparent sampleIndex jump from Serial data: " + prevSampleIndex + " to " + dataPacket.sampleIndex + ". Keeping packet. (" + bleErrorCounter + ")");
|
||||
println("numPacketsDropped = " + numPacketsDropped);
|
||||
}
|
||||
}
|
||||
prevSampleIndex = dataPacket.sampleIndex;
|
||||
@@ -335,7 +343,28 @@ class OpenBCI_Ganglion {
|
||||
getRawValues(dataPacket);
|
||||
// println(binary(dataPacket.values[0], 24) + '\n' + binary(dataPacket.rawValues[0][0], 8) + binary(dataPacket.rawValues[0][1], 8) + binary(dataPacket.rawValues[0][2], 8) + '\n'); //<>//
|
||||
curDataPacketInd = (curDataPacketInd+1) % dataPacketBuff.length; // This is also used to let the rest of the code that it may be time to do something
|
||||
|
||||
ganglion.copyDataPacketTo(dataPacketBuff[curDataPacketInd]); // Resets isNewDataPacketAvailable to false
|
||||
|
||||
// KILL SPIKES!!!
|
||||
if(werePacketsDroppedGang){
|
||||
// println("Packets Dropped ... doing some stuff...");
|
||||
for(int i = numPacketsDroppedGang; i > 0; i--){
|
||||
int tempDataPacketInd = curDataPacketInd - i; //
|
||||
if(tempDataPacketInd >= 0 && tempDataPacketInd < dataPacketBuff.length){
|
||||
// println("i = " + i);
|
||||
ganglion.copyDataPacketTo(dataPacketBuff[tempDataPacketInd]);
|
||||
} else {
|
||||
ganglion.copyDataPacketTo(dataPacketBuff[tempDataPacketInd+200]);
|
||||
}
|
||||
//put the last stored packet in # of packets dropped after that packet
|
||||
}
|
||||
|
||||
//reset werePacketsDropped & numPacketsDropped
|
||||
werePacketsDroppedGang = false;
|
||||
numPacketsDroppedGang = 0;
|
||||
}
|
||||
|
||||
switch (outputDataSource) {
|
||||
case OUTPUT_SOURCE_ODF:
|
||||
fileoutput_odf.writeRawData_dataPacket(dataPacketBuff[curDataPacketInd], ganglion.get_scale_fac_uVolts_per_count(), get_scale_fac_accel_G_per_count());
|
||||
@@ -390,6 +419,21 @@ class OpenBCI_Ganglion {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processStatus(String msg) {
|
||||
String[] list = split(msg, ',');
|
||||
int code = Integer.parseInt(list[1]);
|
||||
if (waitingForResponse) {
|
||||
waitingForResponse = false;
|
||||
println("Node process up!");
|
||||
}
|
||||
if (code == RESP_ERROR_BAD_NOBLE_START) {
|
||||
println("OpenBCI_Ganglion: processStatus: Problem in the Hub");
|
||||
output("Problem starting Ganglion Hub. Please make sure compatible USB is configured, then restart this GUI.");
|
||||
} else {
|
||||
println("OpenBCI_Ganglion: processStatus: Started Successfully");
|
||||
}
|
||||
}
|
||||
|
||||
private void processScan(String msg) {
|
||||
String[] list = split(msg, ',');
|
||||
@@ -617,7 +661,7 @@ class OpenBCI_Ganglion {
|
||||
} else {
|
||||
println("OpenBCI_Ganglion: changeChannelState(): deactivate: sending " + command_deactivate_channel[Ichan]);
|
||||
safeTCPWrite(TCP_CMD_COMMAND + "," + command_deactivate_channel[Ichan] + TCP_STOP);
|
||||
w_timeSeries.hsc.powerUpChannel(Ichan);
|
||||
w_timeSeries.hsc.powerDownChannel(Ichan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +236,7 @@ void parseKey(char val) {
|
||||
case 's':
|
||||
println("case s...");
|
||||
stopRunning();
|
||||
|
||||
// stopButtonWasPressed();
|
||||
break;
|
||||
case 'b':
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Networking
|
||||
// - responsible for sending data over a Network
|
||||
// - Three types of networks are available:
|
||||
// - UDP
|
||||
// - OSC
|
||||
// - LSL
|
||||
// - In control panel, specify the network and parameters (port, ip, etc).
|
||||
// Then, you can receive the streamed data in a variety of different
|
||||
// programs, given that you specify the correct parameters to receive
|
||||
// the data stream in those networks.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float[] data_to_send;
|
||||
float[] aux_to_send;
|
||||
float[] full_message;
|
||||
|
||||
public void sendRawData_dataPacket(DataPacket_ADS1299 data, float scale_to_uV, float scale_for_aux) {
|
||||
data_to_send = writeValues(data.values,scale_to_uV);
|
||||
aux_to_send = writeValues(data.auxValues,scale_for_aux);
|
||||
|
||||
full_message = compressArray(data); //Collect packet into full_message array
|
||||
|
||||
//send to appropriate network type
|
||||
if (networkType == 1){
|
||||
udp.send_message(data_to_send); //Send full message to udp
|
||||
}else if (networkType == 2){
|
||||
osc.send_message(data_to_send); //Send full message to osc
|
||||
}else if (networkType == 3){
|
||||
lsl.send_message(data_to_send,aux_to_send); //Send
|
||||
}
|
||||
}
|
||||
// Convert counts to scientific values (uV or G)
|
||||
private float[] writeValues(int[] values, float scale_fac) {
|
||||
int nVal = values.length;
|
||||
float[] temp_buffer = new float[nVal];
|
||||
for (int Ival = 0; Ival < nVal; Ival++) {
|
||||
temp_buffer[Ival] = scale_fac * float(values[Ival]);
|
||||
}
|
||||
return temp_buffer;
|
||||
}
|
||||
|
||||
//Package all data into one array (full_message) for UDP and OSC
|
||||
private float[] compressArray(DataPacket_ADS1299 data){
|
||||
full_message = new float[1 + data_to_send.length + aux_to_send.length];
|
||||
full_message[0] = data.sampleIndex;
|
||||
for (int i=0;i<data_to_send.length;i++){
|
||||
full_message[i+1] = data_to_send[i];
|
||||
}
|
||||
for (int i=0;i<aux_to_send.length;i++){
|
||||
full_message[data_to_send.length + 1] = aux_to_send[i];
|
||||
}
|
||||
return full_message;
|
||||
}
|
||||
|
||||
//////////////
|
||||
// CLASSES //
|
||||
|
||||
/**
|
||||
* To perform any action on datagram reception, you need to implement this
|
||||
* handler in your code. This method will be automatically called by the UDP
|
||||
* object each time he receive a nonnull message. This method will send the
|
||||
* message to `udpEvent`
|
||||
*/
|
||||
// void receive(byte[] data, String ip, int port) { // <-- extended handler
|
||||
// // get the "real" message =
|
||||
// // forget the ";\n" at the end <-- !!! only for a communication with Pd !!!
|
||||
// data = subset(data, 0, data.length-2);
|
||||
// String message = new String( data );
|
||||
//
|
||||
// // Be safe, always check to make sure the parent did implement this function
|
||||
// if (ganglion.udpRx.udpEventMethod != null) {
|
||||
// try {
|
||||
// ganglion.udpRx.udpEventMethod.invoke(ganglion.udpRx.parent, message);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// System.err.println("Disabling udpEvent() for because of an error.");
|
||||
// e.printStackTrace();
|
||||
// ganglion.udpRx.udpEventMethod = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void clientEvent(Client someClient) {
|
||||
// print("Server Says: ");
|
||||
// dataIn = myClient.read();
|
||||
// println(dataIn);
|
||||
// background(dataIn);
|
||||
//
|
||||
// // get the "real" message =
|
||||
// // forget the ";\n" at the end <-- !!! only for a communication with Pd !!!
|
||||
// data = subset(data, 0, data.length-2);
|
||||
// String message = new String( data );
|
||||
//
|
||||
// // Be safe, always check to make sure the parent did implement this function
|
||||
// if (ganglion.udpRx.udpEventMethod != null) {
|
||||
// try {
|
||||
// ganglion.udpRx.udpEventMethod.invoke(ganglion.udpRx.parent, message);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// System.err.println("Disabling udpEvent() for because of an error.");
|
||||
// e.printStackTrace();
|
||||
// ganglion.udpRx.udpEventMethod = null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
class UDPReceive {
|
||||
public Method udpEventMethod;
|
||||
public PApplet parent;
|
||||
int port;
|
||||
String ip;
|
||||
boolean listen;
|
||||
UDP udp;
|
||||
|
||||
/**
|
||||
* @description Used to construct a new UDP connection
|
||||
* @param `parent` {PApplet} - The object calling constructor. Implements
|
||||
* `udpEvent` if `parent` wants to recieve messages.
|
||||
* @param `port` {int} - The port number to use for the UDP port
|
||||
* @param `ip` {String} - The ip address for the UDP connection. Use `localhost`
|
||||
* to keep the port on this computer.
|
||||
* @constructor
|
||||
*/
|
||||
public UDPReceive(PApplet parent, int port, String ip) {
|
||||
// Grab vars
|
||||
this.port = port;
|
||||
this.ip = ip;
|
||||
|
||||
this.udp = new UDP(parent, port);
|
||||
println("udp bound to " + port);
|
||||
this.udp.setBuffer(1024);
|
||||
this.udp.log(false);
|
||||
this.udp.listen(true);
|
||||
|
||||
// callback: https://forum.processing.org/one/topic/noob-q-i-d-like-to-learn-more-about-callbacks.html
|
||||
// Set parent for callback
|
||||
this.parent = parent;
|
||||
|
||||
// Verify that parent actaully implements the callback
|
||||
try {
|
||||
this.udpEventMethod = this.parent.getClass().getMethod("udpEvent", new Class[] { String.class });
|
||||
println("Networking: Good job iplmenting udpEvent callback in parent " + parent);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// No such method declared, there for the parent who created this will not
|
||||
// recieve messages :(
|
||||
println("Networking: Error failed to implement udpEvent callback in parent " + this.parent);
|
||||
this.udp.listen(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// UDP SEND //
|
||||
class UDPSend {
|
||||
int port;
|
||||
String ip;
|
||||
UDP udp;
|
||||
|
||||
UDPSend(int _port, String _ip){
|
||||
port = _port;
|
||||
ip = _ip;
|
||||
udp = new UDP(this);
|
||||
udp.setBuffer(1024);
|
||||
udp.log(false);
|
||||
}
|
||||
void send_message(float[] _message){
|
||||
String message = Arrays.toString(_message);
|
||||
udp.send(message,ip,port);
|
||||
}
|
||||
|
||||
void send(String msg){
|
||||
udp.send(msg,ip,port);
|
||||
}
|
||||
}
|
||||
|
||||
// OSC SEND //
|
||||
class OSCSend{
|
||||
int port;
|
||||
String ip;
|
||||
String address;
|
||||
OscP5 osc;
|
||||
NetAddress netaddress;
|
||||
|
||||
OSCSend(int _port, String _ip, String _address){
|
||||
port = _port;
|
||||
ip = _ip;
|
||||
address = _address;
|
||||
osc = new OscP5(this,12000);
|
||||
netaddress = new NetAddress(ip,port);
|
||||
}
|
||||
void send_message(float[] _message){
|
||||
OscMessage osc_message = new OscMessage(address);
|
||||
osc_message.add(_message);
|
||||
osc.send(osc_message, netaddress);
|
||||
}
|
||||
}
|
||||
|
||||
// LSL SEND //
|
||||
class LSLSend{
|
||||
String data_stream;
|
||||
String data_stream_id;
|
||||
String aux_stream;
|
||||
String aux_stream_id;
|
||||
LSL.StreamInfo info_data;
|
||||
LSL.StreamOutlet outlet_data;
|
||||
LSL.StreamInfo info_aux;
|
||||
LSL.StreamOutlet outlet_aux;
|
||||
|
||||
LSLSend(String _data_stream, String _aux_stream){
|
||||
data_stream = _data_stream;
|
||||
data_stream_id = data_stream + "_id";
|
||||
aux_stream = _aux_stream;
|
||||
aux_stream_id = aux_stream + "_id";
|
||||
info_data = new LSL.StreamInfo(data_stream, "EEG", nchan, openBCI.get_fs_Hz(), LSL.ChannelFormat.float32, data_stream_id);
|
||||
outlet_data = new LSL.StreamOutlet(info_data);
|
||||
//info_aux = new LSL.StreamInfo("aux_stream", "AUX", 3, openBCI.get_fs_Hz(), LSL.ChannelFormat.float32, aux_stream_id);
|
||||
//outlet_aux = new LSL.StreamOutlet(info_aux);
|
||||
}
|
||||
void send_message(float[] _data_message, float[] _aux_message){
|
||||
outlet_data.push_sample(_data_message);
|
||||
//outlet_aux.push_sample(_aux_message);
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,6 @@ import java.util.*; //for Array.copyOfRange()
|
||||
import java.util.Map.Entry;
|
||||
import processing.serial.*; //for serial communication to Arduino/OpenBCI
|
||||
import java.awt.event.*; //to allow for event listener on screen resize
|
||||
import netP5.*; //for OSC networking
|
||||
import oscP5.*; //for OSC networking
|
||||
import hypermedia.net.*; //for UDP networking
|
||||
import processing.net.*; // For TCP networking
|
||||
import grafica.*;
|
||||
import java.lang.reflect.*; // For callbacks
|
||||
@@ -37,6 +34,11 @@ import java.lang.Process;
|
||||
import java.util.Random;
|
||||
import java.awt.Robot; //used for simulating mouse clicks
|
||||
import java.awt.AWTException;
|
||||
import netP5.*; // for OSC
|
||||
import oscP5.*; // for OSC
|
||||
import hypermedia.net.*; //for UDP
|
||||
import java.nio.ByteBuffer; //for UDP
|
||||
|
||||
|
||||
import gifAnimation.*;
|
||||
|
||||
@@ -146,16 +148,6 @@ final int OUTPUT_SOURCE_BDF = 2; // The BDF data format http://www.biosemi.com/f
|
||||
public int outputDataSource = OUTPUT_SOURCE_ODF;
|
||||
// public int outputDataSource = OUTPUT_SOURCE_BDF;
|
||||
|
||||
//variables for Networking
|
||||
int port = 0;
|
||||
String ip = "";
|
||||
String address = "";
|
||||
String data_stream = "";
|
||||
String aux_stream = "";
|
||||
UDPSend udp;
|
||||
OSCSend osc;
|
||||
LSLSend lsl;
|
||||
|
||||
// Serial output
|
||||
String serial_output_portName = "/dev/tty.usbmodem1411"; //must edit this based on the name of the serial/COM port
|
||||
Serial serial_output;
|
||||
@@ -218,7 +210,7 @@ PFont p6; //small Open Sans
|
||||
|
||||
ButtonHelpText buttonHelpText;
|
||||
|
||||
EMG_Widget emg_widget;
|
||||
//EMG_Widget emg_widget;
|
||||
PulseSensor_Widget pulseWidget;
|
||||
|
||||
boolean no_start_connection = false;
|
||||
@@ -230,7 +222,8 @@ int indices = 0;
|
||||
boolean synthesizeData = false;
|
||||
|
||||
int timeOfSetup = 0;
|
||||
boolean isGanglion = false;
|
||||
boolean isHubInitialized = false;
|
||||
boolean isGanglionObjectInitialized = false;
|
||||
color bgColor = color(1, 18, 41);
|
||||
color openbciBlue = color(31, 69, 110);
|
||||
int COLOR_SCHEME_DEFAULT = 1;
|
||||
@@ -240,9 +233,11 @@ int colorScheme = COLOR_SCHEME_ALTERNATIVE_A;
|
||||
|
||||
Process nodeHubby;
|
||||
int hubPid = 0;
|
||||
String nodeHubName = "Ganglion Hub";
|
||||
String nodeHubName = "GanglionHub";
|
||||
Robot rob3115;
|
||||
|
||||
PApplet ourApplet;
|
||||
|
||||
//-----------------------------------------1-------------------------------
|
||||
// Global Functions
|
||||
//------------------------------------------------------------------------
|
||||
@@ -255,9 +250,12 @@ void setup() {
|
||||
// server on shut down of this app, the main process.
|
||||
// prepareExitHandler();
|
||||
if (dev == false) {
|
||||
// On windows wait to start the hub until Ganglion is clicked on in the control panel.
|
||||
// See issue #111
|
||||
hubStop(); //kill any existing hubs before starting a new one..
|
||||
hubStart();
|
||||
prepareExitHandler();
|
||||
if (!isWindows()) {
|
||||
hubInit();
|
||||
}
|
||||
}
|
||||
|
||||
println("Welcome to the Processing-based OpenBCI GUI!"); //Welcome line.
|
||||
@@ -265,6 +263,7 @@ void setup() {
|
||||
println("For more information about how to work with this code base, please visit: http://docs.openbci.com/OpenBCI%20Software/");
|
||||
//open window
|
||||
size(1024, 768, P2D);
|
||||
ourApplet = this;
|
||||
frameRate(60); //refresh rate ... this will slow automatically, if your processor can't handle the specified rate
|
||||
smooth(); //turn this off if it's too slow
|
||||
|
||||
@@ -332,14 +331,14 @@ void setup() {
|
||||
playground = new Playground(navBarHeight);
|
||||
|
||||
//attempt to open a serial port for "output"
|
||||
try {
|
||||
verbosePrint("OpenBCI_GUI.pde: attempting to open serial port for data output = " + serial_output_portName);
|
||||
serial_output = new Serial(this, serial_output_portName, serial_output_baud); //open the com port
|
||||
serial_output.clear(); // clear anything in the com port's buffer
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
verbosePrint("OpenBCI_GUI.pde: *** ERROR ***: Could not open " + serial_output_portName);
|
||||
}
|
||||
// try {
|
||||
// verbosePrint("OpenBCI_GUI.pde: attempting to open serial/COM port for data output = " + serial_output_portName);
|
||||
// serial_output = new Serial(this, serial_output_portName, serial_output_baud); //open the com port
|
||||
// serial_output.clear(); // clear anything in the com port's buffer
|
||||
// }
|
||||
// catch (RuntimeException e) {
|
||||
// verbosePrint("OpenBCI_GUI.pde: could not open " + serial_output_portName);
|
||||
// }
|
||||
|
||||
// println("OpenBCI_GUI: setup: hub is running " + ganglion.isHubRunning());
|
||||
buttonHelpText = new ButtonHelpText();
|
||||
@@ -373,20 +372,31 @@ void draw() {
|
||||
* This allows us to kill the running node process on quit.
|
||||
*/
|
||||
private void prepareExitHandler () {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
public void run () {
|
||||
System.out.println("SHUTDOWN HOOK");
|
||||
try {
|
||||
if (hubStop()) {
|
||||
System.out.println("SHUTDOWN HUB");
|
||||
} else {
|
||||
System.out.println("FAILED TO SHUTDOWN HUB");
|
||||
}
|
||||
} catch (Exception ex){
|
||||
ex.printStackTrace(); // not much else to do at this point
|
||||
}
|
||||
}
|
||||
}));
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
public void run () {
|
||||
System.out.println("SHUTDOWN HOOK");
|
||||
try {
|
||||
if (hubStop()) {
|
||||
System.out.println("SHUTDOWN HUB");
|
||||
} else {
|
||||
System.out.println("FAILED TO SHUTDOWN HUB");
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace(); // not much else to do at this point
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the hub and sets prepares the exit handler.
|
||||
*/
|
||||
void hubInit() {
|
||||
isHubInitialized = true;
|
||||
hubStart();
|
||||
prepareExitHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,16 +408,17 @@ void hubStart() {
|
||||
// https://forum.processing.org/two/discussion/13053/use-launch-for-applications-kept-in-data-folder
|
||||
if (isWindows()) {
|
||||
println("OpenBCI_GUI: hubStart: OS Detected: Windows");
|
||||
nodeHubby = launch(dataPath("Ganglion Hub.exe"));
|
||||
nodeHubby = launch(dataPath("GanglionHub.exe"));
|
||||
} else if (isLinux()) {
|
||||
println("OpenBCI_GUI: hubStart: OS Detected: Linux");
|
||||
nodeHubby = exec(dataPath("Ganglion Hub"));
|
||||
nodeHubby = exec(dataPath("GanglionHub"));
|
||||
} else {
|
||||
println("OpenBCI_GUI: hubStart: OS Detected: Mac");
|
||||
nodeHubby = launch(dataPath("Ganglion Hub.app"));
|
||||
nodeHubby = launch(dataPath("GanglionHub.app"));
|
||||
}
|
||||
// hubRunning = true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
println("hubStart: " + e);
|
||||
}
|
||||
}
|
||||
@@ -449,20 +460,22 @@ void killRunningProcessMac() {
|
||||
String line;
|
||||
Process p = Runtime.getRuntime().exec("ps -e");
|
||||
BufferedReader input =
|
||||
new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
while ((line = input.readLine()) != null) {
|
||||
if (line.contains(nodeHubName)) {
|
||||
try {
|
||||
endProcess(getProcessIdFromLineMac(line));
|
||||
println("Killed: " + line);
|
||||
} catch (Exception err) {
|
||||
}
|
||||
catch (Exception err) {
|
||||
println("Failed to stop process: " + line + "\n\n");
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
input.close();
|
||||
} catch (Exception err) {
|
||||
}
|
||||
catch (Exception err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -473,9 +486,10 @@ void killRunningProcessMac() {
|
||||
*/
|
||||
boolean killRunningprocessWin() {
|
||||
try {
|
||||
Runtime.getRuntime().exec("taskkill /F /IM Ganglion Hub.exe");
|
||||
Runtime.getRuntime().exec("taskkill /F /IM GanglionHub.exe");
|
||||
return true;
|
||||
} catch (Exception err) {
|
||||
}
|
||||
catch (Exception err) {
|
||||
err.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
@@ -495,7 +509,8 @@ void endProcess(int pid) {
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
try {
|
||||
rt.exec("kill -9 " + pid);
|
||||
} catch (IOException err) {
|
||||
}
|
||||
catch (IOException err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -507,144 +522,147 @@ int byteRate_perSec = 0;
|
||||
int drawLoop_counter = 0;
|
||||
|
||||
//used to init system based on initial settings...Called from the "Start System" button in the GUI's ControlPanel
|
||||
|
||||
void setupWidgetManager() {
|
||||
wm = new WidgetManager(this);
|
||||
}
|
||||
|
||||
void initSystem() {
|
||||
|
||||
println();
|
||||
println();
|
||||
println("=================================================");
|
||||
println("|| INITIALIZING SYSTEM ||");
|
||||
println("=================================================");
|
||||
println();
|
||||
println();
|
||||
println();
|
||||
println("=================================================");
|
||||
println("|| INITIALIZING SYSTEM ||");
|
||||
println("=================================================");
|
||||
println();
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 0 -- " + millis());
|
||||
timeOfInit = millis(); //store this for timeout in case init takes too long
|
||||
verbosePrint("timeOfInit = " + timeOfInit);
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 0 -- " + millis());
|
||||
timeOfInit = millis(); //store this for timeout in case init takes too long
|
||||
verbosePrint("timeOfInit = " + timeOfInit);
|
||||
|
||||
//prepare data variables
|
||||
verbosePrint("OpenBCI_GUI: initSystem: Preparing data variables...");
|
||||
dataBuffX = new float[(int)(dataBuff_len_sec * get_fs_Hz_safe())];
|
||||
dataBuffY_uV = new float[nchan][dataBuffX.length];
|
||||
dataBuffY_filtY_uV = new float[nchan][dataBuffX.length];
|
||||
accelerometerBuff = new float[3][500]; // 500 points
|
||||
for (int i=0; i<n_aux_ifEnabled; i++) {
|
||||
for (int j=0; j<accelerometerBuff[0].length; j++) {
|
||||
accelerometerBuff[i][j] = 0;
|
||||
//prepare data variables
|
||||
verbosePrint("OpenBCI_GUI: initSystem: Preparing data variables...");
|
||||
dataBuffX = new float[(int)(dataBuff_len_sec * get_fs_Hz_safe())];
|
||||
dataBuffY_uV = new float[nchan][dataBuffX.length];
|
||||
dataBuffY_filtY_uV = new float[nchan][dataBuffX.length];
|
||||
accelerometerBuff = new float[3][500]; // 500 points
|
||||
for (int i=0; i<n_aux_ifEnabled; i++) {
|
||||
for (int j=0; j<accelerometerBuff[0].length; j++) {
|
||||
accelerometerBuff[i][j] = 0;
|
||||
}
|
||||
}
|
||||
//data_std_uV = new float[nchan];
|
||||
data_elec_imp_ohm = new float[nchan];
|
||||
is_railed = new DataStatus[nchan];
|
||||
for (int i=0; i<nchan; i++) is_railed[i] = new DataStatus(threshold_railed, threshold_railed_warn);
|
||||
for (int i=0; i<nDataBackBuff; i++) {
|
||||
dataPacketBuff[i] = new DataPacket_ADS1299(nchan, n_aux_ifEnabled);
|
||||
}
|
||||
dataProcessing = new DataProcessing(nchan, get_fs_Hz_safe());
|
||||
dataProcessing_user = new DataProcessing_User(nchan, get_fs_Hz_safe());
|
||||
|
||||
|
||||
|
||||
//initialize the data
|
||||
prepareData(dataBuffX, dataBuffY_uV, get_fs_Hz_safe());
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 1 -- " + millis());
|
||||
|
||||
//initialize the FFT objects
|
||||
for (int Ichan=0; Ichan < nchan; Ichan++) {
|
||||
verbosePrint("Init FFT Buff – "+Ichan);
|
||||
fftBuff[Ichan] = new FFT(Nfft, get_fs_Hz_safe());
|
||||
} //make the FFT objects
|
||||
|
||||
initializeFFTObjects(fftBuff, dataBuffY_uV, Nfft, get_fs_Hz_safe());
|
||||
|
||||
//prepare some signal processing stuff
|
||||
//for (int Ichan=0; Ichan < nchan; Ichan++) { detData_freqDomain[Ichan] = new DetectionData_FreqDomain(); }
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 2 -- " + millis());
|
||||
|
||||
//prepare the source of the input data
|
||||
switch (eegDataSource) {
|
||||
case DATASOURCE_NORMAL_W_AUX:
|
||||
int nEEDataValuesPerPacket = nchan;
|
||||
boolean useAux = false;
|
||||
if (eegDataSource == DATASOURCE_NORMAL_W_AUX) useAux = true; //switch this back to true CHIP 2014-11-04
|
||||
openBCI = new OpenBCI_ADS1299(this, openBCI_portName, openBCI_baud, nEEDataValuesPerPacket, useAux, n_aux_ifEnabled); //this also starts the data transfer after XX seconds
|
||||
break;
|
||||
case DATASOURCE_SYNTHETIC:
|
||||
//do nothing
|
||||
break;
|
||||
case DATASOURCE_PLAYBACKFILE:
|
||||
//open and load the data file
|
||||
println("OpenBCI_GUI: initSystem: loading playback data from " + playbackData_fname);
|
||||
try {
|
||||
playbackData_table = new Table_CSV(playbackData_fname);
|
||||
}
|
||||
catch (Exception e) {
|
||||
println("OpenBCI_GUI: initSystem: could not open file for playback: " + playbackData_fname);
|
||||
println(" : quitting...");
|
||||
exit();
|
||||
}
|
||||
println("OpenBCI_GUI: initSystem: loading complete. " + playbackData_table.getRowCount() + " rows of data, which is " + round(float(playbackData_table.getRowCount())/get_fs_Hz_safe()) + " seconds of EEG data");
|
||||
//removing first column of data from data file...the first column is a time index and not eeg data
|
||||
playbackData_table.removeColumn(0);
|
||||
break;
|
||||
case DATASOURCE_GANGLION:
|
||||
ganglion.connectBLE(ganglion_portName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 3 -- " + millis());
|
||||
|
||||
if (abandonInit) {
|
||||
haltSystem();
|
||||
println("Failed to connect to data source...");
|
||||
output("Failed to connect to data source...");
|
||||
} else {
|
||||
println(" 3a -- " + millis());
|
||||
//initilize the GUI
|
||||
// initializeGUI(); //will soon be destroyed... and replaced with ... wm = new WidgetManager(this);
|
||||
topNav.initSecondaryNav();
|
||||
println(" 3b -- " + millis());
|
||||
|
||||
// wm = new WidgetManager(this);
|
||||
setupWidgetManager();
|
||||
|
||||
if (!abandonInit) {
|
||||
println(" 3c -- " + millis());
|
||||
// setupGUIWidgets(); //####
|
||||
|
||||
//open data file
|
||||
if (eegDataSource == DATASOURCE_NORMAL_W_AUX) openNewLogFile(fileName); //open a new log file
|
||||
if (eegDataSource == DATASOURCE_GANGLION) openNewLogFile(fileName); // println("open ganglion output file");
|
||||
|
||||
nextPlayback_millis = millis(); //used for synthesizeData and readFromFile. This restarts the clock that keeps the playback at the right pace.
|
||||
|
||||
if (eegDataSource != DATASOURCE_GANGLION && eegDataSource != DATASOURCE_NORMAL_W_AUX) {
|
||||
systemMode = SYSTEMMODE_POSTINIT; //tell system it's ok to leave control panel and start interfacing GUI
|
||||
}
|
||||
}
|
||||
//data_std_uV = new float[nchan];
|
||||
data_elec_imp_ohm = new float[nchan];
|
||||
is_railed = new DataStatus[nchan];
|
||||
for (int i=0; i<nchan; i++) is_railed[i] = new DataStatus(threshold_railed, threshold_railed_warn);
|
||||
for (int i=0; i<nDataBackBuff; i++) {
|
||||
dataPacketBuff[i] = new DataPacket_ADS1299(nchan, n_aux_ifEnabled);
|
||||
}
|
||||
dataProcessing = new DataProcessing(nchan, get_fs_Hz_safe());
|
||||
dataProcessing_user = new DataProcessing_User(nchan, get_fs_Hz_safe());
|
||||
|
||||
|
||||
|
||||
//initialize the data
|
||||
prepareData(dataBuffX, dataBuffY_uV, get_fs_Hz_safe());
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 1 -- " + millis());
|
||||
|
||||
//initialize the FFT objects
|
||||
for (int Ichan=0; Ichan < nchan; Ichan++) {
|
||||
verbosePrint("Init FFT Buff – "+Ichan);
|
||||
fftBuff[Ichan] = new FFT(Nfft, get_fs_Hz_safe());
|
||||
} //make the FFT objects
|
||||
|
||||
initializeFFTObjects(fftBuff, dataBuffY_uV, Nfft, get_fs_Hz_safe());
|
||||
|
||||
//prepare some signal processing stuff
|
||||
//for (int Ichan=0; Ichan < nchan; Ichan++) { detData_freqDomain[Ichan] = new DetectionData_FreqDomain(); }
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 2 -- " + millis());
|
||||
|
||||
//prepare the source of the input data
|
||||
switch (eegDataSource) {
|
||||
case DATASOURCE_NORMAL_W_AUX:
|
||||
int nEEDataValuesPerPacket = nchan;
|
||||
boolean useAux = false;
|
||||
if (eegDataSource == DATASOURCE_NORMAL_W_AUX) useAux = true; //switch this back to true CHIP 2014-11-04
|
||||
openBCI = new OpenBCI_ADS1299(this, openBCI_portName, openBCI_baud, nEEDataValuesPerPacket, useAux, n_aux_ifEnabled); //this also starts the data transfer after XX seconds
|
||||
break;
|
||||
case DATASOURCE_SYNTHETIC:
|
||||
//do nothing
|
||||
break;
|
||||
case DATASOURCE_PLAYBACKFILE:
|
||||
//open and load the data file
|
||||
println("OpenBCI_GUI: initSystem: loading playback data from " + playbackData_fname);
|
||||
try {
|
||||
playbackData_table = new Table_CSV(playbackData_fname);
|
||||
}
|
||||
catch (Exception e) {
|
||||
println("OpenBCI_GUI: initSystem: could not open file for playback: " + playbackData_fname);
|
||||
println(" : quitting...");
|
||||
exit();
|
||||
}
|
||||
println("OpenBCI_GUI: initSystem: loading complete. " + playbackData_table.getRowCount() + " rows of data, which is " + round(float(playbackData_table.getRowCount())/get_fs_Hz_safe()) + " seconds of EEG data");
|
||||
//removing first column of data from data file...the first column is a time index and not eeg data
|
||||
playbackData_table.removeColumn(0);
|
||||
break;
|
||||
case DATASOURCE_GANGLION:
|
||||
ganglion.connectBLE(ganglion_portName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 3 -- " + millis());
|
||||
|
||||
if(abandonInit){
|
||||
haltSystem();
|
||||
println("Failed to connect to data source...");
|
||||
output("Failed to connect to data source...");
|
||||
} else{
|
||||
println(" 3a -- " + millis());
|
||||
//initilize the GUI
|
||||
// initializeGUI(); //will soon be destroyed... and replaced with ... wm = new WidgetManager(this);
|
||||
topNav.initSecondaryNav();
|
||||
println(" 3b -- " + millis());
|
||||
|
||||
wm = new WidgetManager(this);
|
||||
|
||||
if(!abandonInit){
|
||||
println(" 3c -- " + millis());
|
||||
// setupGUIWidgets(); //####
|
||||
|
||||
//open data file
|
||||
if (eegDataSource == DATASOURCE_NORMAL_W_AUX) openNewLogFile(fileName); //open a new log file
|
||||
if (eegDataSource == DATASOURCE_GANGLION) openNewLogFile(fileName); // println("open ganglion output file");
|
||||
|
||||
nextPlayback_millis = millis(); //used for synthesizeData and readFromFile. This restarts the clock that keeps the playback at the right pace.
|
||||
|
||||
if (eegDataSource != DATASOURCE_GANGLION && eegDataSource != DATASOURCE_NORMAL_W_AUX) {
|
||||
systemMode = SYSTEMMODE_POSTINIT; //tell system it's ok to leave control panel and start interfacing GUI
|
||||
|
||||
}
|
||||
if(!abandonInit){
|
||||
println("WOOHOO!!!");
|
||||
controlPanel.close();
|
||||
} else {
|
||||
haltSystem();
|
||||
println("Failed to connect to data source...");
|
||||
output("Failed to connect to data source...");
|
||||
}
|
||||
if (!abandonInit) {
|
||||
println("WOOHOO!!!");
|
||||
controlPanel.close();
|
||||
} else {
|
||||
haltSystem();
|
||||
println("Failed to connect to data source...");
|
||||
output("Failed to connect to data source...");
|
||||
}
|
||||
} else {
|
||||
haltSystem();
|
||||
println("Failed to connect to data source...");
|
||||
output("Failed to connect to data source...");
|
||||
}
|
||||
}
|
||||
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 4 -- " + millis());
|
||||
verbosePrint("OpenBCI_GUI: initSystem: -- Init 4 -- " + millis());
|
||||
|
||||
//reset init variables
|
||||
midInit = false;
|
||||
abandonInit = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,7 +680,7 @@ float get_fs_Hz_safe() {
|
||||
//halt the data collection
|
||||
void haltSystem() {
|
||||
println("openBCI_GUI: haltSystem: Halting system for reconfiguration of settings...");
|
||||
if(initSystemButton.but_txt == "STOP SYSTEM"){
|
||||
if (initSystemButton.but_txt == "STOP SYSTEM") {
|
||||
initSystemButton.but_txt = "START SYSTEM";
|
||||
}
|
||||
stopRunning(); //stop data transfer
|
||||
@@ -680,10 +698,12 @@ void haltSystem() {
|
||||
//set all data source list items inactive
|
||||
|
||||
//reset connect loadStrings
|
||||
openBCI_portName = "";
|
||||
openBCI_portName = "N/A"; // Fixes inability to reconnect after halding JAM 1/2017
|
||||
ganglion_portName = "";
|
||||
controlPanel.resetListItems();
|
||||
|
||||
// w_networking.clearCP5(); //closes all networking controllers
|
||||
|
||||
// stopDataTransfer(); // make sure to stop data transfer, if data is streaming and being drawn
|
||||
|
||||
if (eegDataSource == DATASOURCE_NORMAL_W_AUX) {
|
||||
@@ -699,14 +719,14 @@ void haltSystem() {
|
||||
|
||||
void systemUpdate() { // for updating data values and variables
|
||||
|
||||
if(millis() - timeOfSetup >= 1000 && isGanglion == false){
|
||||
if (isHubInitialized && isGanglionObjectInitialized == false && millis() - timeOfSetup >= 1500) {
|
||||
ganglion = new OpenBCI_Ganglion(this);
|
||||
println("Instantiating Ganglion object...");
|
||||
isGanglion = true;
|
||||
isGanglionObjectInitialized = true;
|
||||
}
|
||||
|
||||
//update the sync state with the OpenBCI hardware
|
||||
if(openBCI.state == openBCI.STATE_NOCOM || openBCI.state == openBCI.STATE_COMINIT || openBCI.state == openBCI.STATE_SYNCWITHHARDWARE){
|
||||
if (openBCI.state == openBCI.STATE_NOCOM || openBCI.state == openBCI.STATE_COMINIT || openBCI.state == openBCI.STATE_SYNCWITHHARDWARE) {
|
||||
openBCI.updateSyncState(sdSetting);
|
||||
}
|
||||
|
||||
@@ -723,8 +743,6 @@ void systemUpdate() { // for updating data values and variables
|
||||
if (widthOfLastScreen != width || heightOfLastScreen != height) {
|
||||
topNav.screenHasBeenResized(width, height);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (systemMode == SYSTEMMODE_POSTINIT) {
|
||||
if (isRunning) {
|
||||
@@ -759,12 +777,10 @@ void systemUpdate() { // for updating data values and variables
|
||||
}
|
||||
|
||||
redrawScreenNow=true;
|
||||
|
||||
} else {
|
||||
//not enough data has arrived yet... only update the channel controller
|
||||
}
|
||||
|
||||
} else if(eegDataSource == DATASOURCE_PLAYBACKFILE && !has_processed && !isOldData) {
|
||||
} else if (eegDataSource == DATASOURCE_PLAYBACKFILE && !has_processed && !isOldData) {
|
||||
lastReadDataPacketInd = 0;
|
||||
pointCounter = 0;
|
||||
try {
|
||||
@@ -790,6 +806,7 @@ void systemUpdate() { // for updating data values and variables
|
||||
//re-initialize GUI if screen has been resized and it's been more than 1/2 seccond (to prevent reinitialization of GUI from happening too often)
|
||||
if (screenHasBeenResized) {
|
||||
// GUIWidgets_screenResized(width, height);
|
||||
ourApplet = this; //reset PApplet...
|
||||
topNav.screenHasBeenResized(width, height);
|
||||
wm.screenResized();
|
||||
}
|
||||
@@ -804,7 +821,6 @@ void systemUpdate() { // for updating data values and variables
|
||||
|
||||
wm.update();
|
||||
playground.update();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -826,16 +842,16 @@ void systemDraw() { //for drawing to the screen
|
||||
switch (eegDataSource) {
|
||||
case DATASOURCE_NORMAL_W_AUX:
|
||||
switch (outputDataSource) {
|
||||
case OUTPUT_SOURCE_ODF:
|
||||
surface.setTitle(int(frameRate) + " fps, Byte Count = " + openBCI_byteCount + ", bit rate = " + byteRate_perSec*8 + " bps" + ", " + int(float(fileoutput_odf.getRowsWritten())/get_fs_Hz_safe()) + " secs Saved, Writing to " + output_fname);
|
||||
break;
|
||||
case OUTPUT_SOURCE_BDF:
|
||||
surface.setTitle(int(frameRate) + " fps, Byte Count = " + openBCI_byteCount + ", bit rate = " + byteRate_perSec*8 + " bps" + ", " + int(fileoutput_bdf.getRecordsWritten()) + " secs Saved, Writing to " + output_fname);
|
||||
break;
|
||||
case OUTPUT_SOURCE_NONE:
|
||||
default:
|
||||
surface.setTitle(int(frameRate) + " fps, Byte Count = " + openBCI_byteCount + ", bit rate = " + byteRate_perSec*8 + " bps");
|
||||
break;
|
||||
case OUTPUT_SOURCE_ODF:
|
||||
surface.setTitle(int(frameRate) + " fps, Byte Count = " + openBCI_byteCount + ", bit rate = " + byteRate_perSec*8 + " bps" + ", " + int(float(fileoutput_odf.getRowsWritten())/get_fs_Hz_safe()) + " secs Saved, Writing to " + output_fname);
|
||||
break;
|
||||
case OUTPUT_SOURCE_BDF:
|
||||
surface.setTitle(int(frameRate) + " fps, Byte Count = " + openBCI_byteCount + ", bit rate = " + byteRate_perSec*8 + " bps" + ", " + int(fileoutput_bdf.getRecordsWritten()) + " secs Saved, Writing to " + output_fname);
|
||||
break;
|
||||
case OUTPUT_SOURCE_NONE:
|
||||
default:
|
||||
surface.setTitle(int(frameRate) + " fps, Byte Count = " + openBCI_byteCount + ", bit rate = " + byteRate_perSec*8 + " bps");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DATASOURCE_SYNTHETIC:
|
||||
@@ -881,9 +897,6 @@ void systemDraw() { //for drawing to the screen
|
||||
|
||||
//dataProcessing_user.draw();
|
||||
drawContainers();
|
||||
|
||||
|
||||
|
||||
} else { //systemMode != 10
|
||||
//still print title information about fps
|
||||
surface.setTitle(int(frameRate) + " fps — OpenBCI GUI");
|
||||
@@ -934,7 +947,7 @@ void systemDraw() { //for drawing to the screen
|
||||
//draw presentation last, bc it is intended to be rendered on top of the GUI ...
|
||||
if (drawPresentation) {
|
||||
myPresentation.draw();
|
||||
// emg_widget.drawTriggerFeedback();
|
||||
//emg_widget.drawTriggerFeedback();
|
||||
//dataProcessing_user.drawTriggerFeedback();
|
||||
}
|
||||
|
||||
@@ -960,11 +973,11 @@ void introAnimation() {
|
||||
tint(255, transparency);
|
||||
//draw OpenBCI Logo Front & Center
|
||||
image(cog, width/2, height/2, width/6, width/6);
|
||||
textFont(p3,16);
|
||||
textFont(p3, 16);
|
||||
textLeading(24);
|
||||
fill(31,69,110, transparency);
|
||||
textAlign(CENTER,CENTER);
|
||||
text("OpenBCI GUI v2.0\nDecember 2016", width/2, height/2 + width/9);
|
||||
fill(31, 69, 110, transparency);
|
||||
textAlign(CENTER, CENTER);
|
||||
text("OpenBCI GUI v2.1.2\nJanuary 2017", width/2, height/2 + width/9);
|
||||
}
|
||||
|
||||
//exit intro animation at t2
|
||||
@@ -999,7 +1012,6 @@ void mouseOutOfBounds() {
|
||||
catch (RuntimeException e) {
|
||||
verbosePrint("Error happened while cursor left application...");
|
||||
}
|
||||
|
||||
} else {
|
||||
if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) {
|
||||
loc = getWindowLocation(P2D);
|
||||
@@ -1007,7 +1019,6 @@ void mouseOutOfBounds() {
|
||||
appletOriginY = (int)loc.y;
|
||||
windowOriginSet = true;
|
||||
mouseInFrame = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1026,4 +1037,4 @@ PVector getWindowLocation(String renderer) {
|
||||
}
|
||||
return l;
|
||||
}
|
||||
//END OF CODE FOR FIXING WEIRD EXIT CRASH ISSUE -- 7/27/16 ===========================
|
||||
//END OF CODE FOR FIXING WEIRD EXIT CRASH ISSUE -- 7/27/16 ===========================
|
||||
|
||||
@@ -1,509 +0,0 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OpenBionics Widget is an easy way to interface with your OpenBionics
|
||||
// hand using the OpenBCI gui! Use '\' to toggle between FFT and the widget!
|
||||
//
|
||||
// Colin Fausnaught, October 2016
|
||||
//
|
||||
// KNOWN BUGS: Research mode is sometimes not toggled correctly, will need to fix this by v2 release.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
ControlP5 configP5;
|
||||
String obName;
|
||||
String obBaud;
|
||||
List serialListOB;
|
||||
List baudListOB;
|
||||
int drawConfig;
|
||||
int[] fingerChans;
|
||||
|
||||
class OpenBionics_Widget {
|
||||
|
||||
int x, y, w, h;
|
||||
PApplet parent;
|
||||
|
||||
Serial OpenBionicsHand;
|
||||
PFont f = createFont("Arial Bold", 24); //for "FFT Plot" Widget Title
|
||||
PFont f2 = createFont("Arial", 18); //for dropdown name titles (above dropdown widgets)
|
||||
|
||||
int parentContainer = 9; //which container is it mapped to by default?
|
||||
boolean thumbPressed,indexPressed,middlePressed,ringPressed,littlePressed,palmPressed = false;
|
||||
boolean researchMode = false;
|
||||
|
||||
|
||||
PImage hand;
|
||||
PImage thumb;
|
||||
PImage index;
|
||||
PImage middle;
|
||||
PImage ring;
|
||||
PImage little;
|
||||
PImage palm;
|
||||
int last_command;
|
||||
|
||||
Button configClose;
|
||||
Button configConfirm;
|
||||
Button connect;
|
||||
MenuList obChanList;
|
||||
|
||||
//constructor 1
|
||||
OpenBionics_Widget(PApplet _parent) {
|
||||
parent = _parent;
|
||||
baudListOB = Arrays.asList("230400","115200","57600","38400","28800","19200","14400","9600","7200","4800","3600","2400","1800","1200","600","300");
|
||||
drawConfig = -1;
|
||||
|
||||
fingerChans = new int[6];
|
||||
for(int i = 0; i<6; i++) fingerChans[i] = -1;
|
||||
|
||||
configP5 = new ControlP5(parent);
|
||||
hand = loadImage("hand.png");
|
||||
thumb = loadImage("thumb_over.png");
|
||||
index = loadImage("index_over.png");
|
||||
middle = loadImage("middle_over.png");
|
||||
ring = loadImage("ring_over.png");
|
||||
little = loadImage("little_over.png");
|
||||
palm = loadImage("palm_over.png");
|
||||
|
||||
x = (int)container[parentContainer].x;
|
||||
y = (int)container[parentContainer].y;
|
||||
w = (int)container[parentContainer].w;
|
||||
h = (int)container[parentContainer].h;
|
||||
configClose = new Button(int(x) + w/4,int(y) + 3*navHeight,int(w/25.3),int(w/25.3),"X",fontInfo.buttonLabel_size);
|
||||
configConfirm = new Button(int(x) + w/2 + w/7,int(y) + 12*navHeight,int(w/10.12),int(w/25.3),"OKAY",fontInfo.buttonLabel_size);
|
||||
connect = new Button(int(x) + w - (w/6), int(y) + 14*navHeight, int(w/8), int(w/25.3), "CONNECT", fontInfo.buttonLabel_size);
|
||||
|
||||
obChanList = new MenuList(configP5, "obChanList", 100, 120, f2);
|
||||
obChanList.setPosition(x+w/3 + w/12, y + h/3 + h/16);
|
||||
|
||||
obChanList.addItem(makeItem("NONE"));
|
||||
obChanList.activeItem = 0;
|
||||
for(int i = 0; i < nchan; i++) obChanList.addItem(makeItem("" + (i+1)));
|
||||
|
||||
String[] serialPortsLocal = Serial.list();
|
||||
serialListOB = new ArrayList();
|
||||
for (int i = 0; i < serialPortsLocal.length; i++) {
|
||||
String tempPort = serialPortsLocal[(serialPortsLocal.length-1) - i]; //list backwards... because usually our port is at the bottom
|
||||
if(!tempPort.equals(openBCI_portName)) serialListOB.add(tempPort);
|
||||
}
|
||||
setupDropdownMenus(parent);
|
||||
}
|
||||
void process(){
|
||||
int output_normalized;
|
||||
StringBuilder researchCommand = new StringBuilder();
|
||||
|
||||
if(OpenBionicsHand != null ){
|
||||
if(!researchMode){
|
||||
OpenBionicsHand.write("A10\n");
|
||||
researchMode = true;
|
||||
}
|
||||
byte inByte = byte(OpenBionicsHand.read());
|
||||
|
||||
println(inByte);
|
||||
}
|
||||
|
||||
if(fingerChans[5] == -1){
|
||||
|
||||
if(OpenBionicsHand != null){
|
||||
|
||||
|
||||
for(int i = 0; i<5; i++){
|
||||
//================= OpenBionics Analog Movement =======================
|
||||
if(fingerChans[i] == -1) output_normalized = 0;
|
||||
else output_normalized = int(map(emg_widget.motorWidgets[fingerChans[i]].output_normalized, 0, 1, 0, 1023));
|
||||
|
||||
if(i == 4) researchCommand.append(output_normalized + "\n");
|
||||
else researchCommand.append(output_normalized + ",");
|
||||
|
||||
}
|
||||
OpenBionicsHand.write(researchCommand.toString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if(OpenBionicsHand != null){
|
||||
|
||||
output_normalized = int(map(emg_widget.motorWidgets[fingerChans[5]].output_normalized, 0, 1, 0, 100));
|
||||
OpenBionicsHand.write("G0P" + output_normalized + "\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void setupDropdownMenus(PApplet _parent) {
|
||||
//ControlP5 Stuff
|
||||
int dropdownPos;
|
||||
int dropdownWidth = 100;
|
||||
cp5_colors = new CColor();
|
||||
cp5_colors.setActive(color(150, 170, 200)); //when clicked
|
||||
cp5_colors.setForeground(color(125)); //when hovering
|
||||
cp5_colors.setBackground(color(255)); //color of buttons
|
||||
cp5_colors.setCaptionLabel(color(1, 18, 41)); //color of text
|
||||
cp5_colors.setValueLabel(color(0, 0, 255));
|
||||
|
||||
configP5.setColor(cp5_colors);
|
||||
configP5.setAutoDraw(false);
|
||||
//-------------------------------------------------------------
|
||||
//MAX FREQUENCY (ie X Axis) DROPDOWN
|
||||
//-------------------------------------------------------------
|
||||
dropdownPos = 4; //work down from 4 since we're starting on the right side now...
|
||||
configP5.addScrollableList("OpenBionicsSerialOut")
|
||||
.setPosition(x+w-(dropdownWidth*(dropdownPos+1))-((dropdownPos+1)), navHeight+(y+2)) //float right
|
||||
.setOpen(false)
|
||||
.setSize(dropdownWidth, (serialListOB.size()+1)*(navBarHeight-4))
|
||||
.setScrollSensitivity(0.0)
|
||||
.setBarHeight(navHeight - 4)
|
||||
.setItemHeight(navHeight - 4)
|
||||
.addItems(serialListOB)
|
||||
.setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST
|
||||
;
|
||||
|
||||
configP5.getController("OpenBionicsSerialOut")
|
||||
.getCaptionLabel()
|
||||
.setText("Serial Port")
|
||||
.setSize(12)
|
||||
.getStyle()
|
||||
;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
//Logarithmic vs. Linear DROPDOWN
|
||||
//-------------------------------------------------------------
|
||||
dropdownPos = 0;
|
||||
configP5.addScrollableList("BaudList")
|
||||
//.setPosition(w-(dropdownWidth*dropdownPos)-(2*(dropdownPos+1)), navHeight+(y+2)) // float left
|
||||
.setPosition(x+w-(dropdownWidth*(dropdownPos+1))-(2*(dropdownPos+1)), navHeight+(y+2))
|
||||
.setOpen(false)
|
||||
.setSize(dropdownWidth, (baudListOB.size()+1)*(navBarHeight-4))
|
||||
.setScrollSensitivity(0.0)
|
||||
.setBarHeight(navHeight - 4)
|
||||
.setItemHeight(navHeight - 4)
|
||||
.addItems(baudListOB)
|
||||
.setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST
|
||||
;
|
||||
|
||||
configP5.getController("BaudList")
|
||||
.getCaptionLabel()
|
||||
.setText("BAUD")
|
||||
.setSize(12)
|
||||
.getStyle()
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
void update() { } //may be used later
|
||||
|
||||
|
||||
void draw() {
|
||||
|
||||
if(drawBionics){
|
||||
pushStyle();
|
||||
|
||||
configP5.setVisible(true);
|
||||
|
||||
//draw FFT Graph w/ all plots
|
||||
noStroke();
|
||||
fill(255);
|
||||
rect(x, y, w, h);
|
||||
|
||||
|
||||
//draw nav bars and button bars
|
||||
fill(150, 150, 150);
|
||||
rect(x, y, w, navHeight); //top bar
|
||||
fill(200, 200, 200);
|
||||
rect(x, y+navHeight, w, navHeight); //button bar
|
||||
fill(255);
|
||||
rect(x+2, y+2, navHeight-4, navHeight-4);
|
||||
fill(bgColor, 100);
|
||||
//rect(x+3,y+3, (navHeight-7)/2, navHeight-10);
|
||||
rect(x+4, y+4, (navHeight-10)/2, (navHeight-10)/2);
|
||||
rect(x+4, y+((navHeight-10)/2)+5, (navHeight-10)/2, (navHeight-10)/2);
|
||||
rect(x+((navHeight-10)/2)+5, y+4, (navHeight-10)/2, (navHeight-10)/2);
|
||||
rect(x+((navHeight-10)/2)+5, y+((navHeight-10)/2)+5, (navHeight-10)/2, (navHeight-10 )/2);
|
||||
//text("FFT Plot", x+w/2, y+navHeight/2)
|
||||
fill(bgColor);
|
||||
textAlign(LEFT, CENTER);
|
||||
textFont(f);
|
||||
textSize(18);
|
||||
text("OpenBionics", x+navHeight+2, y+navHeight/2 - 2); //title of widget -- left
|
||||
//textAlign(CENTER,CENTER); text("FFT Plot", w/2, y+navHeight/2 - 2); //title of widget -- left
|
||||
//fill(255,0,0,150);
|
||||
//rect(x,y,w,h);
|
||||
|
||||
//draw dropdown titles
|
||||
int dropdownPos = 1; //used to loop through drop down titles ... should use for loop with titles in String array, but... laziness has ensued. -Conor
|
||||
int dropdownWidth = 100;
|
||||
textFont(f2);
|
||||
textSize(12);
|
||||
textAlign(CENTER, BOTTOM);
|
||||
fill(bgColor);
|
||||
text("OpenBionics Serial Out", x+w-(dropdownWidth*(dropdownPos+1))-(2*(dropdownPos+1))+dropdownWidth/2, y+(navHeight-2));
|
||||
dropdownPos = 0;
|
||||
text("Baud List", x+w-(dropdownWidth*(dropdownPos+1))-(2*(dropdownPos+1))+dropdownWidth/2, y+(navHeight-2));
|
||||
|
||||
//draw dropdown menus
|
||||
|
||||
|
||||
switch(drawConfig){
|
||||
case -1:
|
||||
image(hand,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
|
||||
if(overThumb()) image(thumb,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overIndex()) image(index,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overMiddle()) image(middle,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overRing()) image(ring,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overLittle()) image(little,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overPalm()) image(palm,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(false);
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = 0;
|
||||
connect.draw();
|
||||
break;
|
||||
case 0:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Thumb Finger Channel Selection", x + w/2, y + 4*navHeight);
|
||||
break;
|
||||
case 1:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Index Finger Channel Selection", x + w/2, y + 4*navHeight);
|
||||
break;
|
||||
case 2:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Middle Finger Channel Selection", x + w/2, y + 4*navHeight);
|
||||
break;
|
||||
case 3:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Ring Finger Channel Selection", x + w/2, y + 4*navHeight);
|
||||
break;
|
||||
case 4:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Little Finger Channel Selection", x + w/2, y + 4*navHeight);
|
||||
break;
|
||||
case 5:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Hand Channel Selection", x + w/2, y + 4*navHeight);
|
||||
break;
|
||||
}
|
||||
configP5.draw();
|
||||
|
||||
popStyle();
|
||||
}
|
||||
}
|
||||
|
||||
void screenResized(PApplet _parent, int _winX, int _winY) {
|
||||
//when screen is resized...
|
||||
//update position/size of FFT widget
|
||||
x = (int)container[parentContainer].x;
|
||||
y = (int)container[parentContainer].y;
|
||||
w = (int)container[parentContainer].w;
|
||||
h = (int)container[parentContainer].h;
|
||||
|
||||
|
||||
configClose = new Button(int(x) + w/4,int(y) + 3*navHeight,int(w/25.3),int(w/25.3),"X",fontInfo.buttonLabel_size);
|
||||
configConfirm = new Button(int(x) + w/2 + w/7,int(y) + 12*navHeight,int(w/10.12),int(w/25.3),"OKAY",fontInfo.buttonLabel_size);
|
||||
|
||||
//update dropdown menu positions
|
||||
configP5.setGraphics(_parent, 0, 0); //remaps the cp5 controller to the new PApplet window size
|
||||
int dropdownPos;
|
||||
int dropdownWidth = 60;
|
||||
dropdownPos = 1; //work down from 4 since we're starting on the right side now...
|
||||
configP5.getController("OpenBionicsSerialOut")
|
||||
.setPosition(x+w-(dropdownWidth*(dropdownPos+1))-(2*(dropdownPos+1)), navHeight+(y+2)) //float right
|
||||
;
|
||||
dropdownPos = 0;
|
||||
try{
|
||||
configP5.getController("LogLin")
|
||||
.setPosition(x+w-(dropdownWidth*(dropdownPos+1))-(2*(dropdownPos+1)), navHeight+(y+2)) //float right
|
||||
;
|
||||
}
|
||||
catch(Exception e){
|
||||
println("error resizing...");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
//called by GUI_Widgets.pde
|
||||
if(drawConfig == -1){
|
||||
if(overThumb()) thumbPressed = true;
|
||||
else if(overIndex()) indexPressed = true;
|
||||
else if(overMiddle()) middlePressed = true;
|
||||
else if(overRing()) ringPressed = true;
|
||||
else if(overLittle()) littlePressed = true;
|
||||
else if(overPalm()) palmPressed = true;
|
||||
else if(connect.isMouseHere()) connect.wasPressed = true;
|
||||
}
|
||||
else{
|
||||
if(configClose.isMouseHere()) configClose.wasPressed= true;
|
||||
else if(configConfirm.isMouseHere()) configConfirm.wasPressed= true;
|
||||
}
|
||||
|
||||
}
|
||||
void mouseReleased() {
|
||||
//called by GUI_Widgets.pde
|
||||
if(drawConfig == -1){
|
||||
if (overThumb() && thumbPressed){drawConfig = 0;}
|
||||
else if (overIndex() && indexPressed){drawConfig= 1;}
|
||||
else if (overMiddle() && middlePressed){drawConfig = 2;}
|
||||
else if (overRing() && ringPressed){drawConfig = 3;}
|
||||
else if (overLittle() && littlePressed){drawConfig = 4;}
|
||||
else if (overPalm() && palmPressed){drawConfig = 5;}
|
||||
else if(connect.isMouseHere() && connect.wasPressed){
|
||||
|
||||
//Connect to OpenBionics Hand
|
||||
try{
|
||||
|
||||
OpenBionicsHand = new Serial(parent,obName,Integer.parseInt(obBaud));
|
||||
verbosePrint("Connected to OpenBionics Hand");
|
||||
}
|
||||
catch(Exception e){
|
||||
println(e);
|
||||
verbosePrint("Could not connect to OpenBionics Hand");
|
||||
}
|
||||
}
|
||||
|
||||
thumbPressed = false;
|
||||
indexPressed = false;
|
||||
middlePressed = false;
|
||||
ringPressed = false;
|
||||
littlePressed = false;
|
||||
palmPressed = false;
|
||||
cursor(ARROW);
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
if(configClose.isMouseHere() && configClose.wasPressed) {
|
||||
configClose.wasPressed= false;
|
||||
drawConfig = -1;
|
||||
}
|
||||
else if(configConfirm.isMouseHere() && configConfirm.wasPressed){
|
||||
configConfirm.wasPressed= false;
|
||||
drawConfig = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean overThumb(){
|
||||
if(mouseX >= x + w/3.9 && mouseX <=x + w/2.5 && mouseY >= y + h/1.8 && mouseY <= y + h/1.32){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overIndex(){
|
||||
if(mouseX >= x + w/2.65 && mouseX <=x + w/2.07 && mouseY >= y + h/4.89 && mouseY <= y + h/1.99){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overMiddle(){
|
||||
if(mouseX >= x + w/2.01 && mouseX <=x + w/1.79 && mouseY >= y + h/7.08 && mouseY <= y + h/2.14){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overRing(){
|
||||
if(mouseX >= x + w/1.73 && mouseX <=x + w/1.5 && mouseY >= y + h/5.59 && mouseY <= y + h/1.95){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overLittle(){
|
||||
if(mouseX >= x + w/1.54 && mouseX <=x + w/1.34 && mouseY >= y + h/3.13 && mouseY <= y + h/1.78){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overPalm(){
|
||||
if(mouseX >= x + w/2.47 && mouseX <=x + w/1.48 && mouseY >= y + h/1.89 && mouseY <= y + h/1.05){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//void keyPressed() {
|
||||
// //called by GUI_Widgets.pde
|
||||
//}
|
||||
//void keyReleased() {
|
||||
// //called by GUI_Widgets.pde
|
||||
//}
|
||||
}
|
||||
|
||||
void OpenBionicsSerialOut(int n){
|
||||
obName = (String)serialListOB.get(n);
|
||||
}
|
||||
|
||||
void BaudList(int n){
|
||||
obBaud = (String)baudListOB.get(n);
|
||||
}
|
||||
|
||||
void obChanList(int n){
|
||||
//println("Value: "+ (n-1));
|
||||
fingerChans[drawConfig] = n - 1;
|
||||
}
|
||||
@@ -74,9 +74,10 @@ class Presentation {
|
||||
|
||||
public void draw() {
|
||||
// ----- Drawing Presentation -------
|
||||
if (drawPresentation == true) {
|
||||
image(presentationSlides[currentSlide], 0, 0, width, height);
|
||||
}
|
||||
pushStyle();
|
||||
|
||||
image(presentationSlides[currentSlide], 0, 0, width, height);
|
||||
|
||||
|
||||
if(lockSlides){
|
||||
//draw red rectangle to indicate that slides are locked
|
||||
@@ -85,5 +86,12 @@ class Presentation {
|
||||
rect(width - 50, 25, 25, 25);
|
||||
popStyle();
|
||||
}
|
||||
|
||||
textFont(p3, 16);
|
||||
fill(openbciBlue);
|
||||
textAlign(CENTER);
|
||||
text("Press [Enter] to exit presentation mode.", width/2, 31*(height/32));
|
||||
|
||||
popStyle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
// rather than the OpenBCI_ADS1299 class. I just found this easier to work
|
||||
// with.
|
||||
//
|
||||
// Modified by Joel Murphy, January 2017
|
||||
//
|
||||
//
|
||||
// KNOWN ISSUES:
|
||||
//
|
||||
// TODO:
|
||||
@@ -25,154 +28,267 @@ void autoconnect(){
|
||||
serialPorts = Serial.list();
|
||||
|
||||
|
||||
|
||||
for(int i = 0; i < serialPorts.length; i++){
|
||||
// for(int i = serialPorts.length-1; i >= 0; i--){
|
||||
try{
|
||||
serialPort = serialPorts[i];
|
||||
board = new Serial(this,serialPort,115200);
|
||||
println(serialPort);
|
||||
print("try "); print(i); print(" "); print(serialPort); println(" at 115200 baud");
|
||||
output("Attempting to connect at 115200 baud to " + serialPort); // not working
|
||||
delay(5000);
|
||||
|
||||
delay(1000);
|
||||
|
||||
board.write('?');
|
||||
// board.write('?');
|
||||
board.write('v'); //modified by JAM 1/17
|
||||
//board.write(0x07);
|
||||
delay(1000);
|
||||
delay(2000);
|
||||
if(confirm_openbci()) {
|
||||
println("Board connected on port " +serialPorts[i] + " with BAUD 115200");
|
||||
output("Connected to " + serialPort + "!");
|
||||
openBCI_portName = serialPorts[i];
|
||||
openBCI_baud = 115200;
|
||||
board.stop();
|
||||
return;
|
||||
} else {
|
||||
println("Board not on port " + serialPorts[i] +" with BAUD 115200");
|
||||
board.stop();
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
println("Board not on port " + serialPorts[i] +" with BAUD 115200");
|
||||
println("Exception " + serialPorts[i] + " " + e);
|
||||
}
|
||||
|
||||
try{
|
||||
board = new Serial(this,serialPort,230400);
|
||||
println(serialPort);
|
||||
print("try "); print(i); print(" "); print(serialPort); println(" at 230400 baud");
|
||||
output("Attempting to connect at 230400 baud to " + serialPort); // not working
|
||||
delay(5000);
|
||||
|
||||
delay(1000);
|
||||
|
||||
board.write('?');
|
||||
// board.write('?');
|
||||
board.write('v'); //modified by JAM 1/17
|
||||
//board.write(0x07);
|
||||
delay(1000);
|
||||
if(confirm_openbci()) {
|
||||
delay(2000);
|
||||
if(confirm_openbci()) { // was just confrim_openbci JAM 1/2017
|
||||
println("Board connected on port " +serialPorts[i] + " with BAUD 230400");
|
||||
output("Connected to " + serialPort + "!"); // not working
|
||||
openBCI_baud = 230400;
|
||||
openBCI_portName = serialPorts[i];
|
||||
board.stop();
|
||||
return;
|
||||
} else {
|
||||
println("Board not on port " + serialPorts[i] +" with BAUD 230400");
|
||||
board.stop();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e){
|
||||
println("Board not on port " + serialPorts[i] +" with BAUD 230400");
|
||||
println("Exception " + serialPorts[i] + " " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Serial autoconnect_return_default() throws Exception{
|
||||
// Serial autoconnect_return_default() throws Exception{
|
||||
//
|
||||
// Serial locBoard; //local serial instance just to make sure it's openbci, then connect to it if it is
|
||||
// Serial retBoard;
|
||||
// String[] serialPorts = new String[Serial.list().length];
|
||||
// String serialPort = "";
|
||||
// serialPorts = Serial.list();
|
||||
//
|
||||
//
|
||||
// for(int i = 0; i < serialPorts.length; i++){
|
||||
//
|
||||
// try{
|
||||
// serialPort = serialPorts[i];
|
||||
// locBoard = new Serial(this,serialPort,115200);
|
||||
//
|
||||
// delay(100);
|
||||
//
|
||||
// locBoard.write(0xF0);
|
||||
// locBoard.write(0x07);
|
||||
// delay(1000);
|
||||
//
|
||||
// if(confirm_openbci_v2()) {
|
||||
// println("Board connected on port " +serialPorts[i] + " with BAUD 115200");
|
||||
// no_start_connection = true;
|
||||
// openBCI_portName = serialPorts[i];
|
||||
// openBCI_baud = 115200;
|
||||
// isOpenBCI = false;
|
||||
//
|
||||
// return locBoard;
|
||||
// }
|
||||
// else locBoard.stop();
|
||||
// }
|
||||
// catch (Exception e){
|
||||
// println("Board not on port " + serialPorts[i] +" with BAUD 115200");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// throw new Exception();
|
||||
// }
|
||||
|
||||
Serial locBoard; //local serial instance just to make sure it's openbci, then connect to it if it is
|
||||
Serial retBoard;
|
||||
String[] serialPorts = new String[Serial.list().length];
|
||||
String serialPort = "";
|
||||
serialPorts = Serial.list();
|
||||
|
||||
|
||||
for(int i = 0; i < serialPorts.length; i++){
|
||||
|
||||
try{
|
||||
serialPort = serialPorts[i];
|
||||
locBoard = new Serial(this,serialPort,115200);
|
||||
|
||||
delay(100);
|
||||
|
||||
locBoard.write(0xF0);
|
||||
locBoard.write(0x07);
|
||||
delay(1000);
|
||||
|
||||
if(confirm_openbci_v2()) {
|
||||
println("Board connected on port " +serialPorts[i] + " with BAUD 115200");
|
||||
no_start_connection = true;
|
||||
openBCI_portName = serialPorts[i];
|
||||
openBCI_baud = 115200;
|
||||
isOpenBCI = false;
|
||||
|
||||
return locBoard;
|
||||
}
|
||||
else locBoard.stop();
|
||||
}
|
||||
catch (Exception e){
|
||||
println("Board not on port " + serialPorts[i] +" with BAUD 115200");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
Serial autoconnect_return_high() throws Exception{
|
||||
|
||||
Serial localBoard; //local serial instance just to make sure it's openbci, then connect to it if it is
|
||||
String[] serialPorts = new String[Serial.list().length];
|
||||
String serialPort = "";
|
||||
serialPorts = Serial.list();
|
||||
|
||||
|
||||
for(int i = 0; i < serialPorts.length; i++){
|
||||
try{
|
||||
serialPort = serialPorts[i];
|
||||
localBoard = new Serial(this,serialPort,230400);
|
||||
|
||||
delay(100);
|
||||
|
||||
localBoard.write(0xF0);
|
||||
localBoard.write(0x07);
|
||||
delay(1000);
|
||||
if(confirm_openbci_v2()) {
|
||||
println("Board connected on port " +serialPorts[i] + " with BAUD 230400");
|
||||
no_start_connection = true;
|
||||
openBCI_portName = serialPorts[i];
|
||||
openBCI_baud = 230400;
|
||||
isOpenBCI = false;
|
||||
|
||||
return localBoard;
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
println("Board not on port " + serialPorts[i] +" with BAUD 230400");
|
||||
}
|
||||
|
||||
}
|
||||
throw new Exception();
|
||||
}
|
||||
// Serial autoconnect_return_high() throws Exception{
|
||||
//
|
||||
// Serial localBoard; //local serial instance just to make sure it's openbci, then connect to it if it is
|
||||
// String[] serialPorts = new String[Serial.list().length];
|
||||
// String serialPort = "";
|
||||
// serialPorts = Serial.list();
|
||||
//
|
||||
//
|
||||
// for(int i = 0; i < serialPorts.length; i++){
|
||||
// try{
|
||||
// serialPort = serialPorts[i];
|
||||
// localBoard = new Serial(this,serialPort,230400);
|
||||
//
|
||||
// delay(100);
|
||||
//
|
||||
// localBoard.write(0xF0);
|
||||
// localBoard.write(0x07);
|
||||
// delay(1000);
|
||||
// if(confirm_openbci_v2()) {
|
||||
// println("Board connected on port " +serialPorts[i] + " with BAUD 230400");
|
||||
// no_start_connection = true;
|
||||
// openBCI_portName = serialPorts[i];
|
||||
// openBCI_baud = 230400;
|
||||
// isOpenBCI = false;
|
||||
//
|
||||
// return localBoard;
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e){
|
||||
// println("Board not on port " + serialPorts[i] +" with BAUD 230400");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// throw new Exception();
|
||||
// }
|
||||
|
||||
/**** Helper function for connection of boards ****/
|
||||
boolean confirm_openbci(){
|
||||
//println(board_message.toString());
|
||||
if(board_message.toString().toLowerCase().contains("registers")) return true;
|
||||
else return false;
|
||||
// if(board_message.toString().toLowerCase().contains("registers")) return true;
|
||||
// print("board "); print(board_message.toString()); println("message");
|
||||
if(board_message != null){
|
||||
if(board_message.toString().toLowerCase().contains("ads")){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean confirm_openbci_v2(){
|
||||
//println(board_message.toString());
|
||||
if(board_message.toString().toLowerCase().contains("success")) return true;
|
||||
// if(board_message.toString().contains("v2.")) return true;
|
||||
else return false;
|
||||
}
|
||||
/**** Helper function for autoscan ****/
|
||||
boolean confirm_connected(){
|
||||
if( board_message != null && board_message.toString().charAt(0) == 'S') return true;
|
||||
if( board_message != null && board_message.toString().toLowerCase().contains("success")) return true; // JAM added .containes("success")
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**** Helper function to read from the serial easily ****/
|
||||
void print_bytes(RadioConfigBox rc){
|
||||
println(board_message.toString());
|
||||
rc.print_onscreen(board_message.toString());
|
||||
boolean print_bytes(RadioConfigBox rc){
|
||||
if(board_message != null){
|
||||
println(board_message.toString());
|
||||
rc.print_onscreen(board_message.toString());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void print_bytes_error(RadioConfigBox rcConfig){
|
||||
println("Error reading from Serial/COM port");
|
||||
rcConfig.print_onscreen("Error reading from Serial port. Try a different port?");
|
||||
board = null;
|
||||
}
|
||||
|
||||
/**** Function to connect to a selected port ****/ // JAM 1/2017
|
||||
// Needs to be connected to something to perform the Radio_Config tasks
|
||||
boolean connect_to_portName(RadioConfigBox rcConfig){
|
||||
if(openBCI_portName != "N/A"){
|
||||
output("Attempting to open Serial/COM port: " + openBCI_portName);
|
||||
try {
|
||||
println("Radios_Config: connect_to_portName: attempting to open serial port: " + openBCI_portName);
|
||||
serial_output = new Serial(this,openBCI_portName,openBCI_baud); //open the com port
|
||||
serial_output.clear(); // clear anything in the com port's buffer
|
||||
// portIsOpen = true;
|
||||
println("Radios_Config: connect_to_portName: port is open!");
|
||||
// changeState(STATE_COMINIT);
|
||||
board = serial_output;
|
||||
return true;
|
||||
}
|
||||
catch (RuntimeException e){
|
||||
if (e.getMessage().contains("<init>")) {
|
||||
serial_output = null;
|
||||
System.out.println("Radios_Config: connect_to_portName: port in use, trying again later...");
|
||||
// portIsOpen = false;
|
||||
} else{
|
||||
println("RunttimeException: " + e);
|
||||
output("Error connecting to selected Serial/COM port. Make sure your board is powered up and your dongle is plugged in.");
|
||||
rcConfig.print_onscreen("Error connecting to Serial port. Try a different port?");
|
||||
}
|
||||
board = null;
|
||||
println("Radios_Config: connect_to_portName: failed to connect to " + openBCI_portName);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
output("No Serial/COM port selected. Please select your Serial/COM port and retry");
|
||||
rcConfig.print_onscreen("Select a Serial/COM port, then try again");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=========== GET SYSTEM STATUS ============
|
||||
//= Get's the current status of the system
|
||||
//=
|
||||
//= First writes 0xF0 to let the board know
|
||||
//= a command is coming, then writes the
|
||||
//= command (0x07).
|
||||
//=
|
||||
//= After a short delay it then prints bytes
|
||||
//= from the board.
|
||||
//==========================================
|
||||
|
||||
void system_status(RadioConfigBox rcConfig){
|
||||
if(board == null){
|
||||
if(!connect_to_portName(rcConfig)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(board != null){
|
||||
board.write(0xF0);
|
||||
board.write(0x07);
|
||||
delay(100);
|
||||
if(!print_bytes(rcConfig)){
|
||||
print_bytes_error(rcConfig);
|
||||
}
|
||||
} else {
|
||||
println("Error, no board connected");
|
||||
rcConfig.print_onscreen("No board connected!");
|
||||
}
|
||||
}
|
||||
|
||||
//Scans through channels until a success message has been found
|
||||
void scan_channels(RadioConfigBox rcConfig){
|
||||
if(board == null){
|
||||
if(!connect_to_portName(rcConfig)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
for(int i = 1; i < 26; i++){
|
||||
|
||||
set_channel_over(rcConfig,i);
|
||||
system_status(rcConfig);
|
||||
if(confirm_connected()) return; // break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============== GET CHANNEL ===============
|
||||
//= Gets channel information from the radio.
|
||||
@@ -186,12 +302,19 @@ void print_bytes(RadioConfigBox rc){
|
||||
//==========================================
|
||||
|
||||
void get_channel(RadioConfigBox rcConfig){
|
||||
if(board == null){
|
||||
if(!connect_to_portName(rcConfig)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(board != null){
|
||||
board.write(0xF0);
|
||||
board.write(0x00);
|
||||
delay(100);
|
||||
|
||||
print_bytes(rcConfig);
|
||||
if(!print_bytes(rcConfig)){
|
||||
print_bytes_error(rcConfig);
|
||||
}
|
||||
}
|
||||
else {
|
||||
println("Error, no board connected");
|
||||
@@ -213,13 +336,20 @@ void get_channel(RadioConfigBox rcConfig){
|
||||
//==========================================
|
||||
|
||||
void set_channel(RadioConfigBox rcConfig, int channel_number){
|
||||
if(board == null){
|
||||
if(!connect_to_portName(rcConfig)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(board != null){
|
||||
if(channel_number > 0){
|
||||
board.write(0xF0);
|
||||
board.write(0x01);
|
||||
board.write(byte(channel_number));
|
||||
delay(1000);
|
||||
print_bytes(rcConfig);
|
||||
if(!print_bytes(rcConfig)){
|
||||
print_bytes_error(rcConfig);
|
||||
}
|
||||
}
|
||||
else rcConfig.print_onscreen("Please Select a Channel");
|
||||
}
|
||||
@@ -243,13 +373,20 @@ void set_channel(RadioConfigBox rcConfig, int channel_number){
|
||||
//==========================================
|
||||
|
||||
void set_channel_over(RadioConfigBox rcConfig, int channel_number){
|
||||
if(board == null){
|
||||
if(!connect_to_portName(rcConfig)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(board != null){
|
||||
if(channel_number > 0){
|
||||
board.write(0xF0);
|
||||
board.write(0x02);
|
||||
board.write(byte(channel_number));
|
||||
delay(100);
|
||||
print_bytes(rcConfig);
|
||||
if(!print_bytes(rcConfig)){
|
||||
print_bytes_error(rcConfig);
|
||||
}
|
||||
}
|
||||
|
||||
else rcConfig.print_onscreen("Please Select a Channel");
|
||||
@@ -272,23 +409,30 @@ void set_channel_over(RadioConfigBox rcConfig, int channel_number){
|
||||
//= from the board.
|
||||
//==========================================
|
||||
|
||||
void get_poll(RadioConfigBox rcConfig){
|
||||
if(board != null){
|
||||
board.write(0xF0);
|
||||
board.write(0x03);
|
||||
isGettingPoll = true;
|
||||
delay(100);
|
||||
board_message.append(hexToInt);
|
||||
print_bytes(rcConfig);
|
||||
isGettingPoll = false;
|
||||
spaceFound = false;
|
||||
}
|
||||
|
||||
else {
|
||||
println("Error, no board connected");
|
||||
rcConfig.print_onscreen("No board connected!");
|
||||
}
|
||||
}
|
||||
// void get_poll(RadioConfigBox rcConfig){
|
||||
// if(board == null){
|
||||
// if(!connect_to_portName(rcConfig)){
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if(board != null){
|
||||
// board.write(0xF0);
|
||||
// board.write(0x03);
|
||||
// isGettingPoll = true;
|
||||
// delay(100);
|
||||
// board_message.append(hexToInt);
|
||||
// if(!print_bytes(rcConfig)){
|
||||
// print_bytes_error(rcConfig);
|
||||
// }
|
||||
// isGettingPoll = false;
|
||||
// spaceFound = false;
|
||||
// }
|
||||
//
|
||||
// else {
|
||||
// println("Error, no board connected");
|
||||
// rcConfig.print_onscreen("No board connected!");
|
||||
// }
|
||||
// }
|
||||
|
||||
//=========== SET POLL OVERRIDE ============
|
||||
//= Sets the poll time
|
||||
@@ -303,19 +447,26 @@ void get_poll(RadioConfigBox rcConfig){
|
||||
//= from the board.
|
||||
//==========================================
|
||||
|
||||
void set_poll(RadioConfigBox rcConfig, int poll_number){
|
||||
if(board != null){
|
||||
board.write(0xF0);
|
||||
board.write(0x04);
|
||||
board.write(byte(poll_number));
|
||||
delay(1000);
|
||||
print_bytes(rcConfig);
|
||||
}
|
||||
else {
|
||||
println("Error, no board connected");
|
||||
rcConfig.print_onscreen("No board connected!");
|
||||
}
|
||||
}
|
||||
// void set_poll(RadioConfigBox rcConfig, int poll_number){
|
||||
// if(board == null){
|
||||
// if(!connect_to_portName(rcConfig)){
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if(board != null){
|
||||
// board.write(0xF0);
|
||||
// board.write(0x04);
|
||||
// board.write(byte(poll_number));
|
||||
// delay(1000);
|
||||
// if(!print_bytes(rcConfig)){
|
||||
// print_bytes_error(rcConfig);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// println("Error, no board connected");
|
||||
// rcConfig.print_onscreen("No board connected!");
|
||||
// }
|
||||
// }
|
||||
|
||||
//========== SET BAUD TO DEFAULT ===========
|
||||
//= Sets BAUD to it's default value (115200)
|
||||
@@ -328,29 +479,36 @@ void set_poll(RadioConfigBox rcConfig, int poll_number){
|
||||
//= from the board.
|
||||
//==========================================
|
||||
|
||||
void set_baud_default(RadioConfigBox rcConfig, String serialPort){
|
||||
if(board != null){
|
||||
board.write(0xF0);
|
||||
board.write(0x05);
|
||||
delay(1000);
|
||||
print_bytes(rcConfig);
|
||||
delay(1000);
|
||||
|
||||
|
||||
try{
|
||||
board.stop();
|
||||
board = null;
|
||||
board = autoconnect_return_default();
|
||||
}
|
||||
catch (Exception e){
|
||||
println("error setting serial to BAUD 115200");
|
||||
}
|
||||
}
|
||||
else {
|
||||
println("Error, no board connected");
|
||||
rcConfig.print_onscreen("No board connected!");
|
||||
}
|
||||
}
|
||||
// void set_baud_default(RadioConfigBox rcConfig, String serialPort){
|
||||
// if(board == null){
|
||||
// if(!connect_to_portName(rcConfig)){
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if(board != null){
|
||||
// board.write(0xF0);
|
||||
// board.write(0x05);
|
||||
// delay(1000);
|
||||
// if(!print_bytes(rcConfig)){
|
||||
// print_bytes_error(rcConfig);
|
||||
// }
|
||||
// delay(1000);
|
||||
//
|
||||
//
|
||||
// try{
|
||||
// board.stop();
|
||||
// board = null;
|
||||
// board = autoconnect_return_default();
|
||||
// }
|
||||
// catch (Exception e){
|
||||
// println("error setting serial to BAUD 115200");
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// println("Error, no board connected");
|
||||
// rcConfig.print_onscreen("No board connected!");
|
||||
// }
|
||||
// }
|
||||
|
||||
//====== SET BAUD TO HIGH-SPEED MODE =======
|
||||
//= Sets BAUD to a higher rate (230400)
|
||||
@@ -363,61 +521,33 @@ void set_baud_default(RadioConfigBox rcConfig, String serialPort){
|
||||
//= from the board.
|
||||
//==========================================
|
||||
|
||||
void set_baud_high(RadioConfigBox rcConfig, String serialPort){
|
||||
if(board != null){
|
||||
board.write(0xF0);
|
||||
board.write(0x06);
|
||||
delay(1000);
|
||||
print_bytes(rcConfig);
|
||||
delay(1000);
|
||||
|
||||
try{
|
||||
board.stop();
|
||||
board = null;
|
||||
board = autoconnect_return_high();
|
||||
}
|
||||
catch (Exception e){
|
||||
println("error setting serial to BAUD 230400");
|
||||
}
|
||||
}
|
||||
else {
|
||||
println("Error, no board connected");
|
||||
rcConfig.print_onscreen("No board connected!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=========== GET SYSTEM STATUS ============
|
||||
//= Get's the current status of the system
|
||||
//=
|
||||
//= First writes 0xF0 to let the board know
|
||||
//= a command is coming, then writes the
|
||||
//= command (0x07).
|
||||
//=
|
||||
//= After a short delay it then prints bytes
|
||||
//= from the board.
|
||||
//==========================================
|
||||
|
||||
void system_status(RadioConfigBox rcConfig){
|
||||
if(board != null){
|
||||
board.write(0xF0);
|
||||
board.write(0x07);
|
||||
delay(100);
|
||||
print_bytes(rcConfig);
|
||||
}
|
||||
else {
|
||||
println("Error, no board connected");
|
||||
rcConfig.print_onscreen("No board connected!");
|
||||
}
|
||||
}
|
||||
|
||||
//Scans through channels until a success message has been found
|
||||
void scan_channels(RadioConfigBox rcConfig){
|
||||
|
||||
for(int i = 1; i < 26; i++){
|
||||
|
||||
set_channel_over(rcConfig,i);
|
||||
system_status(rcConfig);
|
||||
if(confirm_connected()) break;
|
||||
}
|
||||
}
|
||||
// void set_baud_high(RadioConfigBox rcConfig, String serialPort){
|
||||
// if(board == null){
|
||||
// if(!connect_to_portName(rcConfig)){
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if(board != null){
|
||||
// board.write(0xF0);
|
||||
// board.write(0x06);
|
||||
// delay(1000);
|
||||
// if(!print_bytes(rcConfig)){
|
||||
// print_bytes_error(rcConfig);
|
||||
// }
|
||||
// delay(1000);
|
||||
//
|
||||
// try{
|
||||
// board.stop();
|
||||
// board = null;
|
||||
// board = autoconnect_return_high();
|
||||
// }
|
||||
// catch (Exception e){
|
||||
// println("error setting serial to BAUD 230400");
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// println("Error, no board connected");
|
||||
// rcConfig.print_onscreen("No board connected!");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
Antes Largura: | Altura: | Tamanho: 167 KiB |
|
Depois Largura: | Altura: | Tamanho: 241 KiB |
|
Depois Largura: | Altura: | Tamanho: 269 KiB |
|
Depois Largura: | Altura: | Tamanho: 276 KiB |
|
Depois Largura: | Altura: | Tamanho: 275 KiB |
|
Depois Largura: | Altura: | Tamanho: 269 KiB |
|
Depois Largura: | Altura: | Tamanho: 167 KiB |
|
Depois Largura: | Altura: | Tamanho: 168 KiB |
|
Depois Largura: | Altura: | Tamanho: 214 KiB |
|
Depois Largura: | Altura: | Tamanho: 187 KiB |
|
Depois Largura: | Altura: | Tamanho: 167 KiB |
|
Depois Largura: | Altura: | Tamanho: 163 KiB |
|
Depois Largura: | Altura: | Tamanho: 152 KiB |
|
Depois Largura: | Altura: | Tamanho: 150 KiB |
|
Depois Largura: | Altura: | Tamanho: 151 KiB |
|
Depois Largura: | Altura: | Tamanho: 153 KiB |
|
Depois Largura: | Altura: | Tamanho: 152 KiB |
|
Depois Largura: | Altura: | Tamanho: 175 KiB |
|
Depois Largura: | Altura: | Tamanho: 175 KiB |
|
Depois Largura: | Altura: | Tamanho: 173 KiB |
|
Depois Largura: | Altura: | Tamanho: 172 KiB |
|
Depois Largura: | Altura: | Tamanho: 173 KiB |
|
Depois Largura: | Altura: | Tamanho: 221 KiB |
|
Depois Largura: | Altura: | Tamanho: 216 KiB |
|
Depois Largura: | Altura: | Tamanho: 245 KiB |
@@ -110,12 +110,24 @@ class W_fft extends Widget {
|
||||
//put your code here...
|
||||
//update the points of the FFT channel arrays
|
||||
//update fft point arrays
|
||||
// println("LENGTH = " + fft_points.length);
|
||||
// println("LENGTH = " + fftBuff.length);
|
||||
// println("LENGTH = " + FFT_indexLim);
|
||||
for (int i = 0; i < fft_points.length; i++) {
|
||||
for (int j = 0; j < FFT_indexLim + 2; j++) { //loop through frequency domain data, and store into points array
|
||||
//GPoint powerAtBin = new GPoint(j, 15*random(0.1*j));
|
||||
GPoint powerAtBin;
|
||||
|
||||
GPoint powerAtBin = new GPoint((1.0*get_fs_Hz_safe()/Nfft)*j, fftBuff[i].getBand(j));
|
||||
// println("i = " + i);
|
||||
// float a = get_fs_Hz_safe();
|
||||
// float aa = fftBuff[i].getBand(j);
|
||||
// float b = fftBuff[i].getBand(j);
|
||||
// float c = Nfft;
|
||||
|
||||
powerAtBin = new GPoint((1.0*get_fs_Hz_safe()/Nfft)*j, fftBuff[i].getBand(j));
|
||||
fft_points[i].set(j, powerAtBin);
|
||||
// GPoint powerAtBin = new GPoint((1.0*get_fs_Hz_safe()/Nfft)*j, fftBuff[i].getBand(j));
|
||||
|
||||
//println("=========================================");
|
||||
//println(j);
|
||||
//println(fftBuff[i].getBand(j) + " :: " + fft_points[i].getX(j) + " :: " + fft_points[i].getY(j));
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// W_template.pde (ie "Widget Template")
|
||||
//
|
||||
// This is a Template Widget, intended to be used as a starting point for OpenBCI Community members that want to develop their own custom widgets!
|
||||
// Good luck! If you embark on this journey, please let us know. Your contributions are valuable to everyone!
|
||||
//
|
||||
// Created by: Conor Russomanno, November 2016
|
||||
//
|
||||
///////////////////////////////////////////////////,
|
||||
|
||||
class W_openBionics extends Widget {
|
||||
|
||||
//to see all core variables/methods of the Widget class, refer to Widget.pde
|
||||
//put your custom variables here...
|
||||
PApplet parent;
|
||||
|
||||
Serial OpenBionicsHand;
|
||||
PFont f = createFont("Arial Bold", 24); //for "FFT Plot" Widget Title
|
||||
PFont f2 = createFont("Arial", 18); //for dropdown name titles (above dropdown widgets)
|
||||
|
||||
int parentContainer = 9; //which container is it mapped to by default?
|
||||
boolean thumbPressed,indexPressed,middlePressed,ringPressed,littlePressed,palmPressed = false;
|
||||
boolean researchMode = false;
|
||||
|
||||
|
||||
PImage hand;
|
||||
PImage thumb;
|
||||
PImage index;
|
||||
PImage middle;
|
||||
PImage ring;
|
||||
PImage little;
|
||||
PImage palm;
|
||||
int last_command;
|
||||
|
||||
Button configClose;
|
||||
Button configConfirm;
|
||||
Button connect;
|
||||
MenuList obChanList;
|
||||
|
||||
ControlP5 configP5;
|
||||
String obName;
|
||||
String obBaud;
|
||||
List serialListOB;
|
||||
List baudListOB;
|
||||
int drawConfig;
|
||||
int[] fingerChans;
|
||||
|
||||
boolean wasConnected;
|
||||
|
||||
|
||||
W_openBionics(PApplet _parent){
|
||||
super(_parent); //calls the parent CONSTRUCTOR method of Widget (DON'T REMOVE)
|
||||
|
||||
//This is the protocol for setting up dropdowns.
|
||||
//Note that these 3 dropdowns correspond to the 3 global functions below
|
||||
//You just need to make sure the "id" (the 1st String) has the same name as the corresponding function
|
||||
|
||||
configP5 = new ControlP5(_parent);
|
||||
wasConnected = false;
|
||||
|
||||
|
||||
parent = _parent;
|
||||
baudListOB = Arrays.asList("NONE","230400","115200","57600","38400","28800","19200","14400","9600","7200","4800","3600","2400","1800","1200","600","300");
|
||||
drawConfig = -1;
|
||||
fingerChans = new int[6];
|
||||
for(int i = 0; i<6; i++) fingerChans[i] = -1;
|
||||
|
||||
hand = loadImage("hand.png");
|
||||
thumb = loadImage("thumb_over.png");
|
||||
index = loadImage("index_over.png");
|
||||
middle = loadImage("middle_over.png");
|
||||
ring = loadImage("ring_over.png");
|
||||
little = loadImage("little_over.png");
|
||||
palm = loadImage("palm_over.png");
|
||||
|
||||
String[] serialPortsLocal = Serial.list();
|
||||
serialListOB = new ArrayList();
|
||||
serialListOB.add("NONE");
|
||||
for (int i = 0; i < serialPortsLocal.length; i++) {
|
||||
String tempPort = serialPortsLocal[(serialPortsLocal.length-1) - i]; //list backwards... because usually our port is at the bottom
|
||||
if(!tempPort.equals(openBCI_portName)) serialListOB.add(tempPort);
|
||||
}
|
||||
|
||||
configClose = new Button(int(x) + w/4,int(y) + 3*navHeight,int(w/25.3),int(w/25.3),"X",fontInfo.buttonLabel_size);
|
||||
configConfirm = new Button(int(x) + w/2 + w/7,int(y) + 12*navHeight,int(w/10.12),int(w/25.3),"OKAY",fontInfo.buttonLabel_size);
|
||||
connect = new Button(int(x) + w - (w/7), int(y) + 10*navHeight, int(w/8), int(w/25.3), "CONNECT", fontInfo.buttonLabel_size);
|
||||
|
||||
obChanList = new MenuList(configP5, "obChanList", 100, 120, f2);
|
||||
obChanList.setPosition(x+w/3 + w/12, y + h/3 + h/16);
|
||||
obChanList.addItem(makeItem("NONE"));
|
||||
obChanList.activeItem = 0;
|
||||
for(int i = 0; i < nchan; i++) obChanList.addItem(makeItem("" + (i+1)));
|
||||
|
||||
addDropdown("OpenBionicsSerialOut", "Serial Output", serialListOB, 0);
|
||||
addDropdown("BaudList", "Baud List", baudListOB, 0);
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(false);
|
||||
// addDropdown("Dropdown3", "Drop 3", Arrays.asList("F", "G", "H", "I"), 3);
|
||||
|
||||
}
|
||||
void process(){
|
||||
int output_normalized;
|
||||
StringBuilder researchCommand = new StringBuilder();
|
||||
|
||||
if(OpenBionicsHand != null ){
|
||||
if(!researchMode){
|
||||
OpenBionicsHand.write("A10\n");
|
||||
researchMode = true;
|
||||
}
|
||||
byte inByte = byte(OpenBionicsHand.read());
|
||||
|
||||
println(inByte);
|
||||
}
|
||||
|
||||
if(fingerChans[5] == -1){
|
||||
|
||||
if(OpenBionicsHand != null){
|
||||
|
||||
|
||||
for(int i = 0; i<5; i++){
|
||||
//================= OpenBionics Analog Movement =======================
|
||||
if(fingerChans[i] == -1) output_normalized = 0;
|
||||
else output_normalized = int(map(w_emg.motorWidgets[fingerChans[i]].output_normalized, 0, 1, 0, 1023));
|
||||
|
||||
if(i == 4) researchCommand.append(output_normalized + "\n");
|
||||
else researchCommand.append(output_normalized + ",");
|
||||
|
||||
}
|
||||
OpenBionicsHand.write(researchCommand.toString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if(OpenBionicsHand != null){
|
||||
|
||||
output_normalized = int(map(w_emg.motorWidgets[fingerChans[5]].output_normalized, 0, 1, 0, 100));
|
||||
OpenBionicsHand.write("G0P" + output_normalized + "\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void update(){
|
||||
super.update(); //calls the parent update() method of Widget (DON'T REMOVE)
|
||||
|
||||
//put your code here...
|
||||
process();
|
||||
|
||||
}
|
||||
|
||||
void draw(){
|
||||
super.draw(); //calls the parent draw() method of Widget (DON'T REMOVE)
|
||||
|
||||
//put your code here... //remember to refer to x,y,w,h which are the positioning variables of the Widget class
|
||||
pushStyle();
|
||||
|
||||
//configP5.setVisible(true);
|
||||
|
||||
//draw FFT Graph w/ all plots
|
||||
noStroke();
|
||||
fill(255);
|
||||
rect(x, y, w, h);
|
||||
|
||||
obChanList.setPosition(x+w/3 + w/12, y + h/3 + h/16);
|
||||
|
||||
switch(drawConfig){
|
||||
case -1:
|
||||
image(hand,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
|
||||
if(overThumb()) image(thumb,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overIndex()) image(index,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overMiddle()) image(middle,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overRing()) image(ring,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overLittle()) image(little,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
else if(overPalm()) image(palm,x + w/4,y+2*navHeight + 2, w/2,h/2 + h/3 );
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(false);
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = 0;
|
||||
if(wasConnected){
|
||||
fill(0,250,0);
|
||||
ellipse(x + 5 * (w/6) ,y + 7 * (h/10),20,20);
|
||||
}
|
||||
else{
|
||||
fill(250,0,0);
|
||||
ellipse(x + 5 * (w/6),y + 7 * (h/10),20,20);
|
||||
}
|
||||
connect.draw();
|
||||
break;
|
||||
case 0:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
fill(10,10,10);
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Thumb Channel Selection", x + w/3, y + 4*navHeight);
|
||||
break;
|
||||
case 1:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
fill(10,10,10);
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Index Finger Channel Selection", x + w/3, y + 4*navHeight);
|
||||
break;
|
||||
case 2:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
fill(10,10,10);
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Middle Finger Channel Selection", x + w/3, y + 4*navHeight);
|
||||
break;
|
||||
case 3:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
fill(10,10,10);
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Ring Finger Channel Selection", x + w/3, y + 4*navHeight);
|
||||
break;
|
||||
case 4:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
fill(10,10,10);
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Little Finger Channel Selection", x + w/3, y + 4*navHeight);
|
||||
break;
|
||||
case 5:
|
||||
configP5.get(MenuList.class, "obChanList").activeItem = fingerChans[drawConfig] + 1;
|
||||
configP5.get(MenuList.class, "obChanList").setVisible(true);
|
||||
fill(180,180,180);
|
||||
rect(int(x) + w/4,int(y) + 3*navHeight, w/2, h/2 + 2*navHeight + navHeight/2);
|
||||
configClose.draw();
|
||||
configConfirm.draw();
|
||||
fill(10,10,10);
|
||||
textFont(f);
|
||||
textSize(12);
|
||||
text("Hand Channel Selection", x + w/3, y + 4*navHeight);
|
||||
break;
|
||||
}
|
||||
configP5.draw();
|
||||
|
||||
popStyle();
|
||||
|
||||
}
|
||||
|
||||
void screenResized(){
|
||||
super.screenResized(); //calls the parent screenResized() method of Widget (DON'T REMOVE)
|
||||
|
||||
//put your code here...
|
||||
configClose = new Button(int(x) + w/4,int(y) + 3*navHeight,int(w/25.3),int(w/25.3),"X",fontInfo.buttonLabel_size);
|
||||
configConfirm = new Button(int(x) + w/2 + w/7,int(y) + 12*navHeight,int(w/10.12),int(w/25.3),"OKAY",fontInfo.buttonLabel_size);
|
||||
|
||||
//update dropdown menu positions
|
||||
configP5.setGraphics(parent, 0, 0); //remaps the cp5 controller to the new PApplet window size
|
||||
int dropdownPos;
|
||||
int dropdownWidth = 60;
|
||||
dropdownPos = 1; //work down from 4 since we're starting on the right side now...
|
||||
configP5.getController("OpenBionicsSerialOut")
|
||||
.setPosition(x+w-(dropdownWidth*(dropdownPos+1))-(2*(dropdownPos+1)), navHeight+(y+2)) //float right
|
||||
;
|
||||
dropdownPos = 0;
|
||||
try{
|
||||
configP5.getController("LogLin")
|
||||
.setPosition(x+w-(dropdownWidth*(dropdownPos+1))-(2*(dropdownPos+1)), navHeight+(y+2)) //float right
|
||||
;
|
||||
}
|
||||
catch(Exception e){
|
||||
println("error resizing...");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void mousePressed(){
|
||||
super.mousePressed(); //calls the parent mousePressed() method of Widget (DON'T REMOVE)
|
||||
|
||||
//put your code here...
|
||||
if(drawConfig == -1){
|
||||
if(overThumb()) thumbPressed = true;
|
||||
else if(overIndex()) indexPressed = true;
|
||||
else if(overMiddle()) middlePressed = true;
|
||||
else if(overRing()) ringPressed = true;
|
||||
else if(overLittle()) littlePressed = true;
|
||||
else if(overPalm()) palmPressed = true;
|
||||
else if(connect.isMouseHere()) connect.wasPressed = true;
|
||||
}
|
||||
else{
|
||||
if(configClose.isMouseHere()) configClose.wasPressed= true;
|
||||
else if(configConfirm.isMouseHere()) configConfirm.wasPressed= true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void mouseReleased(){
|
||||
super.mouseReleased(); //calls the parent mouseReleased() method of Widget (DON'T REMOVE)
|
||||
if(drawConfig == -1){
|
||||
if (overThumb() && thumbPressed){drawConfig = 0;}
|
||||
else if (overIndex() && indexPressed){drawConfig= 1;}
|
||||
else if (overMiddle() && middlePressed){drawConfig = 2;}
|
||||
else if (overRing() && ringPressed){drawConfig = 3;}
|
||||
else if (overLittle() && littlePressed){drawConfig = 4;}
|
||||
else if (overPalm() && palmPressed){drawConfig = 5;}
|
||||
else if(connect.isMouseHere() && connect.wasPressed){
|
||||
|
||||
//Connect to OpenBionics Hand
|
||||
try{
|
||||
|
||||
OpenBionicsHand = new Serial(parent,obName,Integer.parseInt(obBaud));
|
||||
verbosePrint("Connected to OpenBionics Hand");
|
||||
wasConnected = true;
|
||||
}
|
||||
catch(Exception e){
|
||||
wasConnected = false;
|
||||
println(e);
|
||||
verbosePrint("Could not connect to OpenBionics Hand");
|
||||
}
|
||||
}
|
||||
|
||||
thumbPressed = false;
|
||||
indexPressed = false;
|
||||
middlePressed = false;
|
||||
ringPressed = false;
|
||||
littlePressed = false;
|
||||
palmPressed = false;
|
||||
cursor(ARROW);
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
if(configClose.isMouseHere() && configClose.wasPressed) {
|
||||
configClose.wasPressed= false;
|
||||
drawConfig = -1;
|
||||
}
|
||||
else if(configConfirm.isMouseHere() && configConfirm.wasPressed){
|
||||
configConfirm.wasPressed= false;
|
||||
drawConfig = -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean overThumb(){
|
||||
if(mouseX >= x + w/3.9 && mouseX <=x + w/2.5 && mouseY >= y + h/1.8 && mouseY <= y + h/1.32){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overIndex(){
|
||||
if(mouseX >= x + w/2.65 && mouseX <=x + w/2.07 && mouseY >= y + h/4.89 && mouseY <= y + h/1.99){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overMiddle(){
|
||||
if(mouseX >= x + w/2.01 && mouseX <=x + w/1.79 && mouseY >= y + h/7.08 && mouseY <= y + h/2.14){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overRing(){
|
||||
if(mouseX >= x + w/1.73 && mouseX <=x + w/1.5 && mouseY >= y + h/5.59 && mouseY <= y + h/1.95){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overLittle(){
|
||||
if(mouseX >= x + w/1.54 && mouseX <=x + w/1.34 && mouseY >= y + h/3.13 && mouseY <= y + h/1.78){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boolean overPalm(){
|
||||
if(mouseX >= x + w/2.47 && mouseX <=x + w/1.48 && mouseY >= y + h/1.89 && mouseY <= y + h/1.05){
|
||||
cursor(HAND);
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
cursor(ARROW);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//add custom classes functions here
|
||||
void customFunction(){
|
||||
//this is a fake function... replace it with something relevant to this widget
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//These functions need to be global! These functions are activated when an item from the corresponding dropdown is selected
|
||||
void OpenBionicsSerialOut(int n){
|
||||
|
||||
if(!w_openbionics.serialListOB.get(n).equals("NONE")) w_openbionics.obName = (String)w_openbionics.serialListOB.get(n);
|
||||
|
||||
closeAllDropdowns(); // do this at the end of all widget-activated functions to ensure proper widget interactivity ... we want to make sure a click makes the menu close
|
||||
}
|
||||
|
||||
void BaudList(int n){
|
||||
if(!w_openbionics.baudListOB.get(n).equals("NONE")) w_openbionics.obBaud = (String)w_openbionics.baudListOB.get(n);
|
||||
closeAllDropdowns();
|
||||
}
|
||||
|
||||
void obChanList(int n){
|
||||
w_openbionics.fingerChans[w_openbionics.drawConfig] = n - 1;
|
||||
closeAllDropdowns();
|
||||
}
|
||||
@@ -472,7 +472,7 @@ class ChannelBar{
|
||||
if (is_railed[channelNumber-1].is_railed == true) {
|
||||
voltageValue.string = "RAILED";
|
||||
} else if (is_railed[channelNumber-1].is_railed_warn == true) {
|
||||
voltageValue.string = "NEAR RAILED";
|
||||
voltageValue.string = "NEAR RAILED - " + String.format(getFmt(val),val) + " uVrms";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,7 +626,7 @@ class ChannelBar{
|
||||
onOffButton.but_dx = onOff_diameter;
|
||||
onOffButton.but_dy = onOff_diameter;
|
||||
} else{
|
||||
println("h = " + h);
|
||||
// println("h = " + h);
|
||||
onOff_diameter = h - 2;
|
||||
onOffButton.but_dx = onOff_diameter;
|
||||
onOffButton.but_dy = onOff_diameter;
|
||||
|
||||
@@ -93,7 +93,7 @@ class W_ganglionImpedance extends Widget {
|
||||
popStyle();
|
||||
}
|
||||
|
||||
if(isGanglion && eegDataSource == DATASOURCE_GANGLION){
|
||||
if(isHubInitialized && isGanglionObjectInitialized && eegDataSource == DATASOURCE_GANGLION){
|
||||
if(ganglion.isCheckingImpedance()){
|
||||
image(loadingGIF_blue, x + padding + startStopCheck.but_dx + 15, y + padding - 8, 40, 40);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class W_ganglionImpedance extends Widget {
|
||||
|
||||
//put your code here...
|
||||
if(startStopCheck.isActive && startStopCheck.isMouseHere()){
|
||||
if(isGanglion && eegDataSource == DATASOURCE_GANGLION){
|
||||
if(isHubInitialized && isGanglionObjectInitialized && eegDataSource == DATASOURCE_GANGLION){
|
||||
if(ganglion.isCheckingImpedance()){
|
||||
ganglion.impedanceStop();
|
||||
startStopCheck.but_txt = "Start Impedance Check";
|
||||
|
||||
@@ -19,8 +19,8 @@ W_accelerometer w_accelerometer;
|
||||
W_networking w_networking;
|
||||
W_ganglionImpedance w_ganglionImpedance;
|
||||
W_template w_template1;
|
||||
W_template w_template2;
|
||||
W_template w_template3;
|
||||
W_emg w_emg;
|
||||
W_openBionics w_openbionics;
|
||||
|
||||
//ADD YOUR WIDGET TO WIDGETS OF WIDGETMANAGER
|
||||
void setupWidgets(PApplet _this, ArrayList<Widget> w){
|
||||
@@ -46,18 +46,26 @@ void setupWidgets(PApplet _this, ArrayList<Widget> w){
|
||||
w_accelerometer = new W_accelerometer(_this);
|
||||
w_accelerometer.setTitle("Accelerometer");
|
||||
addWidget(w_accelerometer, w);
|
||||
//
|
||||
// w_networking = new W_networking(_this);
|
||||
// w_networking.setTitle("Networking");
|
||||
// addWidget(w_networking, w);
|
||||
|
||||
w_networking = new W_networking(_this);
|
||||
w_networking.setTitle("Networking");
|
||||
addWidget(w_networking, w);
|
||||
|
||||
w_emg = new W_emg(_this);
|
||||
w_emg.setTitle("EMG");
|
||||
addWidget(w_emg, w);
|
||||
|
||||
w_template1 = new W_template(_this);
|
||||
w_template1.setTitle("Widget Template 1");
|
||||
addWidget(w_template1, w);
|
||||
|
||||
w_template2 = new W_template(_this);
|
||||
w_template2.setTitle("Widget Template 2");
|
||||
addWidget(w_template2, w);
|
||||
// w_template2 = new W_template(_this);
|
||||
// w_template2.setTitle("Widget Template 2");
|
||||
// addWidget(w_template2, w);
|
||||
|
||||
// w_openbionics = new W_OpenBionics(_this);
|
||||
// w_openbionics.setTitle("OpenBionics");
|
||||
// addWidget(w_openbionics,w);
|
||||
|
||||
// w_template3 = new W_template(_this);
|
||||
// w_template3.setTitle("LSL Stream");
|
||||
@@ -146,7 +154,8 @@ class WidgetManager{
|
||||
}
|
||||
|
||||
void update(){
|
||||
if(visible && updating){
|
||||
// if(visible && updating){
|
||||
if(visible){
|
||||
for(int i = 0; i < widgets.size(); i++){
|
||||
if(widgets.get(i).isActive){
|
||||
widgets.get(i).update();
|
||||
@@ -169,6 +178,14 @@ class WidgetManager{
|
||||
widgets.get(i).draw();
|
||||
widgets.get(i).drawDropdowns();
|
||||
popStyle();
|
||||
}else{
|
||||
if(widgets.get(i).widgetTitle.equals("Networking")){
|
||||
try{
|
||||
w_networking.shutDown();
|
||||
}catch (NullPointerException e){
|
||||
println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,4 @@ Project Management Plan:
|
||||
[](http://waffle.io/OpenBCI/OpenBCI_GUI_v2.0)
|
||||
|
||||
# OpenBCI_GUI_v2.0
|
||||
Based on OpenBCI_Processing, OpenBCI_GUI_v2.0 extends the GUI to include additional features, and will soon be usable with the Ganglion board.
|
||||
|
||||
## Developing
|
||||
|
||||
Drag and drop all folders in the libraries folder into your processing libraries folder.
|
||||
Based on OpenBCI_Processing, OpenBCI_GUI_v2.0 extends the GUI to include additional features, and interfaces with the OpenBCI [Cyton](http://shop.openbci.com/collections/frontpage/products/openbci-32-bit-board-kit?variant=784651699) and [Ganglion](http://shop.openbci.com/collections/frontpage/products/pre-order-ganglion-board?variant=13461804483) hardware systems. Tutorials, and getting started guides can be found on the [OpenBCI Learning Pages](http://docs.openbci.com/Getting%20Started/00-Welcome). For a guide on how to run this code in the Processing IDE, go [here](http://docs.openbci.com/OpenBCI%20Software/01-OpenBCI_GUI)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package controlP5;
|
||||
package controlP5;
|
||||
|
||||
/**
|
||||
* controlP5 is a processing gui library.
|
||||
*
|
||||
*
|
||||
* 2006-2015 by Andreas Schlegel
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
@@ -13,16 +13,16 @@ package controlP5;
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* @author Andreas Schlegel (http://www.sojamo.de)
|
||||
* @modified 04/14/2016
|
||||
* @version 2.2.6
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,7 +35,7 @@ import processing.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* ControllerGroup is an abstract class and is extended by class ControlGroup, Tab, or the ListBox.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class ControllerGroup< T > implements ControllerInterface< T > , ControlP5Constants , ControlListener {
|
||||
|
||||
@@ -924,7 +924,7 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > ,
|
||||
|
||||
/**
|
||||
* convenience method to fill a float array in favor of theArray[0] = 1.2; etc.
|
||||
* takes a float array and fills it (starting from index 0) with arguments starting from index 1.
|
||||
* takes a float array and fills it (starting from index 0) with arguments starting from index 1.
|
||||
*/
|
||||
static public float[] set( float[] theArray , float ... theValues ) {
|
||||
if ( theValues.length > theArray.length ) {
|
||||
|
||||
@@ -2,9 +2,9 @@ package controlP5;
|
||||
|
||||
/**
|
||||
* controlP5 is a processing gui library.
|
||||
*
|
||||
*
|
||||
* 2006-2015 by Andreas Schlegel
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation; either version 2.1
|
||||
@@ -13,16 +13,16 @@ package controlP5;
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General
|
||||
* Public License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* @author Andreas Schlegel (http://www.sojamo.de)
|
||||
* @modified 04/14/2016
|
||||
* @version 2.2.6
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -36,13 +36,13 @@ import processing.core.PImage;
|
||||
* A radioButton is a list of toggles that can be turned on or off. radioButton is of type
|
||||
* ControllerGroup, therefore a controllerPlug can't be set. this means that an event from a
|
||||
* radioButton can't be forwarded to a method other than controlEvent in a sketch.
|
||||
*
|
||||
*
|
||||
* a radioButton has 2 sets of values. radioButton.getValue() returns the value of the active
|
||||
* radioButton item. radioButton.getArrayValue() returns a float array that represents the active
|
||||
* (1) and inactive (0) items of a radioButton.
|
||||
*
|
||||
*
|
||||
* ControlP5 CheckBox Toggle
|
||||
*
|
||||
*
|
||||
* @example controllers/ControlP5radioButton
|
||||
*
|
||||
* @nosuperclasses Controller Controller
|
||||
@@ -68,7 +68,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* Convenience constructor to extend RadioButton.
|
||||
*
|
||||
*
|
||||
* @example use/ControlP5extendController
|
||||
* @param theControlP5
|
||||
* @param theName
|
||||
@@ -189,7 +189,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param theDefaultImage
|
||||
* @param theOverImage
|
||||
* @param theActiveImage
|
||||
@@ -241,7 +241,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
* set the height of a radioButton/checkBox item. by default the height is 11px. in order to
|
||||
* recognize a custom height, the itemHeight has to be set before adding items to a
|
||||
* radioButton/checkBox.
|
||||
*
|
||||
*
|
||||
* @param theItemHeight
|
||||
*/
|
||||
public RadioButton setItemHeight( int theItemHeight ) {
|
||||
@@ -257,7 +257,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
* set the width of a radioButton/checkBox item. by default the width is 11px. in order to
|
||||
* recognize a custom width, the itemWidth has to be set before adding items to a
|
||||
* radioButton/checkBox.
|
||||
*
|
||||
*
|
||||
* @param theItemWidth
|
||||
*/
|
||||
public RadioButton setItemWidth( int theItemWidth ) {
|
||||
@@ -271,7 +271,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* Gets a radio button item by index.
|
||||
*
|
||||
*
|
||||
* @param theIndex
|
||||
* @return Toggle
|
||||
*/
|
||||
@@ -294,7 +294,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* Gets the state of an item - this can be true (for on) or false (for off) - by index.
|
||||
*
|
||||
*
|
||||
* @param theIndex
|
||||
* @return boolean
|
||||
*/
|
||||
@@ -307,7 +307,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* Gets the state of an item - this can be true (for on) or false (for off) - by name.
|
||||
*
|
||||
*
|
||||
* @param theName
|
||||
* @return
|
||||
*/
|
||||
@@ -350,7 +350,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
/**
|
||||
* Items of a radioButton or a checkBox are organized in columns and rows. SetItemsPerRow sets
|
||||
* the limit of items per row. items exceeding the limit will be pushed to the next row.
|
||||
*
|
||||
*
|
||||
* @param theValue
|
||||
*/
|
||||
public RadioButton setItemsPerRow( final int theValue ) {
|
||||
@@ -361,7 +361,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* Sets the spacing in pixels between columns.
|
||||
*
|
||||
*
|
||||
* @param theSpacing
|
||||
*/
|
||||
public RadioButton setSpacingColumn( final int theSpacing ) {
|
||||
@@ -372,7 +372,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* Sets the spacing in pixels between rows.
|
||||
*
|
||||
*
|
||||
* @param theSpacing
|
||||
*/
|
||||
public RadioButton setSpacingRow( final int theSpacing ) {
|
||||
@@ -398,7 +398,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
* Deactivates all active RadioButton items and only activates the item corresponding to
|
||||
* theIndex.
|
||||
* TODO does not trigger function or value when called by code, fix!
|
||||
*
|
||||
*
|
||||
* @param theIndex
|
||||
*/
|
||||
public RadioButton activate( int theIndex ) {
|
||||
@@ -434,7 +434,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* Actives an item of the Radio button by name.
|
||||
*
|
||||
*
|
||||
* @param theName
|
||||
*/
|
||||
public RadioButton activate( String theName ) {
|
||||
@@ -452,7 +452,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
/**
|
||||
* Deactivates a RadioButton by name and sets the value of the RadioButton to the default value
|
||||
* -1.
|
||||
*
|
||||
*
|
||||
* @param theName
|
||||
*/
|
||||
public RadioButton deactivate( String theName ) {
|
||||
@@ -491,7 +491,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @exclude
|
||||
*/
|
||||
@ControlP5.Invisible @Override public void controlEvent( ControlEvent theEvent ) {
|
||||
@@ -572,7 +572,7 @@ public class RadioButton extends ControlGroup< RadioButton > {
|
||||
/**
|
||||
* In order to always have 1 item selected, use setNoneSelectedAllowed(false), by default this
|
||||
* is true. setNoneSelectedAllowed does not apply when in multipleChoice mode.
|
||||
*
|
||||
*
|
||||
* @param theValue
|
||||
*/
|
||||
public RadioButton setNoneSelectedAllowed( boolean theValue ) {
|
||||
|
||||