Add Wheelsize Config

So we can calculate speed from wheelRPM when working
with ANT+ speed sensors in realtime.

The config screen is still ugly as hell, but there is
another bug raised to resolve that.

Fixes #529.
This commit is contained in:
Mark Liversedge
2012-01-14 15:38:01 +00:00
parent 0a6875df3b
commit 2c95b70696
5 changed files with 38 additions and 1 deletions

View File

@@ -70,6 +70,8 @@
#include <QDebug>
#include "Settings.h" // for wheel size config
// timeouts for read/write of serial port in ms
#define ANT_READTIMEOUT 1000
#define ANT_WRITETIMEOUT 2000
@@ -306,7 +308,7 @@ public:
}
void setWheelRpm(float x) {
telemetry.setWheelRpm(x);
telemetry.setSpeed(x * 2.1 * 60 / 1000); // XXX fixed wheel size needs fixing
telemetry.setSpeed(x * (appsettings->value(NULL, GC_WHEELSIZE, 2100).toInt()/1000) * 60 / 1000);
}
void setWatts(float x) {
telemetry.setWatts(x);

View File

@@ -157,6 +157,18 @@ void ConfigDialog::save_Clicked()
appsettings->setValue(GC_GARMIN_HWMARK, configPage->garminHWMarkedit->text().toInt());
appsettings->setValue(GC_GARMIN_SMARTRECORD, configPage->garminSmartRecord->checkState());
appsettings->setValue(GC_CRANKLENGTH, configPage->crankLengthCombo->currentText());
// save wheel size
int wheelSize;
switch (configPage->wheelSizeCombo->currentIndex()) {
default:
case 0: wheelSize = 2100 ; break;
case 1: wheelSize = 1960 ; break;
case 2: wheelSize = 1985 ; break;
case 3: wheelSize = 1750 ; break;
}
appsettings->setValue(GC_WHEELSIZE, wheelSize);
appsettings->setValue(GC_BIKESCOREDAYS, configPage->BSdaysEdit->text());
appsettings->setValue(GC_BIKESCOREMODE, configPage->bsModeCombo->currentText());
appsettings->setValue(GC_WORKOUTDIR, configPage->workoutDirectory->text());

View File

@@ -122,6 +122,23 @@ ConfigurationPage::ConfigurationPage(MainWindow *main) : main(main)
if(crankLength.toString() == "185")
crankLengthCombo->setCurrentIndex(10);
QLabel *wheelSizeLabel = new QLabel("Wheelsize:", this);
int wheelSize = appsettings->value(this, GC_WHEELSIZE, 2100).toInt();
wheelSizeCombo = new QComboBox();
wheelSizeCombo->addItem("Road/Cross (700C/622)"); // 2100mm
wheelSizeCombo->addItem("Tri/TT (650C)"); // 1960mm
wheelSizeCombo->addItem("Mountain (26\")"); // 1985mm
wheelSizeCombo->addItem("BMX (20\")"); // 1750mm
switch (wheelSize) {
default:
case 2100 : wheelSizeCombo->setCurrentIndex(0); break;
case 1960 : wheelSizeCombo->setCurrentIndex(1); break;
case 1985 : wheelSizeCombo->setCurrentIndex(2); break;
case 1750 : wheelSizeCombo->setCurrentIndex(3); break;
}
// garmin Smart Recording options
QVariant garminHWMark = appsettings->value(this, GC_GARMIN_HWMARK);
if (garminHWMark.isNull() || garminHWMark.toInt() == 0)
@@ -161,6 +178,9 @@ ConfigurationPage::ConfigurationPage(MainWindow *main) : main(main)
crankLengthLayout->addWidget(crankLengthLabel);
crankLengthLayout->addWidget(crankLengthCombo);
QHBoxLayout *wheelSizeLayout = new QHBoxLayout;
wheelSizeLayout->addWidget(wheelSizeLabel);
wheelSizeLayout->addWidget(wheelSizeCombo);
// BikeScore Estimate
QVariant BSdays = appsettings->value(this, GC_BIKESCOREDAYS);
@@ -208,6 +228,7 @@ ConfigurationPage::ConfigurationPage(MainWindow *main) : main(main)
configLayout->addLayout(garminLayout);
//SmartRecord);
configLayout->addLayout(crankLengthLayout);
configLayout->addLayout(wheelSizeLayout);
configLayout->addLayout(bsDaysLayout);
configLayout->addLayout(bsModeLayout);
configLayout->addLayout(workoutLayout);

View File

@@ -61,6 +61,7 @@ class ConfigurationPage : public QWidget
QComboBox *langCombo;
QComboBox *unitCombo;
QComboBox *crankLengthCombo;
QComboBox *wheelSizeCombo;
QCheckBox *allRidesAscending;
QCheckBox *garminSmartRecord;
QLineEdit *garminHWMarkedit;

View File

@@ -52,6 +52,7 @@
#define GC_AVATAR "avatar"
#define GC_SETTINGS_LAST_IMPORT_PATH "mainwindow/lastImportPath"
#define GC_CRANKLENGTH "crankLength"
#define GC_WHEELSIZE "wheelsize"
#define GC_BIKESCOREDAYS "bikeScoreDays"
#define GC_BIKESCOREMODE "bikeScoreMode"
#define GC_SB_TODAY "PMshowSBtoday"