Skip to content

Commit 2fe9d83

Browse files
removed gain from BrainFlowInputParams, format
1 parent 81bdbc0 commit 2fe9d83

File tree

4 files changed

+2
-47
lines changed

4 files changed

+2
-47
lines changed

src/board_controller/neuropawn/inc/knight_base.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class KnightBase : public Board
1818
Serial *serial;
1919

2020
int min_package_size;
21-
int gain;
2221

2322
virtual int send_to_board (const char *msg);
2423
virtual int send_to_board (const char *msg, std::string &response);
@@ -28,8 +27,6 @@ class KnightBase : public Board
2827
virtual void read_thread () = 0;
2928

3029
private:
31-
static const std::set<int> allowed_gains;
32-
3330
public:
3431
KnightBase (int board_id, struct BrainFlowInputParams params);
3532
virtual ~KnightBase ();

src/board_controller/neuropawn/knight.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void Knight::read_thread ()
2929

3030
int res;
3131
unsigned char b[20] = {0};
32-
float eeg_scale = 4 / float ((pow (2, 15) - 1)) / gain * 1000000.;
32+
float eeg_scale = 4 / float ((pow (2, 15) - 1)) / 12 * 1000000.;
3333
int num_rows = board_descr["default"]["num_rows"];
3434
double *package = new double[num_rows];
3535
for (int i = 0; i < num_rows; i++)

src/board_controller/neuropawn/knight_base.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ using json = nlohmann::json;
1212

1313
constexpr int KnightBase::start_byte;
1414
constexpr int KnightBase::end_byte;
15-
const std::set<int> KnightBase::allowed_gains = {1, 2, 3, 4, 6, 8, 12};
1615

1716
KnightBase::KnightBase (int board_id, struct BrainFlowInputParams params) : Board (board_id, params)
1817
{
1918
serial = NULL;
2019
is_streaming = false;
2120
keep_alive = false;
2221
initialized = false;
23-
gain = 12; // default gain value
2422
}
2523

2624
KnightBase::~KnightBase ()
@@ -42,46 +40,6 @@ int KnightBase::prepare_session ()
4240
return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
4341
}
4442

45-
// Parse gain from other_info if provided
46-
if (!params.other_info.empty ())
47-
{
48-
try
49-
{
50-
json j = json::parse (params.other_info);
51-
if (j.contains ("gain"))
52-
{
53-
int parsed_gain = j["gain"];
54-
// Validate gain is one of allowed values
55-
if (allowed_gains.count (parsed_gain))
56-
{
57-
gain = parsed_gain;
58-
safe_logger (spdlog::level::info, "Knight board gain set to {}", gain);
59-
}
60-
else
61-
{
62-
safe_logger (
63-
spdlog::level::err, "Invalid gain value {} in other_info", parsed_gain);
64-
return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
65-
}
66-
}
67-
else
68-
{
69-
safe_logger (spdlog::level::info, "No gain field in other_info, using default 12");
70-
}
71-
}
72-
catch (json::parse_error &e)
73-
{
74-
safe_logger (spdlog::level::err, "Failed to parse JSON from other_info: {}", e.what ());
75-
return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
76-
}
77-
catch (json::exception &e)
78-
{
79-
safe_logger (
80-
spdlog::level::err, "JSON exception while parsing other_info: {}", e.what ());
81-
return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR;
82-
}
83-
}
84-
8543
serial = Serial::create (params.serial_port.c_str (), this);
8644
int port_open = open_port ();
8745
if (port_open != (int)BrainFlowExitCodes::STATUS_OK)

src/board_controller/neuropawn/knight_imu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void KnightIMU::read_thread ()
3535

3636
unsigned char b[frame_payload_size] = {0};
3737

38-
float eeg_scale = 4 / float ((pow (2, 15) - 1)) / gain * 1000000.;
38+
float eeg_scale = 4 / float ((pow (2, 15) - 1)) / 12 * 1000000.;
3939
int num_rows = board_descr["default"]["num_rows"];
4040
double *package = new double[num_rows];
4141
for (int i = 0; i < num_rows; i++)

0 commit comments

Comments
 (0)