Explorar el Código

TM: Move initial R0 initialization closer to usage

Yuri D'Elia hace 2 años
padre
commit
54e5702f30
Se han modificado 1 ficheros con 4 adiciones y 4 borrados
  1. 4 4
      Firmware/temperature.cpp

+ 4 - 4
Firmware/temperature.cpp

@@ -2768,16 +2768,16 @@ static bool autotune(int16_t cal_temp)
             wait(10000);
         }
 
-        // we need a valid R value for the initial C guess
-        if(isnan(temp_model::data.R[0]))
-            temp_model::data.R[0] = TEMP_MODEL_Rh;
-
         printf_P(PSTR("TM: %S C estimation\n"), verb);
         target_temperature[0] = cal_temp;
         samples = record();
         if(temp_error_state.v || !samples)
             return true;
 
+        // we need a high R value for the initial C guess
+        if(isnan(temp_model::data.R[0]))
+            temp_model::data.R[0] = TEMP_MODEL_Rh;
+
         e = estimate(samples, &temp_model::data.C,
             TEMP_MODEL_Cl, TEMP_MODEL_Ch, TEMP_MODEL_C_thr, TEMP_MODEL_C_itr,
             0, current_temperature_ambient);