diff --git a/OpenBCI_GUI/BoardGanglion.pde b/OpenBCI_GUI/BoardGanglion.pde index 27a63aeec..55b55d4be 100644 --- a/OpenBCI_GUI/BoardGanglion.pde +++ b/OpenBCI_GUI/BoardGanglion.pde @@ -24,6 +24,24 @@ class BoardGanglionNative extends BoardGanglion { } } } + + //Temporary fix for Ganglion firmware on Mac + public BoardGanglionNative(String name, boolean showUpgradePopup, boolean usingV3Firmware) { + super(); + this.boardName = name; + + if (usingV3Firmware) { + this.firmwareVersion = 3; + output("Detected Ganglion firmware version 3"); + } + else { + this.firmwareVersion = 2; + output("Detected Ganglion firmware version 2"); + if (showUpgradePopup) { + PopupMessage msg = new PopupMessage("Warning", "Ganglion firmware version 2 detected. Please update to version 3 for better performance. \n\nhttps://docs.openbci.com/Ganglion/GanglionProgram"); + } + } + } @Override protected BrainFlowInputParams getParams() { @@ -89,6 +107,25 @@ class BoardGanglionBLE extends BoardGanglion { } } + //Temporary fix for Ganglion firmware on Mac + public BoardGanglionBLE(String deviceName, String serialPort, String macAddress, boolean showUpgradePopup, boolean usingV3Firmware) { + super(); + this.serialPort = serialPort; + this.macAddress = macAddress; + + if (usingV3Firmware) { + this.firmwareVersion = 3; + output("Detected Ganglion firmware version 3"); + } + else { + this.firmwareVersion = 2; + if (showUpgradePopup) { + PopupMessage msg = new PopupMessage("Warning", "Ganglion firmware version 2 detected. Please update to version 3 for better performance. \n\nhttps://docs.openbci.com/Ganglion/GanglionProgram"); + } + output("Detected Ganglion firmware version 2"); + } + } + @Override public BoardIds getBoardId() { return BoardIds.GANGLION_BOARD; diff --git a/OpenBCI_GUI/ControlPanel.pde b/OpenBCI_GUI/ControlPanel.pde index 840934113..0dd95c2a2 100644 --- a/OpenBCI_GUI/ControlPanel.pde +++ b/OpenBCI_GUI/ControlPanel.pde @@ -676,6 +676,10 @@ class BLEBox { private MenuList bleList; private Button refreshBLE; Map bleMACAddrMap = new HashMap(); + private final int BUTTON_HEIGHT = 24; + + private Button v2FirmwareButton; + private Button v3FirmwareButton; BLEBox(int _x, int _y, int _w, int _h, int _padding) { x = _x; @@ -691,6 +695,17 @@ class BLEBox { createRefreshBLEButton("refreshGanglionBLEButton", "START SEARCH", x + padding, y + padding*4 + 72 + 8, w - padding*5, 24); createGanglionBLEMenuList(bleBox_cp5, "bleList", x + padding, y + padding*3 + 8, w - padding*2, 72, p3); + + //Temporary fix for Mac OS X and Ganglion BLE + if (isMac()) { + h = 140 + _padding * 2 + BUTTON_HEIGHT; + int buttonWidth = (w-padding*3)/2; + int buttonY = y + h - padding - BUTTON_HEIGHT; + createV2FirmwareButton("v2FirmwareButton", "V2 FIRMWARE", x + padding, buttonY, buttonWidth, BUTTON_HEIGHT); + createV3FirmwareButton("v3FirmwareButton", "V3 FIRMWARE", x + padding + buttonWidth + padding, buttonY, buttonWidth, BUTTON_HEIGHT); + } + + } public void update() { @@ -835,6 +850,41 @@ class BLEBox { } }); } + + //Temporary fix for Ganglion firmware on Mac + private void createV2FirmwareButton(String name, String text, int _x, int _y, int _w, int _h) { + v2FirmwareButton = createButton(bleBox_cp5, name, text, _x, _y, _w, _h); + v2FirmwareButton.setSwitch(true); + if (usingGanglionV3andMacOS) { + v2FirmwareButton.setOff(); + } else { + v2FirmwareButton.setOn(); + } + v2FirmwareButton.setOn(); + v2FirmwareButton.onRelease(new CallbackListener() { + public void controlEvent(CallbackEvent theEvent) { + v3FirmwareButton.setOff(); + usingGanglionV3andMacOS = false; + } + }); + } + + //Temporary fix for Ganglion firmware on Mac + private void createV3FirmwareButton(String name, String text, int _x, int _y, int _w, int _h) { + v3FirmwareButton = createButton(bleBox_cp5, name, text, _x, _y, _w, _h); + v3FirmwareButton.setSwitch(true); + if (usingGanglionV3andMacOS) { + v3FirmwareButton.setOn(); + } else { + v3FirmwareButton.setOff(); + } + v3FirmwareButton.onRelease(new CallbackListener() { + public void controlEvent(CallbackEvent theEvent) { + v2FirmwareButton.setOff(); + usingGanglionV3andMacOS = true; + } + }); + } }; class WifiBox { diff --git a/OpenBCI_GUI/OpenBCI_GUI.pde b/OpenBCI_GUI/OpenBCI_GUI.pde index 54f8de9f5..34f8fe5cb 100644 --- a/OpenBCI_GUI/OpenBCI_GUI.pde +++ b/OpenBCI_GUI/OpenBCI_GUI.pde @@ -312,6 +312,8 @@ boolean isFFTFiltered = true; //yes by default ... this is used in dataProcessin StringBuilder globalScreenResolution; StringBuilder globalScreenDPI; +boolean usingGanglionV3andMacOS = false; + //------------------------------------------------------------------------ // Global Functions //------------------------------------------------------------------------ @@ -621,12 +623,20 @@ void initSystem() { String ganglionPort = (String)(controlPanel.bleBox.bleList.getItem(controlPanel.bleBox.bleList.activeItem).get("subline")); String ganglionMac = controlPanel.bleBox.bleMACAddrMap.get(ganglionName); println("MAC address for Ganglion is " + ganglionMac); - currentBoard = new BoardGanglionBLE(ganglionName, ganglionPort, ganglionMac, showUpgradePopup); + if (isMac()) { + currentBoard = new BoardGanglionBLE(ganglionName, ganglionPort, ganglionMac, showUpgradePopup, usingGanglionV3andMacOS); + } else { + currentBoard = new BoardGanglionBLE(ganglionName, ganglionPort, ganglionMac, showUpgradePopup); + } } else if (selectedProtocol == BoardProtocol.NATIVE_BLE) { String ganglionName = (String)(controlPanel.bleBox.bleList.getItem(controlPanel.bleBox.bleList.activeItem).get("headline")); String ganglionMac = controlPanel.bleBox.bleMACAddrMap.get(ganglionName); println("MAC address for Ganglion is " + ganglionMac); - currentBoard = new BoardGanglionNative(ganglionName, showUpgradePopup); + if (isMac()) { + currentBoard = new BoardGanglionNative(ganglionName, showUpgradePopup, usingGanglionV3andMacOS); + } else { + currentBoard = new BoardGanglionNative(ganglionName, showUpgradePopup); + } } break; case DATASOURCE_STREAMING: