@@ -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