diff --git a/src/ANT.cpp b/src/ANT.cpp index 5dcf36ef1..8d03cb403 100644 --- a/src/ANT.cpp +++ b/src/ANT.cpp @@ -82,7 +82,7 @@ const ant_sensor_type_t ANT::ant_sensor_types[] = { // thread and is part of the GC architecture NOT related to the // hardware controller. // -ANT::ANT(QObject *parent, DeviceConfiguration *devConf) : QThread(parent) +ANT::ANT(QObject *parent, DeviceConfiguration *devConf) : QThread(parent), devConf(devConf) { // device status and settings Status=0; @@ -152,6 +152,15 @@ double ANT::channelValue(int channel) return antChannel[channel]->channelValue(); } +void ANT::setWheelRpm(float x) { + telemetry.setWheelRpm(x); + + // devConf will be NULL if we are are running the add device wizard + // we can default to the global setting + if (devConf) telemetry.setSpeed(x * (devConf->wheelSize/1000) * 60 / 1000); + else telemetry.setSpeed(x * (appsettings->value(NULL, GC_WHEELSIZE, 2100).toInt()/1000) * 60 / 1000); +} + /*====================================================================== * Main thread functions; start, stop etc *====================================================================*/ diff --git a/src/ANT.h b/src/ANT.h index 4b44786e7..57fd1be6f 100644 --- a/src/ANT.h +++ b/src/ANT.h @@ -334,10 +334,7 @@ public: void setCadence(float x) { telemetry.setCadence(x); } - void setWheelRpm(float x) { - telemetry.setWheelRpm(x); - telemetry.setSpeed(x * (appsettings->value(NULL, GC_WHEELSIZE, 2100).toInt()/1000) * 60 / 1000); - } + void setWheelRpm(float x); void setWatts(float x) { telemetry.setWatts(x); } @@ -356,6 +353,7 @@ private: int channels; // how many 4 or 8 ? depends upon the USB stick... // access to device file + DeviceConfiguration *devConf; QString deviceFilename; int baud; #ifdef WIN32 diff --git a/src/DeviceConfiguration.cpp b/src/DeviceConfiguration.cpp index 3fe33a793..d840b8de2 100644 --- a/src/DeviceConfiguration.cpp +++ b/src/DeviceConfiguration.cpp @@ -89,6 +89,7 @@ DeviceConfigurations::readConfig() configStr = QString("%1%2").arg(GC_DEV_WHEEL).arg(i+1); configVal = appsettings->value(NULL, configStr); Entry.wheelSize = configVal.toInt(); + if (Entry.wheelSize == 0) Entry.wheelSize = 2100; // default to 700C configStr = QString("%1%2").arg(GC_DEV_PROF).arg(i+1); configVal = appsettings->value(NULL, configStr);