Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ public enum BoardIds
BIOLISTENER_BOARD = 64,
IRONBCI_32_BOARD = 65,
NEUROPAWN_KNIGHT_BOARD_IMU = 66,
MUSE_S_ANTHENA_BOARD = 67
MUSE_S_ANTHENA_BOARD = 67,
SHIMMER3_BOARD = 68
};


Expand Down
3 changes: 2 additions & 1 deletion java_package/brainflow/src/main/java/brainflow/BoardIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public enum BoardIds
BIOLISTENER_BOARD(64),
IRONBCI_32_BOARD(65),
NEUROPAWN_KNIGHT_BOARD_IMU(66),
MUSE_S_ANTHENA_BOARD(67);
MUSE_S_ANTHENA_BOARD(67),
SHIMMER3_BOARD(68);

private final int board_id;
private static final Map<Integer, BoardIds> bi_map = new HashMap<Integer, BoardIds> ();
Expand Down
1 change: 1 addition & 0 deletions julia_package/brainflow/src/board_shim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export BrainFlowInputParams
IRONBCI_32_BOARD = 65
NEUROPAWN_KNIGHT_BOARD_IMU = 66
MUSE_S_ANTHENA_BOARD = 67
SHIMMER3_BOARD = 68

end

Expand Down
1 change: 1 addition & 0 deletions matlab_package/brainflow/BoardIds.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@
IRONBCI_32_BOARD(65)
NEUROPAWN_KNIGHT_BOARD_IMU(66)
MUSE_S_ANTHENA_BOARD(67)
SHIMMER3_BOARD(68)
end
end
3 changes: 2 additions & 1 deletion nodejs_package/brainflow/brainflow.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export enum BoardIds {
BIOLISTENER_BOARD = 64,
IRONBCI_32_BOARD = 65,
NEUROPAWN_KNIGHT_BOARD_IMU = 66,
MUSE_S_ANTHENA_BOARD = 67
MUSE_S_ANTHENA_BOARD = 67,
SHIMMER3_BOARD = 68
}

export enum IpProtocolTypes {
Expand Down
1 change: 1 addition & 0 deletions python_package/brainflow/board_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class BoardIds(enum.IntEnum):
IRONBCI_32_BOARD = 65 #:
NEUROPAWN_KNIGHT_BOARD_IMU = 66 #:
MUSE_S_ANTHENA_BOARD = 67 #:
SHIMMER3_BOARD = 68 #:


class IpProtocolTypes(enum.IntEnum):
Expand Down
1 change: 1 addition & 0 deletions rust_package/brainflow/src/ffi/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub enum BoardIds {
Ironbci32Board = 65,
NeuropawnKnightBoardImu = 66,
MuseSAnthenaBoard = 67,
Shimmer3Board = 68,
}
#[repr(i32)]
#[derive(FromPrimitive, ToPrimitive, Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down
4 changes: 4 additions & 0 deletions src/board_controller/board_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "ntl_wifi.h"
#include "pieeg_board.h"
#include "playback_file_board.h"
#include "shimmer3.h"
#include "streaming_board.h"
#include "synchroni_board.h"
#include "synthetic_board.h"
Expand Down Expand Up @@ -310,6 +311,9 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
board = std::shared_ptr<Board> (
new KnightIMU ((int)BoardIds::NEUROPAWN_KNIGHT_BOARD_IMU, params));
break;
case BoardIds::SHIMMER3_BOARD:
board = std::shared_ptr<Board> (new Shimmer3 (params));
break;
default:
return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR;
}
Expand Down
44 changes: 43 additions & 1 deletion src/board_controller/brainflow_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ BrainFlowBoards::BrainFlowBoards()
{"64", json::object()},
{"65", json::object()},
{"66", json::object()},
{"67", json::object()}
{"67", json::object()},
{"68", json::object()}
}
}};

