Synthetic & Live Data Mode Selection for GUI5 - 3C-SCSU/Avatar GitHub Wiki
I have added a feature that lets the user choose between Synthetic Data and Live Data using radio buttons in the GUI5.py for BrainWave Reading Tab. Based on the selection, the Python backend initializes the correct EEG board using the BrainFlow library.
Step 1: Added Radio Buttons in QML (UI)
Created two radio buttons:
RadioButton {
id: syntheticRadio
text: "Synthetic Data"
onClicked: {
backend.setDataMode("synthetic")
}
}
RadioButton {
id: liveRadio
text: "Live Data"
checked: true
onClicked: {
backend.setDataMode("live")
}
}
Step 2: Wrote Backend Logic in Python
In the Python file, I added a slot that receives the selected mode:
@Slot(str)
def setDataMode(self, mode):
if mode == "synthetic":
self.init_synthetic_board()
elif mode == "live":
self.init_live_board()
If the mode is synthetic, it starts a synthetic board for testing. If the mode is live, it connects to the real EEG board.
Step 3: Setup Synthetic & Live Boards
def init_synthetic_board(self):
self.board = BoardShim(BoardIds.SYNTHETIC_BOARD.value, BrainFlowInputParams())
def init_live_board(self):
params = BrainFlowInputParams()
params.serial_port = "/dev/cu.usbserial-D200PMA1"
self.board = BoardShim(BoardIds.CYTON_DAISY_BOARD.value, params)
init_synthetic_board() is for testing without hardware. init_live_board() is for connecting to the real OpenBCI Cyton-Daisy board.
Demo :