Skip to content

Commit

Permalink
AAVAA board addition (#668)
Browse files Browse the repository at this point in the history
* add aavaa board

---------

Co-authored-by: farnoodf <farnood.faraji@gmail.com>
  • Loading branch information
aavaa-farnood and FarnoodF committed Sep 13, 2023
1 parent f5bb746 commit b7e6753
Show file tree
Hide file tree
Showing 26 changed files with 882 additions and 64 deletions.
12 changes: 12 additions & 0 deletions cpp_package/src/board_shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,18 @@ std::vector<int> BoardShim::get_accel_channels (int board_id, int preset)
return std::vector<int> (channels, channels + len);
}

std::vector<int> BoardShim::get_rotation_channels (int board_id, int preset)
{
int channels[MAX_CHANNELS];
int len = 0;
int res = ::get_rotation_channels (board_id, preset, channels, &len);
if (res != (int)BrainFlowExitCodes::STATUS_OK)
{
throw BrainFlowException ("failed to get board info", res);
}
return std::vector<int> (channels, channels + len);
}

std::vector<int> BoardShim::get_gyro_channels (int board_id, int preset)
{
int channels[MAX_CHANNELS];
Expand Down
9 changes: 8 additions & 1 deletion cpp_package/src/inc/board_shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ class BoardShim
static std::vector<int> get_accel_channels (
int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET);
/**
* get row indices which hold analog data
* get row indices which hold rotation data
* @param board_id board id of your device
* @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
*/
static std::vector<int> get_rotation_channels (
int board_id, int preset = (int)BrainFlowPresets::DEFAULT_PRESET);
/**
* get row indices which hold rotation calib data
* @param board_id board id of your device
* @throw BrainFlowException If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR
*/
Expand Down
28 changes: 27 additions & 1 deletion csharp_package/brainflow/brainflow/board_controller_library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public enum BoardIds
GALEA_SERIAL_BOARD_V4 = 49,
NTL_WIFI_BOARD = 50,
ANT_NEURO_EE_511_BOARD = 51,
FREEEEG128_BOARD = 52
FREEEEG128_BOARD = 52,
AAVAA_V3_BOARD = 53
};


