Skip to content
Open
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_ATHENA_BOARD = 67
MUSE_S_ATHENA_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_ATHENA_BOARD(67);
MUSE_S_ATHENA_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_ATHENA_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_ATHENA_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_ATHENA_BOARD = 67
MUSE_S_ATHENA_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_ATHENA_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,
MuseSAthenaBoard = 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 @@ -314,6 +315,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
20 changes: 19 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,23 @@ BrainFlowBoards::BrainFlowBoards()
{"optical_channels", {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}},
{"battery_channel", 17}
};
brainflow_boards_json["boards"]["68"]["default"] =
{
{"name", "Shimmer3"},
{"sampling_rate", 512}, // configurable via config_board("sampling_rate:<Hz>")
{"package_num_channel", 0},
{"timestamp_channel", 18},
{"marker_channel", 19},
{"num_rows", 20},
{"accel_channels", {1, 2, 3}},
{"gyro_channels", {4, 5, 6}},
{"magnetometer_channels", {7, 8, 9}},
{"ecg_channels", {10, 11, 12, 13}},
{"eda_channels", {14}},
{"temperature_channels", {15}},
{"battery_channel", 16},
{"other_channels", {17}}
};
}

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/shimmer/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/shimmer/inc
)

target_compile_definitions(${BOARD_CONTROLLER_NAME} PRIVATE NOMINMAX BRAINFLOW_VERSION=${BRAINFLOW_VERSION})
Expand Down
77 changes: 77 additions & 0 deletions src/board_controller/shimmer/inc/shimmer3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#pragma once

#include <condition_variable>
#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
{
public:
Shimmer3 (struct BrainFlowInputParams params);
~Shimmer3 ();

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

private:
// Describes one field inside the streamed data packet, in transmit order.
struct PacketField
{
shimmer3::Signal signal;
shimmer3::FieldFormat format;
};

volatile bool keep_alive;
volatile bool initialized;

Serial *serial_port;
std::string port_name;

std::thread streaming_thread;

// First-data handshake: start_stream blocks until
// read_thread confirms real data packets are flowing, or times out.
std::mutex sync_mutex;
std::condition_variable sync_cv;
bool first_data_received;

double sampling_rate;
double package_num; // local sequence counter (Shimmer3
// packets carry no sequence number)
std::vector<PacketField> packet_layout; // leading timestamp + active signals
int packet_data_size; // bytes after the 0x00 header

// -- low-level serial helpers --
int write_bytes (const uint8_t *data, int len);
int read_exact (uint8_t *buf, int len);
int read_byte (uint8_t &out);
int wait_for_ack ();

// -- device commands --
int cmd_get_fw_version ();
int cmd_get_hw_version (uint8_t &hw_version);
int cmd_disable_instream_ack_prefix ();
int cmd_set_sensors (uint32_t bitfield);
int cmd_set_sampling_rate (double hz);
int cmd_inquiry ();
int cmd_start_streaming ();
int cmd_stop_streaming ();

// -- helpers --
void build_packet_layout (const std::vector<shimmer3::Signal> &signals);
void read_thread ();
int route_field (shimmer3::Signal s, int32_t raw, double *package, int &accel_axis,
int &gyro_axis, int &mag_axis, int &exg_idx, int &other_idx);
};
Loading