Skip to content

Commit

Permalink
Merge pull request #1 from NeuroPawn/knight-board
Browse files Browse the repository at this point in the history
Knight board
  • Loading branch information
Kevin-Xue01 authored Sep 17, 2024
2 parents fede9a6 + cac9b9b commit a3af6c8
Show file tree
Hide file tree
Showing 13 changed files with 399 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public enum BoardIds
EXPLORE_PLUS_8_CHAN_BOARD = 54,
EXPLORE_PLUS_32_CHAN_BOARD = 55,
PIEEG_BOARD = 56
NEUROPAWN_KNIGHT_BOARD = 57
};


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 @@ -65,7 +65,8 @@ public enum BoardIds
AAVAA_V3_BOARD(53),
EXPLORE_PLUS_8_CHAN_BOARD(54),
EXPLORE_PLUS_32_CHAN_BOARD(55),
PIEEG_BOARD(56);
PIEEG_BOARD(56),
NEUROPAWN_KNIGHT_BOARD(57);

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 @@ -61,6 +61,7 @@ export BrainFlowInputParams
EXPLORE_PLUS_8_CHAN_BOARD = 54
EXPLORE_PLUS_32_CHAN_BOARD = 55
PIEEG_BOARD = 56
NEUROPAWN_KNIGHT_BOARD = 57

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 @@ -59,5 +59,6 @@
EXPLORE_PLUS_8_CHAN_BOARD(54)
EXPLORE_PLUS_32_CHAN_BOARD(55)
PIEEG_BOARD(56)
NEUROPAWN_KNIGHT_BOARD(57)
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 @@ -68,7 +68,8 @@ export enum BoardIds {
ANT_NEURO_EE_511_BOARD = 51,
EXPLORE_PLUS_8_CHAN_BOARD = 54,
EXPLORE_PLUS_32_CHAN_BOARD = 55,
PIEEG_BOARD = 56
PIEEG_BOARD = 56,
NEUROPAWN_KNIGHT_BOARD = 57
}

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 @@ -74,6 +74,7 @@ class BoardIds(enum.IntEnum):
EXPLORE_PLUS_8_CHAN_BOARD = 54 #:
EXPLORE_PLUS_32_CHAN_BOARD = 55 #:
PIEEG_BOARD = 56 #:
NEUROPAWN_KNIGHT_BOARD = 57 #:


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 @@ -94,6 +94,7 @@ pub enum BoardIds {
AavaaV3Board = 53,
ExplorePlus8ChanBoard = 54,
ExplorePlus32ChanBoard = 55,
NeuroPawnKnightBoard = 57
}
#[repr(i32)]
#[derive(FromPrimitive, ToPrimitive, Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down
8 changes: 6 additions & 2 deletions src/board_controller/board_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "ganglion_wifi.h"
#include "gforce_dual.h"
#include "gforce_pro.h"
#include "json.hpp"
#include "knight.h"
#include "muse.h"
#include "muse_bled.h"
#include "notion_osc.h"
Expand All @@ -55,8 +57,6 @@
#include "synthetic_board.h"
#include "unicorn_board.h"

#include "json.hpp"

using json = nlohmann::json;


Expand Down Expand Up @@ -281,6 +281,10 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
case BoardIds::PIEEG_BOARD:
board = std::shared_ptr<Board> (new PIEEGBoard (board_id, params));
break;
case BoardIds::NEUROPAWN_KNIGHT_BOARD:
board =
std::shared_ptr<Board> (new Knight ((int)BoardIds::NEUROPAWN_KNIGHT_BOARD, params));
break;
default:
return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR;
}
Expand Down
14 changes: 13 additions & 1 deletion src/board_controller/brainflow_boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ BrainFlowBoards::BrainFlowBoards()
{"53", json::object()},
{"54", json::object()},
{"55", json::object()},
{"56", json::object()}
{"56", json::object()},
{"57", json::object()}
}
}};

Expand Down Expand Up @@ -1095,6 +1096,17 @@ BrainFlowBoards::BrainFlowBoards()
{"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8}},
{"eeg_names", "Fp1,Fp2,C3,C4,P7,P8,O1,O2"}
};
brainflow_boards_json["boards"]["57"]["default"] =
{
{"name", "Knight"},
{"sampling_rate", 125},
{"timestamp_channel", 11},
{"marker_channel",12},
{"package_num_channel", 0},
{"num_rows", 13},
{"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8}},
{"other_channels", {9, 10}}
};
}

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 @@ -85,6 +85,7 @@ SET (BOARD_CONTROLLER_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ntl/ntl_wifi.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/aavaa/aavaa_v3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/pieeg/pieeg_board.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuropawn/knight.cpp
)

include (${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ant_neuro/build.cmake)
Expand Down Expand Up @@ -142,6 +143,7 @@ target_include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ntl/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/aavaa/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/pieeg/inc
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/neuropawn/inc
)

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

#include <thread>

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

class Knight : public Board
{

protected:
volatile bool keep_alive;
bool initialized;
bool is_streaming;
std::thread streaming_thread;
Serial *serial;

int min_package_size;

virtual int send_to_board (const char *msg);
virtual int send_to_board (const char *msg, std::string &response);
virtual std::string read_serial_response ();
int open_port ();
int set_port_settings ();
void read_thread ();

public:
Knight (int board_id, struct BrainFlowInputParams params);
~Knight ();

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);

static constexpr int start_byte = 0xA0;
static constexpr int end_byte = 0xC0;
};
Loading

0 comments on commit a3af6c8

Please sign in to comment.