Skip to content

Commit 53093d0

Browse files
Add muse2016 (native and BLED) support (brainflow-dev#405)
* add muse2016 native and BLED Signed-off-by: eeg_lab <eeg_lab@20X3-PF2S2YVN.camh.ca>
1 parent 84b8b16 commit 53093d0

10 files changed

Lines changed: 82 additions & 14 deletions

File tree

‎csharp-package/brainflow/brainflow/board_controller_library.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ public enum BoardIds
8585
ANT_NEURO_EE_225_BOARD = 36,
8686
ENOPHONE_BOARD = 37,
8787
MUSE_2_BOARD = 38,
88-
MUSE_S_BOARD = 39
88+
MUSE_S_BOARD = 39,
89+
BRAINALIVE_BOARD = 40,
90+
MUSE_2016_BOARD = 41,
91+
MUSE_2016_BLED_BOARD = 42
8992
};
9093

9194

‎docs/SupportedBoards.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,10 @@ Muse
552552

553553
"MuseSBLED", "BoardIds.MUSE_S_BLED_BOARD (21)", "dongle serial port", "-", "-", "-", "-", "-", "-", "Optional: device name", "-"
554554
"Muse2BLED", "BoardIds.MUSE_2_BLED_BOARD (22)", "dongle serial port", "-", "-", "-", "-", "-", "-", "Optional: device name", "-"
555+
"Muse2016BLED", "BoardIds.MUSE_2016_BLED_BOARD (42)", "dongle serial port", "-", "-", "-", "-", "-", "-", "Optional: device name", "-"
555556
"Muse2", "BoardIds.MUSE_2_BOARD (38)", "-", "Optional: MAC adress", "-", "-", "-", "-", "-", "Optional: device name", "-"
556557
"MuseS", "BoardIds.MUSE_S_BOARD (39)", "-", "Optional: MAC adress", "-", "-", "-", "-", "-", "Optional: device name", "-"
558+
"Muse2016", "BoardIds.MUSE_2016_BOARD (41)", "-", "Optional: MAC adress", "-", "-", "-", "-", "-", "Optional: device name", "-"
557559

558560
Muse S BLED
559561
~~~~~~~~~~~~~~

‎java-package/brainflow/src/main/java/brainflow/BoardIds.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public enum BoardIds
4949
ANT_NEURO_EE_225_BOARD (36),
5050
ENOPHONE_BOARD (37),
5151
MUSE_2_BOARD (38),
52-
MUSE_S_BOARD (39);
52+
MUSE_S_BOARD (39),
53+
BRAINALIVE_BOARD (40),
54+
MUSE_2016_BOARD (41),
55+
MUSE_2016_BLED_BOARD (42);
5356

5457
private final int board_id;
5558
private static final Map<Integer, BoardIds> bi_map = new HashMap<Integer, BoardIds> ();

‎julia-package/brainflow/src/board_shim.jl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export BrainFlowInputParams
4545
ENOPHONE_BOARD = 37
4646
MUSE_2_BOARD = 38
4747
MUSE_S_BOARD = 39
48+
BRAINALIVE_BOARD = 40
49+
MUSE_2016_BOARD = 41
50+
MUSE_2016_BLED_BOARD = 42
4851

4952
end
5053

‎matlab-package/brainflow/BoardIDs.m‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,8 @@
4343
ENOPHONE_BOARD(37)
4444
MUSE_2_BOARD(38)
4545
MUSE_S_BOARD(39)
46+
BRAINALIVE_BOARD (40)
47+
MUSE_2016_BOARD (41)
48+
MUSE_2016_BLED_BOARD (42)
4649
end
4750
end

‎python-package/brainflow/board_shim.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class BoardIds(enum.IntEnum):
6060
MUSE_2_BOARD = 38 #:
6161
MUSE_S_BOARD = 39 #:
6262
BRAINALIVE_BOARD = 40 #:
63+
MUSE_2016_BOARD = 41 #:
64+
MUSE_2016_BLED_BOARD = 42 #:
6365

6466

6567
class LogLevels(enum.IntEnum):

‎src/board_controller/board_controller.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
229229
case BoardIds::BRAINALIVE_BOARD:
230230
board = std::shared_ptr<Board> (new BrainAlive (params));
231231
break;
232+
case BoardIds::MUSE_2016_BOARD:
233+
board = std::shared_ptr<Board> (new Muse (board_id, params));
234+
break;
235+
case BoardIds::MUSE_2016_BLED_BOARD:
236+
board = std::shared_ptr<Board> (new MuseBLED (board_id, params));
237+
break;
232238
default:
233239
return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR;
234240
}

