-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 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 eb81363
Merge branch 'brainflow-dev:master' into shimmer3
VigneshRajan-AMRC 43d29b7
Fix: change last board id to Shimmer3
VigneshRajan-AMRC 0415e03
Fix (shimmer3): address runtime config and packet parsing feedback
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,79 @@ | ||
| #pragma once | ||
|
|
||
| #include <atomic> | ||
| #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 () override; | ||
|
|
||
| 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; | ||
| int get_board_sampling_rate (int preset) override; | ||
|
|
||
| private: | ||
| // Describes one field inside one streamed sample, in transmit order. | ||
| struct PacketField | ||
| { | ||
| shimmer3::Signal signal; | ||
| shimmer3::FieldFormat format; | ||
| }; | ||
|
|
||
| std::atomic<bool> keep_alive; | ||
| bool initialized; | ||
|
|
||
| Serial *serial_port; | ||
| std::string port_name; | ||
|
|
||
| std::thread streaming_thread; | ||
|
|
||
| // First-data handshake between start_stream and read_thread. | ||
| std::mutex sync_mutex; | ||
| std::condition_variable sync_cv; | ||
| bool first_data_received; | ||
|
|
||
| double sampling_rate; | ||
| double package_num; | ||
| std::vector<PacketField> packet_layout; | ||
| int packet_data_size; | ||
| uint8_t samples_per_packet; | ||
| uint8_t configured_gsr_range; | ||
|
|
||
| // -- low-level serial helpers -- | ||
| int write_bytes (const uint8_t *data, int len); | ||
| int read_exact (uint8_t *buf, int len, bool cancellable = false); | ||
| int read_byte (uint8_t &out, bool cancellable = false); | ||
| 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 -- | ||
| bool build_packet_layout (const std::vector<shimmer3::Signal> &signals); | ||
| bool convert_gsr_to_microsiemens (int32_t raw, double &eda_us) const; | ||
| void route_field (shimmer3::Signal s, int32_t raw, double *package, int &other_idx); | ||
| void read_thread (); | ||
| }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.