Expand Down Expand Up @@ -1198,6 +1199,47 @@ BrainFlowBoards::BrainFlowBoards()
{"optical_channels", {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}},
{"battery_channel", 17}
};
// Shimmer3 (ID 68)
// Default preset: IMU data (accel, gyro, mag)
brainflow_boards_json["boards"]["68"]["default"] =
{
{"name", "Shimmer3"},
{"sampling_rate", 512},
{"package_num_channel", 0},
{"timestamp_channel", 10},
{"marker_channel", 11},
{"num_rows", 12},
{"accel_channels", {1, 2, 3}},
{"gyro_channels", {4, 5, 6}},
{"magnetometer_channels", {7, 8, 9}}
};
// Auxiliary preset: ExG data (ECG/EMG via ADS1292R chips)
brainflow_boards_json["boards"]["68"]["auxiliary"] =
{
{"name", "Shimmer3"},
{"sampling_rate", 512},
{"package_num_channel", 0},
{"timestamp_channel", 7},
{"marker_channel", 8},
{"num_rows", 9},
{"ecg_channels", {1, 2}},
{"emg_channels", {3, 4}},
{"other_channels", {5, 6}} // ExG1 status, ExG2 status
};
// Ancillary preset: GSR, temperature, battery, pressure
brainflow_boards_json["boards"]["68"]["ancillary"] =
{
{"name", "Shimmer3"},
{"sampling_rate", 64},
{"package_num_channel", 0},
{"timestamp_channel", 7},
{"marker_channel", 8},
{"num_rows", 9},
{"eda_channels", {1}},
{"temperature_channels", {2}},
{"battery_channel", 3},
{"other_channels", {4, 5, 6}} // pressure, internal ADC, external ADC
};
}

BrainFlowBoards boards_struct;
2 changes: 2 additions & 0 deletions src/board_controller/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ SET (BOARD_CONTROLLER_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuropawn/knight_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuropawn/knight_imu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/biolistener/biolistener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/shimmer3/shimmer3.cpp
)

include (${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ant_neuro/build.cmake)
Expand Down Expand Up @@ -156,6 +157,7 @@ target_include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/synchroni/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuropawn/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/biolistener/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/shimmer3/inc
)

target_compile_definitions(${BOARD_CONTROLLER_NAME} PRIVATE NOMINMAX BRAINFLOW_VERSION=${BRAINFLOW_VERSION})
Expand Down
84 changes: 84 additions & 0 deletions src/board_controller/shimmer3/inc/shimmer3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Shimmer3 board driver for BrainFlow.
*
* Adapted from the pyshimmer Python library by semoo-lab:
* https://github.com/seemoo-lab/pyshimmer
*
* Original work licensed under the GNU General Public License v3.0.
* See https://www.gnu.org/licenses/gpl-3.0.html for details.
*/

#pragma once

#include <atomic>
#include <cstdint>
#include <mutex>
#include <string>
#include <thread>
#include <vector>

#include "board.h"
#include "board_controller.h"
#include "serial.h"

#include "shimmer3_defines.h"


class Shimmer3 : public Board
{

private:
volatile bool keep_alive;
volatile bool initialized;

Serial *serial_port;
std::string port_name;

std::thread streaming_thread;
std::mutex m;

// Populated during prepare_session by querying the device
double sampling_rate;
std::vector<EChannelType> active_channels;
std::vector<ShimmerChannelDType> active_dtypes;
int packet_size;
ShimmerAllCalibration calibration;

// Serial helpers
int serial_write (const uint8_t *data, int len);
int serial_read (uint8_t *buf, int len);
int serial_read_byte (uint8_t &out);
int send_command (uint8_t cmd);
int send_command_with_args (uint8_t cmd, const uint8_t *args, int args_len);
int wait_for_ack ();
int read_response (uint8_t expected_code, uint8_t *buf, int buf_len, int &out_len);

// Device commands
int get_firmware_version (uint16_t &fw_type, uint16_t &major, uint8_t &minor, uint8_t &rel);
int get_sampling_rate (double &sr);
int set_sampling_rate (double sr);
int get_shimmer_version (uint8_t &hw_ver);
int send_inquiry (double &sr, int &buf_size, std::vector<EChannelType> &channels);
int set_sensors (uint32_t sensor_bitfield);
int start_streaming_cmd ();
int stop_streaming_cmd ();
int disable_status_ack ();
int get_all_calibration (ShimmerAllCalibration &cal);

// Packet parsing
bool lookup_channel_dtype (EChannelType ch, ShimmerChannelDType &out);
void build_active_channel_list (const std::vector<EChannelType> &inquiry_channels);
int compute_packet_size ();

void read_thread ();

public:
Shimmer3 (struct BrainFlowInputParams params);
~Shimmer3 ();

int prepare_session ();
int start_stream (int buffer_size, const char *streamer_params);
int stop_stream ();
int release_session ();
int config_board (std::string config, std::string &response);
};
Loading
Loading