-
-
Notifications
You must be signed in to change notification settings - Fork 395
Add Shimmer3 board support #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VigneshRajan-AMRC
wants to merge
4
commits into
brainflow-dev:master
Choose a base branch
from
VigneshRajan-AMRC:shimmer3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a0468d6
Add Shimmer3 board support (C++ API adapted from pyshimmer)
VigneshRajan-AMRC ecc6814
Add Shimmer3 board (ID 68) to BrainFlow
VigneshRajan-AMRC 9eea0b9
Fix more Shimmer3 Board ID in more spots
VigneshRajan-AMRC 3d07101
Fully reworked and refined Shimmer3 board support
VigneshRajan-AMRC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,5 +67,6 @@ | |
| IRONBCI_32_BOARD(65) | ||
| NEUROPAWN_KNIGHT_BOARD_IMU(66) | ||
| MUSE_S_ATHENA_BOARD(67) | ||
| SHIMMER3_BOARD(68) | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in brainflow api new method was added - get_board_sampling_rate, you can use this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
especially since you allow overriding sampling rates via config_board method, it would be good to have it, check #805