From 32ec4fa38c044fb9809f6b1ce867119831b7ae35 Mon Sep 17 00:00:00 2001 From: Andrea Baccega Date: Sun, 28 Jan 2024 18:31:24 +0100 Subject: [PATCH] Refactor drawReflowTargetTempLine() method and update startTemps[0] in reflow.h --- src/displays/tft.cpp | 4 ++-- src/reflow.h | 14 +++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/displays/tft.cpp b/src/displays/tft.cpp index cce6cc7..6669bff 100644 --- a/src/displays/tft.cpp +++ b/src/displays/tft.cpp @@ -342,13 +342,13 @@ void TFT_Display::drawGraphReflowStagesBackground() void TFT_Display::drawReflowTargetTempLine() { - uint16_t y = tempYonGraph(20); + uint16_t y = tempYonGraph(chosenReflowProfile.startTemps[0]); uint16_t x = percentageToX(0); for (float i=0.00; i<=1; i+=0.01) { float temp = profile->getTargetTempFromPercentage(i); uint16_t y2 = tempYonGraph(temp); uint16_t x2 = percentageToX(i); - Serial.println(String(i) + " - temp: "+ String(temp) + " - x:" + String(x) + " y:" + String(y) + " x2:" + String(x2) + " y2:" + String(y2)); + // Serial.println(String(i) + " - temp: "+ String(temp) + " - x:" + String(x) + " y:" + String(y) + " x2:" + String(x2) + " y2:" + String(y2)); tft.drawLine(x, y, x2, y2, ST77XX_WHITE); x = x2; y = y2; diff --git a/src/reflow.h b/src/reflow.h index f0008ad..fc1ef4a 100644 --- a/src/reflow.h +++ b/src/reflow.h @@ -119,7 +119,7 @@ public: startTimes[3] = endTimes[2]; startTimes[4] = endTimes[3]; - startTemps[0] = 20; + startTemps[0] = 20; // USe ambient temp as the starting temp for the first step endTemps[0] = steps[0].calcTempAtPercentage(startTemps[0], 1); endTemps[1] = steps[1].calcTempAtPercentage(endTemps[0], 1); @@ -163,27 +163,19 @@ public: { if (!timer.isRunning()) { - return 20; + return startTemps[0]; } return getTargetTemp(timer.elapsed()); } float getTargetTemp(uint32_t elapsedMS) { - uint8_t startTemp = 20; // always assume 20 degrees at the start - ReflowStep curStep = reflowStep(elapsedMS); - if (curStep.state > PREHEAT) - { - startTemp = endTemps[STEPINDEX(curStep) - 1]; - } - - // startTemp => 20 or the temp at 100% of the previous step uint32_t startTimeMS = TOMILLIS(startTimes[STEPINDEX(curStep)]); uint32_t relativeElapsedTime = elapsedMS - startTimeMS; float stepPercentage = relativeElapsedTime / (double)TOMILLIS(curStep.duration); - return curStep.calcTempAtPercentage(startTemp, stepPercentage); + return curStep.calcTempAtPercentage(startTemps[STEPINDEX(curStep)], stepPercentage); } /**