From ad5cf062bd682ac5ed82c1aa9781d5fffa3dce6c Mon Sep 17 00:00:00 2001 From: jussi Date: Sun, 3 Feb 2019 20:44:03 +0200 Subject: [PATCH 1/2] fix custom fan mode --- mainwindow.cpp | 16 +++++++++++----- nvidia.cpp | 12 ------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index b43b44e..304d07f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -92,6 +92,9 @@ MainWindow::MainWindow(QWidget *parent) : ui->fanSlider->setDisabled(true); ui->fanSpinBox->setDisabled(true); } + if (nv->GPUList[currentGPUIndex].fanControlMode == 2) { + connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(tempUpdater())); + } if (!nv->GPUList[currentGPUIndex].manualFanCtrlAvailable) { // If manual fan control is not available for the GPU, disable the option QStandardItemModel *model = qobject_cast(ui->fanModeComboBox->model()); @@ -603,6 +606,8 @@ void MainWindow::fanSpeedUpdater() void MainWindow::tempUpdater() { nv->queryGPUTemp(currentGPUIndex); + qDebug() << "updating temp"; + qDebug() << xCurvePoints << yCurvePoints; if (xCurvePoints.size() != 0) { generateFanPoint(); } @@ -789,6 +794,7 @@ void MainWindow::applyGPUSettings() connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(tempUpdater())); ui->fanSlider->setEnabled(false); ui->fanSpinBox->setEnabled(false); + fanUpdateTimer->start(2000); settings.setValue("fanControlMode", 2); } else { errorText.append("- Fan mode"); @@ -932,15 +938,15 @@ void MainWindow::generateFanPoint() // Calculate the value for fan speed based on temperature // First check if the fan speed should be y[0] or y[final] int index = 0; - if (temp <= xCurvePoints[0]) { + if (nv->GPUList[currentGPUIndex].temp <= xCurvePoints[0]) { targetFanSpeed = yCurvePoints[0]; } - if (temp >= xCurvePoints[xCurvePoints.size()-1]) { + if (nv->GPUList[currentGPUIndex].temp >= xCurvePoints[xCurvePoints.size()-1]) { targetFanSpeed = yCurvePoints[yCurvePoints.size()-1]; } else { // Get the index of the leftmost point of the interpolated interval by comparing it to temperature for (int i=0; i= xCurvePoints[i] && temp <= xCurvePoints[i+1]) { + if (nv->GPUList[currentGPUIndex].temp >= xCurvePoints[i] && nv->GPUList[currentGPUIndex].temp <= xCurvePoints[i+1]) { index = i; break; } @@ -949,10 +955,10 @@ void MainWindow::generateFanPoint() if (xCurvePoints[index] - xCurvePoints[index + 1] == 0) { targetFanSpeed = yCurvePoints[index+1]; } else { - targetFanSpeed = (((yCurvePoints[index + 1] - yCurvePoints[index]) * (temp - xCurvePoints[index])) / (xCurvePoints[index + 1] - xCurvePoints[index])) + yCurvePoints[index]; + targetFanSpeed = (((yCurvePoints[index + 1] - yCurvePoints[index]) * (nv->GPUList[currentGPUIndex].temp - xCurvePoints[index])) / (xCurvePoints[index + 1] - xCurvePoints[index])) + yCurvePoints[index]; } } - + qDebug() << "target fan speed is" << targetFanSpeed; nv->assignGPUFanSpeed(currentGPUIndex, targetFanSpeed); } void MainWindow::on_frequencySlider_valueChanged(int value) diff --git a/nvidia.cpp b/nvidia.cpp index b1cb039..fdba06b 100644 --- a/nvidia.cpp +++ b/nvidia.cpp @@ -171,17 +171,6 @@ void nvidia::queryGPUFeatures() &GPUList[i].totalVRAM); qDebug() << GPUList[i].totalVRAM << "vram"; } - - //queryGPUVoltage(0); - //queryGPUTemp(0); - //queryGPUFrequencies(0); - //queryGPUFanSpeed(0); - //queryGPUUsedVRAM(0); - //assignGPUFanSpeed(0, 60); - //assignGPUFreqOffset(0, 10); - //assignGPUMemClockOffset(0, 10); - //assignGPUVoltageOffset(0, 5000); - //assignGPUFanCtlMode(0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); } void nvidia::queryGPUVoltage(int GPUIndex) { @@ -241,7 +230,6 @@ void nvidia::queryGPUFanSpeed(int GPUIndex) NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL, &GPUList[GPUIndex].fanSpeed); - //qDebug() << GPUList[GPUIndex].fanSpeed; } void nvidia::queryGPUUsedVRAM(int GPUIndex) { From 83f1918175cacb2e643e22652a3d2313f605c753 Mon Sep 17 00:00:00 2001 From: jussi Date: Sun, 3 Feb 2019 21:25:50 +0200 Subject: [PATCH 2/2] fix interpolation --- mainwindow.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 304d07f..97f8fb4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -92,9 +92,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->fanSlider->setDisabled(true); ui->fanSpinBox->setDisabled(true); } - if (nv->GPUList[currentGPUIndex].fanControlMode == 2) { - connect(fanUpdateTimer, SIGNAL(timeout()), this, SLOT(tempUpdater())); - } + if (!nv->GPUList[currentGPUIndex].manualFanCtrlAvailable) { // If manual fan control is not available for the GPU, disable the option QStandardItemModel *model = qobject_cast(ui->fanModeComboBox->model()); @@ -941,7 +939,7 @@ void MainWindow::generateFanPoint() if (nv->GPUList[currentGPUIndex].temp <= xCurvePoints[0]) { targetFanSpeed = yCurvePoints[0]; } - if (nv->GPUList[currentGPUIndex].temp >= xCurvePoints[xCurvePoints.size()-1]) { + else if (nv->GPUList[currentGPUIndex].temp >= xCurvePoints[xCurvePoints.size()-1]) { targetFanSpeed = yCurvePoints[yCurvePoints.size()-1]; } else { // Get the index of the leftmost point of the interpolated interval by comparing it to temperature