Skip to content

Commit 746f07b

Browse files
kcoulcalebkuitenbrouwerAndrey1994
authored
Add battery stats (#800)
* Add battery stats * Update emotibit.cpp * Fix EmotiBit clang-format --------- Co-authored-by: calebkuitenbrouwer <33358507+calebkuitenbrouwer@users.noreply.github.com> Co-authored-by: Andrey Parfenov <a1994ndrey@gmail.com>
1 parent 9a9c47b commit 746f07b

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

src/board_controller/brainflow_boards.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,11 @@ BrainFlowBoards::BrainFlowBoards()
896896
{"package_num_channel", 0},
897897
{"timestamp_channel", 4},
898898
{"marker_channel", 5},
899-
{"num_rows", 6},
899+
{"num_rows", 8},
900900
{"eda_channels", {1}},
901901
{"temperature_channels", {2}},
902-
{"other_channels", {3}}
902+
{"other_channels", {3, 6}},
903+
{"battery_channel", 7}
903904
};
904905
brainflow_boards_json["boards"]["50"]["default"] =
905906
{

src/board_controller/emotibit/emotibit.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,27 +345,35 @@ void Emotibit::read_thread ()
345345
}
346346
}
347347
// ancillary package
348-
if ((type_tag == TEMPERATURE_1) || (type_tag == THERMOPILE))
348+
if ((type_tag == TEMPERATURE_1) || (type_tag == THERMOPILE) ||
349+
(type_tag == BATTERY_VOLTAGE) || (type_tag == BATTERY_PERCENT))
349350
{
350-
int temperature_channel = 0;
351+
int channel_index = 0;
351352
if (type_tag == TEMPERATURE_1)
352353
{
353-
temperature_channel = board_descr["ancillary"]["temperature_channels"][0];
354+
channel_index = board_descr["ancillary"]["temperature_channels"][0];
354355
}
355356
if (type_tag == THERMOPILE)
356357
{
357-
temperature_channel = board_descr["ancillary"]["other_channels"][0];
358+
channel_index = board_descr["ancillary"]["other_channels"][0];
358359
}
359-
// upsample temperature data 2x to match eda
360+
if (type_tag == BATTERY_VOLTAGE)
361+
{
362+
channel_index = board_descr["ancillary"]["other_channels"][1];
363+
}
364+
if (type_tag == BATTERY_PERCENT)
365+
{
366+
channel_index = board_descr["ancillary"]["battery_channel"];
367+
}
368+
// upsample lower-rate ancillary values 2x to better align with EDA samples
360369
if (payload.size () < max_datapoints_in_package / 2)
361370
{
362371
for (int i = 0; i < (int)payload.size (); i++)
363372
{
364373
try
365374
{
366-
anc_packages[i * 2][temperature_channel] = std::stod (payload[i]);
367-
anc_packages[i + 1][temperature_channel] =
368-
anc_packages[i][temperature_channel];
375+
anc_packages[i * 2][channel_index] = std::stod (payload[i]);
376+
anc_packages[i + 1][channel_index] = anc_packages[i][channel_index];
369377
}
370378
catch (...)
371379
{
@@ -382,7 +390,7 @@ void Emotibit::read_thread ()
382390
{
383391
try
384392
{
385-
anc_packages[i][temperature_channel] = std::stod (payload[i]);
393+
anc_packages[i][channel_index] = std::stod (payload[i]);
386394
}
387395
catch (...)
388396
{

0 commit comments

Comments
 (0)