Skip to content

Commit 83ef473

Browse files
committed
Add battery stats
1 parent c3a28e2 commit 83ef473

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/board_controller/brainflow_boards.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,10 +890,11 @@ BrainFlowBoards::BrainFlowBoards()
890890
{"package_num_channel", 0},
891891
{"timestamp_channel", 4},
892892
{"marker_channel", 5},
893-
{"num_rows", 6},
893+
{"num_rows", 8},
894894
{"eda_channels", {1}},
895895
{"temperature_channels", {2}},
896-
{"other_channels", {3}}
896+
{"other_channels", {3, 6}},
897+
{"battery_channel", 7}
897898
};
898899
brainflow_boards_json["boards"]["50"]["default"] =
899900
{

src/board_controller/emotibit/emotibit.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,27 +345,36 @@ 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 ancillary_channel = 0;
351352
if (type_tag == TEMPERATURE_1)
352353
{
353-
temperature_channel = board_descr["ancillary"]["temperature_channels"][0];
354+
ancillary_channel = board_descr["ancillary"]["temperature_channels"][0];
354355
}
355356
if (type_tag == THERMOPILE)
356357
{
357-
temperature_channel = board_descr["ancillary"]["other_channels"][0];
358+
ancillary_channel = board_descr["ancillary"]["other_channels"][0];
358359
}
359-
// upsample temperature data 2x to match eda
360+
if (type_tag == BATTERY_VOLTAGE)
361+
{
362+
ancillary_channel = board_descr["ancillary"]["other_channels"][1];
363+
}
364+
if (type_tag == BATTERY_PERCENT)
365+
{
366+
ancillary_channel = 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][ancillary_channel] = std::stod (payload[i]);
376+
anc_packages[i + 1][ancillary_channel] =
377+
anc_packages[i][ancillary_channel];
369378
}
370379
catch (...)
371380
{
@@ -382,7 +391,7 @@ void Emotibit::read_thread ()
382391
{
383392
try
384393
{
385-
anc_packages[i][temperature_channel] = std::stod (payload[i]);
394+
anc_packages[i][ancillary_channel] = std::stod (payload[i]);
386395
}
387396
catch (...)
388397
{

0 commit comments

Comments
 (0)