Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/board_controller/neuropawn/inc/knight_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ class KnightBase : public Board

static constexpr int start_byte = 0xA0;
static constexpr int end_byte = 0xC0;
// 4 Vref / (2^15 - 1) / gain / 79.57 * 1e6 -> uV. Gain is fixed at 12.
static constexpr double eeg_scale = 4.0 / (32768.0 - 1.0) / 12.0 / 79.57 * 1000000.0;
};
6 changes: 2 additions & 4 deletions src/board_controller/neuropawn/knight.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <math.h>
#include <vector>

#include "custom_cast.h"
Expand Down Expand Up @@ -29,7 +28,6 @@ void Knight::read_thread ()

int res;
unsigned char b[20] = {0};
float eeg_scale = 4 / float ((pow (2, 15) - 1)) / 12 * 1000000.;
int num_rows = board_descr["default"]["num_rows"];
double *package = new double[num_rows];
for (int i = 0; i < num_rows; i++)
Expand Down Expand Up @@ -81,8 +79,8 @@ void Knight::read_thread ()
// exg data retrieval
for (unsigned int i = 0; i < eeg_channels.size (); i++)
{
package[eeg_channels[i]] =
eeg_scale * cast_16bit_to_int32 (b + 1 + 2 * i); // CHANGE TO 2+2*i if not working
package[eeg_channels[i]] = KnightBase::eeg_scale *
cast_16bit_to_int32 (b + 1 + 2 * i); // CHANGE TO 2+2*i if not working
}

// other channel data retrieval
Expand Down
1 change: 1 addition & 0 deletions src/board_controller/neuropawn/knight_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using json = nlohmann::json;

constexpr int KnightBase::start_byte;
constexpr int KnightBase::end_byte;
constexpr double KnightBase::eeg_scale;

KnightBase::KnightBase (int board_id, struct BrainFlowInputParams params) : Board (board_id, params)
{
Expand Down
5 changes: 2 additions & 3 deletions src/board_controller/neuropawn/knight_imu.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <cstdint>
#include <cstring>
#include <limits>
#include <math.h>
#include <vector>

#include "custom_cast.h"
Expand Down Expand Up @@ -35,7 +34,6 @@ void KnightIMU::read_thread ()

unsigned char b[frame_payload_size] = {0};

float eeg_scale = 4 / float ((pow (2, 15) - 1)) / 12 * 1000000.;
int num_rows = board_descr["default"]["num_rows"];
double *package = new double[num_rows];
for (int i = 0; i < num_rows; i++)
Expand Down Expand Up @@ -91,7 +89,8 @@ void KnightIMU::read_thread ()
const int exg_offset = 1;
for (unsigned int i = 0; i < eeg_channels.size () && i < exg_channels_count; i++)
{
package[eeg_channels[i]] = eeg_scale * cast_16bit_to_int32 (b + exg_offset + 2 * i);
package[eeg_channels[i]] =
KnightBase::eeg_scale * cast_16bit_to_int32 (b + exg_offset + 2 * i);
}

// other channel data retrieval (keep old behavior)
Expand Down
Loading