Hi,
The portion of code that I've posted is supposed to come up with an average heart rate variable. The problem I'm having is that every time that the average gets within about 10 bpm to the current HR (only from the low end. It will decrease to a lower average just fine, but it won't increase), it is no longer affected by the current heart rate and stays where it is. The math formula I wrote in here works fine, I tested it by hand with no problem. I was hoping someone could point something I perhaps missed as someone newer to the Garmin environment? Maybe there's a problem with rounding that I'm unaware of?
Thanks!
All variables are set by default to 0, and this is located in a method the runs each second.
myHR = Info.getActivityInfo().currentHeartRate;
mySaturation = Info.getActivityInfo().currentOxygenSaturation;
if(myHR != null) {
secondDivisor += 1;
if(myAverageHR == 0) {
myAverageHR = myHR;
Sys.println(secondDivisor);
Sys.println(myHR);
Sys.println(myAverageHR);
Sys.println("---------------------");
}
else {
myAverageHR = ((myAverageHR * secondDivisor) + myHR)/(secondDivisor + 1);
Sys.println(secondDivisor);
Sys.println(myHR);
Sys.println(myAverageHR);
Sys.println("---------------------");
}