Skip to content

Commit

Permalink
Correct HRM output for Stages Power meters (#57)
Browse files Browse the repository at this point in the history
Specifically, as the V800 only reports power for the left side when
using Stages power meters, the total output power samples ought to be
doubled.
  • Loading branch information
pcolby committed Nov 24, 2015
1 parent 1f742a3 commit 6f8e7bb
Show file tree
Hide file tree
Showing 3 changed files with 12,265 additions and 12,261 deletions.
10 changes: 7 additions & 3 deletions src/polar/v2/trainingsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ QStringList TrainingSession::toHRM(const bool rrDataOnly) const
const bool havePowerLeft = ((!rrDataOnly) && (haveAnySamples(samples, QLatin1String("left-pedal-power"))));
const bool havePowerRight = ((!rrDataOnly) && (haveAnySamples(samples, QLatin1String("right-pedal-power"))));
const bool havePower = (havePowerLeft || havePowerRight);
const bool havePowerBalance = (havePowerLeft && havePowerRight);
const bool havePowerBalance = havePower;
const bool haveSpeed = ((!rrDataOnly) && (haveAnySamples(samples, QLatin1String("altitude"))));

QString hrmData;
Expand Down Expand Up @@ -1876,12 +1876,16 @@ QStringList TrainingSession::toHRM(const bool rrDataOnly) const
first(powerLeft.at(index).toMap().value(QLatin1String("current-power"))).toInt() : 0;
const int currentPowerRight = (index < powerRight.length()) ?
first(powerRight.at(index).toMap().value(QLatin1String("current-power"))).toInt() : 0;
const int currentPower = currentPowerLeft + currentPowerRight;
const int currentPower = (havePowerLeft && havePowerRight)
? currentPowerLeft + currentPowerRight
: (havePowerLeft ? currentPowerLeft : currentPowerRight) * 2;
stream << '\t' << currentPower;
if (havePowerBalance) {
// In case we only have right power, not left.
const int powerLeft = havePowerLeft ? currentPowerLeft : currentPower - currentPowerRight;
// Convert the left and right powers into a left-right balance percentage.
const int leftBalance = (currentPower == 0) ? 0 :
qRound(100.0 * (float)currentPowerLeft / (float)currentPower);
qRound(100.0 * (float)powerLeft / (float)currentPower);
if (leftBalance > 100) {
qWarning() << "leftBalance of " << leftBalance << "% is greater than 100%";
}
Expand Down
Loading

0 comments on commit 6f8e7bb

Please sign in to comment.