Expand Down Expand Up @@ -170,6 +171,8 @@ public static class BoardControllerLibrary64
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_rotation_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_analog_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_gyro_channels (int board_id, int preset, int[] channels, int[] len);
Expand Down Expand Up @@ -256,6 +259,8 @@ public static class BoardControllerLibrary32
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_rotation_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_analog_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("BoardController32.dll", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_gyro_channels (int board_id, int preset, int[] channels, int[] len);
Expand Down Expand Up @@ -342,6 +347,8 @@ public static class BoardControllerLibraryLinux
[DllImport ("libBoardController.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("libBoardController.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_rotation_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("libBoardController.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_analog_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("libBoardController.so", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_gyro_channels (int board_id, int preset, int[] channels, int[] len);
Expand Down Expand Up @@ -430,6 +437,8 @@ public static class BoardControllerLibraryMac
[DllImport ("libBoardController.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_accel_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("libBoardController.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_rotation_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("libBoardController.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_analog_channels (int board_id, int preset, int[] channels, int[] len);
[DllImport ("libBoardController.dylib", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
public static extern int get_gyro_channels (int board_id, int preset, int[] channels, int[] len);
Expand Down Expand Up @@ -1044,6 +1053,23 @@ public static int get_accel_channels (int board_id, int preset, int[] channels,
return (int)BrainFlowExitCodes.GENERAL_ERROR;
}

public static int get_rotation_channels (int board_id, int preset, int[] channels, int[] len)
{
switch (PlatformHelper.get_library_environment ())
{
case LibraryEnvironment.x64:
return BoardControllerLibrary64.get_rotation_channels (board_id, preset, channels, len);
case LibraryEnvironment.x86:
return BoardControllerLibrary32.get_rotation_channels (board_id, preset, channels, len);
case LibraryEnvironment.Linux:
return BoardControllerLibraryLinux.get_rotation_channels (board_id, preset, channels, len);
case LibraryEnvironment.MacOS:
return BoardControllerLibraryMac.get_rotation_channels (board_id, preset, channels, len);
}

return (int)BrainFlowExitCodes.GENERAL_ERROR;
}

public static int get_analog_channels (int board_id, int preset, int[] channels, int[] len)
{
switch (PlatformHelper.get_library_environment ())
Expand Down
5 changes: 4 additions & 1 deletion csharp_package/brainflow/brainflow/board_descr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class BoardDescr
[DataMember]
public int[] accel_channels;
[DataMember]
public int[] rotation_channels;
[DataMember]
public int[] gyro_channels;
[DataMember]
public int[] temperature_channels;
Expand All @@ -32,7 +34,7 @@ public class BoardDescr
[DataMember]
public int package_num_channel;
[DataMember]
public int batter_channel;
public int battery_channel;
[DataMember]
public int timestamp_channel;
[DataMember]
Expand All @@ -54,6 +56,7 @@ public BoardDescr ()
ppg_channels = null;
eda_channels = null;
accel_channels = null;
rotation_channels = null;
gyro_channels = null;
temperature_channels = null;
resistance_channels = null;
Expand Down
28 changes: 26 additions & 2 deletions csharp_package/brainflow/brainflow/board_shim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static int get_battery_channel (int board_id, int preset = (int)BrainFlow
}

/// <summary>
/// get number of rows in returned by get_board_data() 2d array
/// get number of rows in returned by get_board_data() 2d array
/// </summary>
/// <param name="board_id"></param>
/// <param name="preset">preset for device</param>
Expand Down Expand Up @@ -466,7 +466,31 @@ public static int[] get_accel_channels (int board_id, int preset = (int)BrainFlo
}

/// <summary>
/// get row indices which hold analog data
/// get row indices which hold rotation data
/// </summary>
/// <param name="board_id"></param>
/// <param name="preset">preset for device</param>
/// <returns>array of row nums</returns>
/// <exception cref="BrainFlowException">If this board has no such data exit code is UNSUPPORTED_BOARD_ERROR</exception>
public static int[] get_rotation_channels (int board_id, int preset = (int)BrainFlowPresets.DEFAULT_PRESET)
{
int[] len = new int[1];
int[] channels = new int[512];
int res = BoardControllerLibrary.get_rotation_channels (board_id, preset, channels, len);
if (res != (int)BrainFlowExitCodes.STATUS_OK)
{
throw new BrainFlowError (res);
}
int[] result = new int[len[0]];
for (int i = 0; i < len[0]; i++)
{
result[i] = channels[i];
}
return result;
}

/// <summary>
/// get row indices which hold analog data
/// </summary>
/// <param name="board_id"></param>
/// <param name="preset">preset for device</param>
Expand Down
4 changes: 2 additions & 2 deletions docs/DataFormatDesc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Data Format Description
Units of Measure
------------------

For EXG channels BrainFlow returns uV wherever possible.
For EXG channels BrainFlow returns uV wherever possible.

For timestamps BrainFlow uses UNIX timestamp, this counter starts at the Unix Epoch on January 1st, 1970 at UTC.
Precision is microsecond, but for some boards timestamps are generated on PC side as soon as packages were received.
Expand Down Expand Up @@ -115,7 +115,7 @@ There is a method :code:`get_board_descr(int board_id)`. You can use it to get a

.. code-block:: python
from pprint import pprint
from pprint import pprint
import brainflow
from brainflow.board_shim import BoardShim, BoardIds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ public class BoardDescr
public List<Integer> ppg_channels;
public List<Integer> eda_channels;
public List<Integer> accel_channels;
public List<Integer> rotation_channels;
public List<Integer> gyro_channels;
public List<Integer> temperature_channels;
public List<Integer> resistance_channels;
public List<Integer> other_channels;
public Integer package_num_channel;
public Integer batter_channel;
public Integer battery_channel;
public Integer timestamp_channel;
public Integer marker_channel;
public Integer num_rows;
Expand All @@ -34,6 +35,7 @@ public BoardDescr ()
ppg_channels = null;
eda_channels = null;
accel_channels = null;
rotation_channels = null;
gyro_channels = null;
temperature_channels = null;
resistance_channels = null;
Expand Down
3 changes: 2 additions & 1 deletion java_package/brainflow/src/main/java/brainflow/BoardIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public enum BoardIds
GALEA_SERIAL_BOARD_V4 (49),
NTL_WIFI_BOARD (50),
ANT_NEURO_EE_511_BOARD (51),
FREEEEG128_BOARD (52);
FREEEEG128_BOARD (52),
AAVAA_V3_BOARD(53);

private final int board_id;
private static final Map<Integer, BoardIds> bi_map = new HashMap<Integer, BoardIds> ();
Expand Down
6 changes: 4 additions & 2 deletions java_package/brainflow/src/main/java/brainflow/BoardShim.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ int get_current_board_data (int num_samples, int preset, double[] data_buf, int[

int get_accel_channels (int board_id, int preset, int[] accel_channels, int[] len);

int get_rotation_channels (int board_id, int preset, int[] rotation_channels, int[] len);

int get_analog_channels (int board_id, int preset, int[] analog_channels, int[] len);

int get_gyro_channels (int board_id, int preset, int[] gyro_channels, int[] len);
Expand Down Expand Up @@ -1418,9 +1420,9 @@ public String config_board (String config) throws BrainFlowError
/**
* start streaming thread, store data in internal ringbuffer and stream them
* from brainflow at the same time
*
*
* @param buffer_size size of internal ringbuffer
*
*
* @param streamer_params supported vals: "file://%file_name%:w",
* "file://%file_name%:a",
* "streaming_board://%multicast_group_ip%:%port%". Range
Expand Down
8 changes: 5 additions & 3 deletions julia_package/brainflow/src/board_shim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export BrainFlowInputParams
NTL_WIFI_BOARD = 50
ANT_NEURO_EE_511_BOARD = 51
FREEEEG128_BOARD = 52
AAVAA_V3_BOARD = 53

end

Expand Down Expand Up @@ -188,6 +189,7 @@ channel_function_names = (
:get_eda_channels,
:get_ppg_channels,
:get_accel_channels,
:get_rotation_channels,
:get_analog_channels,
:get_gyro_channels,
:get_other_channels,
Expand Down Expand Up @@ -294,7 +296,7 @@ end
end
num_rows = get_num_rows(board_shim.master_board_id, preset)
val = Vector{Float64}(undef, num_rows * data_size)
ccall((:get_board_data, BOARD_CONTROLLER_INTERFACE), Cint, (Cint, Cint, Ptr{Float64}, Cint, Ptr{UInt8}),
ccall((:get_board_data, BOARD_CONTROLLER_INTERFACE), Cint, (Cint, Cint, Ptr{Float64}, Cint, Ptr{UInt8}),
data_size, Int32(preset), val, board_shim.board_id, board_shim.input_json)
value = transpose(reshape(val, (data_size, num_rows)))
return value
Expand All @@ -304,7 +306,7 @@ end
data_size = get_board_data_count(board_shim, preset)
num_rows = get_num_rows(board_shim.master_board_id, preset)
val = Vector{Float64}(undef, num_rows * data_size)
ccall((:get_board_data, BOARD_CONTROLLER_INTERFACE), Cint, (Cint, Cint, Ptr{Float64}, Cint, Ptr{UInt8}),
ccall((:get_board_data, BOARD_CONTROLLER_INTERFACE), Cint, (Cint, Cint, Ptr{Float64}, Cint, Ptr{UInt8}),
data_size, Int32(preset), val, board_shim.board_id, board_shim.input_json)
value = transpose(reshape(val, (data_size, num_rows)))
return value
Expand All @@ -314,7 +316,7 @@ end
data_size = Vector{Cint}(undef, 1)
num_rows = get_num_rows(board_shim.master_board_id, preset)
val = Vector{Float64}(undef, num_rows * num_samples)
ccall((:get_current_board_data, BOARD_CONTROLLER_INTERFACE), Cint, (Cint, Cint, Ptr{Float64}, Ptr{Cint}, Cint, Ptr{UInt8}),
ccall((:get_current_board_data, BOARD_CONTROLLER_INTERFACE), Cint, (Cint, Cint, Ptr{Float64}, Ptr{Cint}, Cint, Ptr{UInt8}),
num_samples, Int32(preset), val, data_size, board_shim.board_id, board_shim.input_json)
value = transpose(reshape(val[1:data_size[1] * num_rows], (data_size[1], num_rows)))
return value
Expand Down
1 change: 1 addition & 0 deletions matlab_package/brainflow/BoardIds.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
NTL_WIFI_BOARD(50)
ANT_NEURO_EE_511_BOARD(51)
FREEEEG128_BOARD(52)
AAVAA_V3_BOARD(53)
end
end

0 comments on commit b7e6753

Please sign in to comment.