Skip to content

Commit 02d525b

Browse files
committed
Add get_gains_string() method to openbci_gain_tracker and remove hardcoded limits
1 parent 39bbb05 commit 02d525b

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/board_controller/openbci/galea.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,7 @@ int Galea::config_board (std::string conf, std::string &response)
117117

118118
if (conf == "get_gains")
119119
{
120-
std::stringstream gains;
121-
122-
for (int i = 0; i < 20; i++)
123-
{
124-
gains << gain_tracker.get_gain_for_channel (i);
125-
if (i < 19)
126-
{
127-
gains << ", ";
128-
}
129-
}
130-
response = gains.str ();
120+
response = gain_tracker.get_gains_string ();
131121
safe_logger (spdlog::level::info, "gains for all channels: {}", response);
132122
return (int)BrainFlowExitCodes::STATUS_OK;
133123
}

src/board_controller/openbci/inc/openbci_gain_tracker.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <algorithm>
4+
#include <sstream>
45
#include <stdlib.h>
56
#include <string>
67
#include <vector>
@@ -126,6 +127,20 @@ class OpenBCIGainTracker
126127
{
127128
std::copy (old_gains.begin (), old_gains.end (), current_gains.begin ());
128129
}
130+
131+
virtual std::string get_gains_string ()
132+
{
133+
std::stringstream gains;
134+
for (size_t i = 0; i < current_gains.size (); i++)
135+
{
136+
gains << current_gains[i];
137+
if (i < current_gains.size () - 1)
138+
{
139+
gains << ", ";
140+
}
141+
}
142+
return gains.str ();
143+
}
129144
};
130145

131146
class CytonGainTracker : public OpenBCIGainTracker

0 commit comments

Comments
 (0)