Skip to content

Commit ebe6c25

Browse files
authored
restore support for pieeg (#729)
* restore support for pieeg Signed-off-by: Andrey Parfenov <a1994ndrey@gmail.com> Author: Nick Gamb <nickgamb@gmail.com> Date: Sun Jun 30 02:40:04 2024 +0200
1 parent a0b554d commit ebe6c25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+10429
-5
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ option (BUILD_BLUETOOTH "BUILD_BLUETOOTH" OFF)
2424
option (BUILD_BLE "BUILD_BLE" OFF)
2525
option (BUILD_ONNX "BUILD_ONNX" OFF)
2626
option (BUILD_TESTS "BUILD_TESTS" OFF)
27+
option (BUILD_PERIPHERY "BUILD_PERIPHERY" OFF)
2728

2829
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros.cmake)
2930
configure_msvc_runtime ()

csharp_package/brainflow/brainflow/board_controller_library.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public enum BoardIds
114114
FREEEEG128_BOARD = 52,
115115
AAVAA_V3_BOARD = 53,
116116
EXPLORE_PLUS_8_CHAN_BOARD = 54,
117-
EXPLORE_PLUS_32_CHAN_BOARD = 55
117+
EXPLORE_PLUS_32_CHAN_BOARD = 55,
118+
PIEEG_BOARD = 56
118119
};
119120

120121

docs/SupportedBoards.rst

+37
Original file line numberDiff line numberDiff line change
@@ -1268,3 +1268,40 @@ Available :ref:`presets-label`:
12681268
- :code:`BrainFlowPresets.DEFAULT_PRESET`, it contains accelerometer, gyroscope and magnetometer data
12691269
- :code:`BrainFlowPresets.AUXILIARY_PRESET`, it contains PPG data
12701270
- :code:`BrainFlowPresets.ANCILLARY_PRESET`, it contains EDA and temperature data
1271+
1272+
PiEEG
1273+
------
1274+
1275+
PiEEG Board
1276+
~~~~~~~~~~~
1277+
1278+
PiEEG (Measure EEG with RaspberryPi) – Brain-computer interface (EEG, EMG, and ECG bio-signals) is an open-source Raspberry Pi shield that measures biosignals such as those used in electroencephalography (EEG), electromyography (EMG), and electrocardiography (ECG). It integrates seamlessly with BrainFlow's API, allowing for easy data streaming, processing, and analysis.
1279+
1280+
.. image:: https://live.staticflickr.com/65535/53823500137_3bf2e27dbf_z.jpg
1281+
:width: 640px
1282+
:height: 384px
1283+
1284+
`PiEEG Website <https://pieeg.com/>`_
1285+
1286+
To create such a board, you need to specify the following board ID and fields of the BrainFlowInputParams object:
1287+
1288+
- :code:`BoardIds.PIEEG_BOARD`
1289+
- :code:`serial_port`(optional), e.g., COM3, /dev/spidev0.0, etc.
1290+
1291+
Initialization Example:
1292+
1293+
.. code-block:: python
1294+
from brainflow.board_shim import BoardShim, BrainFlowInputParams, BoardIds
1295+
params = BrainFlowInputParams()
1296+
params.serial_port = "/dev/spidev0.0"
1297+
board = BoardShim(BoardIds.PIEEG_BOARD, params)
1298+
board.prepare_session()
1299+
board.start_stream()
1300+
1301+
Supported platforms:
1302+
1303+
- Raspberry Pi
1304+
1305+
**Note**: Ensure that you have the necessary permissions to access the serial port on your operating system. For Unix-like systems, you may need to configure permissions for the serial port or run with sudo.
1306+
1307+
**To use this board you need to compile BrainFlow from the source code right on your Raspbery Pi device with flag --build-periphery(build.py) or with -DBUILD_PERIPHERY=ON(CMake) and install desired bindings using local libraries.**

java_package/brainflow/src/main/java/brainflow/BoardIds.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public enum BoardIds
6464
FREEEEG128_BOARD (52),
6565
AAVAA_V3_BOARD(53),
6666
EXPLORE_PLUS_8_CHAN_BOARD(54),
67-
EXPLORE_PLUS_32_CHAN_BOARD(55);
67+
EXPLORE_PLUS_32_CHAN_BOARD(55),
68+
PIEEG_BOARD(56);
6869

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

julia_package/brainflow/src/board_shim.jl

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export BrainFlowInputParams
6060
AAVAA_V3_BOARD = 53
6161
EXPLORE_PLUS_8_CHAN_BOARD = 54
6262
EXPLORE_PLUS_32_CHAN_BOARD = 55
63+
PIEEG_BOARD = 56
6364

6465
end
6566

matlab_package/brainflow/BoardIds.m

+1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@
5858
AAVAA_V3_BOARD(53)
5959
EXPLORE_PLUS_8_CHAN_BOARD(54)
6060
EXPLORE_PLUS_32_CHAN_BOARD(55)
61+
PIEEG_BOARD(56)
6162
end
6263
end

nodejs_package/brainflow/brainflow.types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export enum BoardIds {
6767
NTL_WIFI_BOARD = 50,
6868
ANT_NEURO_EE_511_BOARD = 51,
6969
EXPLORE_PLUS_8_CHAN_BOARD = 54,
70-
EXPLORE_PLUS_32_CHAN_BOARD = 55
70+
EXPLORE_PLUS_32_CHAN_BOARD = 55,
71+
PIEEG_BOARD = 56
7172
}
7273

