Dear All,
I am using SmartRF development board to run a Heart Rate Sensor example.
The example send a heart rate value to central device when it detect a new beat.
But the size of beat value is 1 byte only, and now I want to modify the code to send the Interbeat interval value which needs 2 bytes.
I am wondering how to modify the code as follow?
( If you want to project file with all code, I can send it to you, thank you very much, I really want to solve it out quickly)
Many thanks,
Caroline
------------- heartrate.c -------------------
static void heartRateMeasNotify_PulseSensor(uint8 heatRate) // === call in heartRatePeriodicTask() ===========
{
uint8 *p = heartRateMeas.value;
uint8 flags = heartRateFlags[heartRateFlagsIdx];
// build heart rate measurement structure from simulated values
*p++ = flags;
*p++ = heatRate; // ========== append heatRate to p ==========
if (flags & HEARTRATE_FLAGS_FORMAT_UINT16)
{
// additional byte for 16 bit format
*p++ = 0;
}
if (flags & HEARTRATE_FLAGS_ENERGY_EXP)
{
*p++ = LO_UINT16(heartRateEnergy);
*p++ = HI_UINT16(heartRateEnergy);
}
if (flags & HEARTRATE_FLAGS_RR)
{
*p++ = LO_UINT16(heartRateRrInterval1);
*p++ = HI_UINT16(heartRateRrInterval1);
*p++ = LO_UINT16(heartRateRrInterval2);
*p++ = HI_UINT16(heartRateRrInterval2);
}
heartRateMeas.len = (uint8) (p - heartRateMeas.value); // BMP, without this line, notify nothing
HeartRate_MeasNotify( gapConnHandle, &heartRateMeas ); // =============== 把填充好的心率数据发送 ,在 heartrateservice.c ===============
}
---------- pulse_sensor.c ------------
static int BPM; // used to hold the pulse rate
static int Signal; // holds the incoming raw data
static int IBI = 600; // holds the time between beats, the Inter-Beat Interval
........
uint8 GetCurrentHeartRate() // Orignial code in the example
{
if(QS)
{
QS = FALSE;
LCD_WRITE_STRING_VALUE("IBI : ", IBI, 10, HAL_LCD_LINE_6); // DH add
return BPM;
}
return 0;
}
uint16 GetCurrentHeartRate() // I modify the above code as follow
{
if(QS)
{
QS = FALSE;
// return BMP; // the code originally return BMP, so I change it to return Interbeat Interval(IBI), which is normally in the range of 600~1200ms
HalLcdWriteStringValueValue("IBI : ", IBI, 10, IBI, 16,HAL_LCD_LINE_6);
return IBI;
}
return 0; /
}