Withings Weight and Watts per Kilogram

Fixed up the code to use withings weight when calculating watts
per kilogram and the display on the CP chart.

There will be issues when retrospectively refreshing data from a
withings account, but that is such an edge case we can just ask
people to delete old .cpx files to ensure they are refreshed.
This commit is contained in:
Mark Liversedge
2012-07-08 15:38:53 +01:00
parent a3d2e84465
commit 8dae828da2
3 changed files with 17 additions and 27 deletions

View File

@@ -692,27 +692,14 @@ MainWindow::MainWindow(const QDir &home) :
rideMenu->addAction(tr("Split &activity..."), this, SLOT(splitRide()));
rideMenu->addSeparator ();
// XXX MEASURES ARE NOT IMPLEMENTED YET
//#if 0
QMenu *measureMenu = menuBar()->addMenu(tr("&Measure"));
measureMenu->addAction(tr("&Record Measures..."), this,
SLOT(recordMeasure()), tr("Ctrl+R"));
measureMenu->addSeparator();
measureMenu->addAction(tr("&Export Measures..."), this,
SLOT(exportMeasures()), tr("Ctrl+E"));
measureMenu->addAction(tr("&Import Measures..."), this,
SLOT(importMeasures()), tr("Ctrl+I"));
measureMenu->addSeparator();
measureMenu->addAction(tr("Get &Withings Data..."), this,
SLOT (downloadMeasures()));
//#endif
QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools"));
optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions()));
optionsMenu->addAction(tr("Critical Power Calculator..."), this, SLOT(showTools()));
optionsMenu->addAction(tr("Air Density (Rho) Estimator..."), this, SLOT(showRhoEstimator()));
optionsMenu->addSeparator();
optionsMenu->addAction(tr("Get &Withings Data..."), this,
SLOT (downloadMeasures()));
optionsMenu->addSeparator();
optionsMenu->addAction(tr("Workout Wizard"), this, SLOT(showWorkoutWizard()));
optionsMenu->addAction(tr("Get Workouts from ErgDB"), this, SLOT(downloadErgDB()));

View File

@@ -40,12 +40,12 @@
RideFile::RideFile(const QDateTime &startTime, double recIntSecs) :
startTime_(startTime), recIntSecs_(recIntSecs),
deviceType_("unknown"), data(NULL)
deviceType_("unknown"), data(NULL), weight_(0)
{
command = new RideFileCommand(this);
}
RideFile::RideFile() : recIntSecs_(0.0), deviceType_("unknown"), data(NULL)
RideFile::RideFile() : recIntSecs_(0.0), deviceType_("unknown"), data(NULL), weight_(0)
{
command = new RideFileCommand(this);
}
@@ -508,8 +508,6 @@ RideFilePoint::value(RideFile::SeriesType series) const
double
RideFile::getPointValue(int index, SeriesType series) const
{
if (series == wattsKg)
qDebug() << "wattsKg value";
return dataPoints_[index]->value(series);
}
@@ -634,37 +632,41 @@ RideFile::appendPoints(QVector <struct RideFilePoint *> newRows)
void
RideFile::emitSaved()
{
weight_ = 0;
emit saved();
}
void
RideFile::emitReverted()
{
weight_ = 0;
emit reverted();
}
void
RideFile::emitModified()
{
weight_ = 0;
emit modified();
}
double
RideFile::getWeight()
{
if (weight_) return weight_; // cached value
// ride
double weight;
if ((weight = getTag("Weight", "0.0").toDouble()) > 0) {
return weight;
if ((weight_ = getTag("Weight", "0.0").toDouble()) > 0) {
return weight_;
}
#if 0
// withings?
QList<SummaryMetrics> measures = mainwindow->metricDB->getAllMeasuresFor(QDateTime::fromString("Jan 1 00:00:00 1900"), startTime());
if (measures.count()) {
return measures.last().getText("Weight", "0.0").toDouble();
return weight_ = measures.last().getText("Weight", "0.0").toDouble();
}
#endif
// global options
return appsettings->cvalue(mainwindow->cyclist, GC_WEIGHT, "75.0").toString().toDouble(); // default to 75kg
return weight_ = appsettings->cvalue(mainwindow->cyclist, GC_WEIGHT, "75.0").toString().toDouble(); // default to 75kg
}

View File

@@ -194,6 +194,7 @@ class RideFile : public QObject // QObject to emit signals
QList<RideFileInterval> intervals_;
QMap<QString,QString> tags_;
EditorData *data;
double weight_; // cached to save calls to getWeight();
};
struct RideFilePoint