7374
export enum IpProtocolTypes {

python_package/brainflow/board_shim.py

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class BoardIds(enum.IntEnum):
7373
AAVAA_V3_BOARD = 53 #:
7474
EXPLORE_PLUS_8_CHAN_BOARD = 54 #:
7575
EXPLORE_PLUS_32_CHAN_BOARD = 55 #:
76+
PIEEG_BOARD = 56 #:
7677

7778

7879
class IpProtocolTypes(enum.IntEnum):

src/board_controller/board_controller.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "muse_bled.h"
5050
#include "notion_osc.h"
5151
#include "ntl_wifi.h"
52+
#include "pieeg_board.h"
5253
#include "playback_file_board.h"
5354
#include "streaming_board.h"
5455
#include "synthetic_board.h"
@@ -277,6 +278,9 @@ int prepare_session (int board_id, const char *json_brainflow_input_params)
277278
case BoardIds::EXPLORE_PLUS_32_CHAN_BOARD:
278279
board = std::shared_ptr<Board> (new Explore (board_id, params));
279280
break;
281+
case BoardIds::PIEEG_BOARD:
282+
board = std::shared_ptr<Board> (new PIEEGBoard (board_id, params));
283+
break;
280284
default:
281285
return (int)BrainFlowExitCodes::UNSUPPORTED_BOARD_ERROR;
282286
}

src/board_controller/brainflow_boards.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ BrainFlowBoards::BrainFlowBoards()
7171
{"50", json::object()},
7272
{"51", json::object()},
7373
{"52", json::object()},
74-
{"53", json::object()}
74+
{"53", json::object()},
75+
{"54", json::object()},
76+
{"55", json::object()},
77+
{"56", json::object()}
7578
}
7679
}};
7780

@@ -1082,6 +1085,16 @@ BrainFlowBoards::BrainFlowBoards()
10821085
{"battery_channel", 2},
10831086
{"other_channels", {3}}
10841087
};
1088+
brainflow_boards_json["boards"]["56"]["default"] = {
1089+
{"name", "PIEEG"},
1090+
{"sampling_rate", 250},
1091+
{"package_num_channel", 0},
1092+
{"timestamp_channel", 9},
1093+
{"marker_channel", 10},
1094+
{"num_rows", 11},
1095+
{"eeg_channels", {1, 2, 3, 4, 5, 6, 7, 8}},
1096+
{"eeg_names", "Fp1,Fp2,C3,C4,P7,P8,O1,O2"}
1097+
};
10851098
}
10861099

10871100
BrainFlowBoards boards_struct;

src/board_controller/build.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ SET (BOARD_CONTROLLER_SRC
8484
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/emotibit/emotibit.cpp
8585
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ntl/ntl_wifi.cpp
8686
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/aavaa/aavaa_v3.cpp
87+
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/pieeg/pieeg_board.cpp
8788
)
8889

8990
include (${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ant_neuro/build.cmake)
@@ -140,6 +141,7 @@ target_include_directories (
140141
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/emotibit/inc
141142
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/ntl/inc
142143
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/aavaa/inc
144+
${CMAKE_CURRENT_SOURCE_DIR}/src/board_controller/pieeg/inc
143145
)
144146

145147
target_compile_definitions(${BOARD_CONTROLLER_NAME} PRIVATE NOMINMAX BRAINFLOW_VERSION=${BRAINFLOW_VERSION})
@@ -168,6 +170,13 @@ if (USE_LIBFTDI)
168170
endif (LibFTDI1_FOUND)
169171
endif (USE_LIBFTDI)
170172

173+
if (BUILD_PERIPHERY)
174+
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/third_party/periphery)
175+
target_compile_definitions (${BOARD_CONTROLLER_NAME} PRIVATE USE_PERIPHERY)
176+
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/third_party/periphery)
177+
target_link_libraries (${BOARD_CONTROLLER_NAME} PRIVATE periphery ${CMAKE_THREAD_LIBS_INIT} dl)
178+
endif (BUILD_PERIPHERY)
179+
171180
if (MSVC)
172181
add_custom_command (TARGET ${BOARD_CONTROLLER_NAME} POST_BUILD
173182
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/$<CONFIG>/${BOARD_CONTROLLER_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${BOARD_CONTROLLER_COMPILED_NAME}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <thread>
5+
6+
#include "board.h"
7+
#include "board_controller.h"
8+
#include "math.h"
9+
#include "socket_server_tcp.h"
10+
11+
#ifdef USE_PERIPHERY
12+
#include "gpio.h"
13+
#include "spi.h"
14+
#endif
15+
16+
class PIEEGBoard : public Board
17+
{
18+
protected:
19+
#ifdef USE_PERIPHERY
20+
volatile bool keep_alive;
21+
bool initialized;
22+
std::thread streaming_thread;
23+
spi_t *spi;
24+
gpio_t *gpio_in;
25+
SocketServerTCP *server_socket;
26+
void read_thread ();
27+
int write_reg (uint8_t reg_address, uint8_t val);
28+
int send_command (uint8_t command);
29+
#endif
30+
31+
public:
32+
PIEEGBoard (int board_id, struct BrainFlowInputParams params);
33+
~PIEEGBoard ();
34+
35+
int prepare_session ();
36+
int start_stream (int buffer_size, const char *streamer_params);
37+
int stop_stream ();
38+
int release_session ();
39+
int config_board (std::string config, std::string &response);
40+
};

0 commit comments

Comments
 (0)