‎src/board_controller/brainflow_boards.cpp‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,31 @@ json brainflow_boards_json = {
531531
{"eeg_names", "F7,FT7,T7,CP5,CZ,C6,FC6,F4"},
532532
{"accel_channels", {9, 10, 11}},
533533
{"ppg_channels", {12, 13, 14}}
534-
}}
534+
}},
535+
{"41",
536+
{{"name", "Muse2016"},
537+
{"sampling_rate", 256},
538+
{"timestamp_channel", 11},
539+
{"marker_channel", 12},
540+
{"package_num_channel", 0},
541+
{"num_rows", 13},
542+
{"eeg_channels", {1, 2, 3, 4}},
543+
{"eeg_names", "TP9,Fp1,Fp2,TP10"},
544+
{"accel_channels", {5, 6, 7}},
545+
{"gyro_channels", {8, 9, 10}}
546+
}},
547+
{"42",
548+
{{"name", "Muse2016BLED"},
549+
{"sampling_rate", 256},
550+
{"timestamp_channel", 11},
551+
{"marker_channel", 12},
552+
{"package_num_channel", 0},
553+
{"num_rows", 13},
554+
{"eeg_channels", {1, 2, 3, 4}},
555+
{"eeg_names", "TP9,Fp1,Fp2,TP10"},
556+
{"accel_channels", {5, 6, 7}},
557+
{"gyro_channels", {8, 9, 10}}
558+
}}
535559
}
536560
}};
537561
// clang-format on

‎src/board_controller/muse/muse_bglib/muse_bglib_helper.cpp‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,19 @@ void MuseBGLibHelper::ble_evt_attclient_procedure_completed (
282282
void MuseBGLibHelper::ble_evt_attclient_find_information_found (
283283
const struct ble_msg_attclient_find_information_found_evt_t *msg)
284284
{
285+
size_t chars_to_find = 9;
286+
size_t ccids_to_find = 13;
287+
try
288+
{
289+
std::vector<int> ppg_channels = board_descr["ppg_channels"];
290+
}
291+
catch (...)
292+
{
293+
// no ppg for old muse
294+
chars_to_find = 6;
295+
ccids_to_find = 10;
296+
}
297+
285298
if (state == (int)DeviceState::OPEN_CALLED)
286299
{
287300
if (msg->uuid.len == 2)
@@ -344,8 +357,8 @@ void MuseBGLibHelper::ble_evt_attclient_find_information_found (
344357
characteristics[msg->chrhandle] = uuid;
345358
}
346359
}
347-
if ((characteristics.size () == 9) && (state == (int)DeviceState::OPEN_CALLED) &&
348-
(ccids.size () >= 13))
360+
if ((characteristics.size () == chars_to_find) &&
361+
(state == (int)DeviceState::OPEN_CALLED) && (ccids.size () >= ccids_to_find))
349362
{
350363
exit_code = (int)BrainFlowExitCodes::STATUS_OK;
351364
}
@@ -429,18 +442,25 @@ void MuseBGLibHelper::ble_evt_attclient_attribute_value (
429442
ppg_chann_num = 2;
430443
}
431444

432-
std::vector<int> ppg_channels = board_descr["ppg_channels"];
433-
for (int i = 0; i < 6; i++)
445+
try
434446
{
435-
double ppg_val =
436-
(double)cast_24bit_to_int32 ((unsigned char *)&msg->value.data[2 + i * 3]);
437-
for (int j = 0; j < 2; j++)
447+
std::vector<int> ppg_channels = board_descr["ppg_channels"];
448+
for (int i = 0; i < 6; i++)
438449
{
439-
int pos = (current_ppg_pos[ppg_chann_num] + i * 2 + j) % 12;
440-
current_buf[pos][ppg_channels[ppg_chann_num]] = ppg_val;
450+
double ppg_val =
451+
(double)cast_24bit_to_int32 ((unsigned char *)&msg->value.data[2 + i * 3]);
452+
for (int j = 0; j < 2; j++)
453+
{
454+
int pos = (current_ppg_pos[ppg_chann_num] + i * 2 + j) % 12;
455+
current_buf[pos][ppg_channels[ppg_chann_num]] = ppg_val;
456+
}
441457
}
458+
current_ppg_pos[ppg_chann_num] += 2;
459+
}
460+
catch (...)
461+
{
462+
// do nothing
442463
}
443-
current_ppg_pos[ppg_chann_num] += 2;
444464
}
445465
else
446466
{

‎src/utils/inc/brainflow_constants.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ enum class BoardIds : int
7474
MUSE_2_BOARD = 38,
7575
MUSE_S_BOARD = 39,
7676
BRAINALIVE_BOARD = 40,
77+
MUSE_2016_BOARD = 41,
78+
MUSE_2016_BLED_BOARD = 42,
7779
// use it to iterate
7880
FIRST = PLAYBACK_FILE_BOARD,
79-
LAST = BRAINALIVE_BOARD
81+
LAST = MUSE_2016_BLED_BOARD
8082
};
8183

8284
enum class IpProtocolType : int

0 commit comments

Comments
 (0)