Compare commits

...

1 Commits

Author SHA1 Message Date
Roberto Viola
8ffafc76e0 Revert "Revert "Peloton Rowing with Concept 2 #1481""
This reverts commit 54799c3519.
2023-06-13 21:49:30 +02:00
5 changed files with 60 additions and 5 deletions

View File

@@ -3277,7 +3277,7 @@ void homeform::update() {
double verticalOscillation = 0;
bool miles = settings.value(QZSettings::miles_unit, QZSettings::default_miles_unit).toBool();
double ftpSetting = settings.value(QZSettings::ftp, QZSettings::default_ftp).toDouble();
double ftpSetting = ftpValue(bluetoothManager->device());
double unit_conversion = 1.0;
double meter_feet_conversion = 1.0;
double cm_inches_conversion = 1.0;

View File

@@ -201,6 +201,15 @@ class homeform : public QObject {
});
}
double ftpValue(bluetoothdevice* bluetoothDevice) {
QSettings settings;
double ftpSetting = settings.value(QZSettings::ftp, QZSettings::default_ftp).toDouble();
if(bluetoothDevice && bluetoothDevice->deviceType() == bluetoothdevice::ROWING) {
return settings.value(QZSettings::ftp_row, QZSettings::default_ftp_row).toDouble();
}
return ftpSetting;
}
Q_INVOKABLE void update_chart_power(QQuickItem *item) {
if (QGraphicsScene *scene = item->findChild<QGraphicsScene *>()) {
auto items_list = scene->items();
@@ -210,7 +219,7 @@ class homeform : public QObject {
QLinearGradient backgroundGradient;
double maxWatt = wattMaxChart();
QSettings settings;
double ftpSetting = settings.value(QZSettings::ftp, QZSettings::default_ftp).toDouble();
double ftpSetting = ftpValue(bluetoothManager->device());
/*backgroundGradient.setStart(QPointF(0, 0));
backgroundGradient.setFinalStop(QPointF(0, 1));
backgroundGradient.setColorAt((maxWatt - (ftpSetting * 0.55)) / maxWatt, QColor("white"));
@@ -432,10 +441,10 @@ class homeform : public QObject {
QSettings settings;
if (bluetoothManager && bluetoothManager->device() &&
bluetoothManager->device()->wattsMetric().max() >
(settings.value(QZSettings::ftp, QZSettings::default_ftp).toDouble() * 2)) {
(ftpValue(bluetoothManager->device()) * 2)) {
return bluetoothManager->device()->wattsMetric().max();
} else {
return settings.value(QZSettings::ftp, QZSettings::default_ftp).toDouble() * 2;
return ftpValue(bluetoothManager->device()) * 2;
}
}

View File

@@ -658,8 +658,9 @@ const QString QZSettings::csafe_rower = QStringLiteral("csafe_rower");
const QString QZSettings::default_csafe_rower = QStringLiteral("");
const QString QZSettings::ftms_rower = QStringLiteral("ftms_rower");
const QString QZSettings::default_ftms_rower = QStringLiteral("Disabled");
const QString QZSettings::ftp_row = QStringLiteral("ftp_row");
const uint32_t allSettingsCount = 550;
const uint32_t allSettingsCount = 551;
QVariant allSettings[allSettingsCount][2] = {
{QZSettings::cryptoKeySettingsProfiles, QZSettings::default_cryptoKeySettingsProfiles},
{QZSettings::bluetooth_no_reconnection, QZSettings::default_bluetooth_no_reconnection},
@@ -1215,6 +1216,7 @@ QVariant allSettings[allSettingsCount][2] = {
{QZSettings::tts_act_target_pace, QZSettings::default_tts_act_target_pace},
{QZSettings::csafe_rower, QZSettings::default_csafe_rower},
{QZSettings::ftms_rower, QZSettings::default_ftms_rower},
{QZSettings::ftp_row, QZSettings::default_ftp_row},
};
void QZSettings::qDebugAllSettings(bool showDefaults) {

View File

@@ -1845,6 +1845,9 @@ class QZSettings {
static const QString ftms_rower;
static const QString default_ftms_rower;
static const QString ftp_row;
static constexpr float default_ftp_row = 100.0;
/**
* @brief Write the QSettings values using the constants from this namespace.
* @param showDefaults Optionally indicates if the default should be shown with the key.

View File

@@ -794,6 +794,9 @@ import QtQuick.Dialogs 1.0
// from version 2.13.71
property int theme_tile_secondline_textsize: 12
// from version 2.13.75
property real ftp_row: 100.0
}
function paddingZeros(text, limit) {
@@ -6225,6 +6228,44 @@ import QtQuick.Dialogs 1.0
color: Material.backgroundColor
accordionContent: ColumnLayout {
spacing: 0
RowLayout {
spacing: 10
Label {
text: qsTr("FTP value:")
Layout.fillWidth: true
}
TextField {
id: ftpRowTextField
text: settings.ftp_row
horizontalAlignment: Text.AlignRight
Layout.fillHeight: false
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
inputMethodHints: Qt.ImhDigitsOnly
onAccepted: settings.ftp_row = text
onActiveFocusChanged: if(this.focus) this.cursorPosition = this.text.length
}
Button {
text: "OK"
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
onClicked: { settings.ftp_row = ftpRowTextField.text; toast.show("Setting saved!"); }
}
}
Label {
text: qsTr("If you train to specific output (or watts) levels, for example in Peloton Power Zone classes,and have taken an FTP test (Functional Threshold Power), enter your FTP here. This number is used to calculate your Power Zones (Zones 1 to 7 for Peloton and 1 to 6 for Zwift).")
font.bold: true
font.italic: true
font.pixelSize: 9
textFormat: Text.PlainText
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
color: Material.color(Material.Lime)
}
AccordionElement {
title: qsTr("PM3, PM4 Options")
indicatRectColor: Material.color(Material.Grey)