Skip to content

Commit 8848205

Browse files
committed
Reduce size by 1382 bytes (AVR)
1 parent 43d21d5 commit 8848205

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

Marlin/Configuration.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@
687687
*/
688688
#if ENABLED(MPCTEMP)
689689
//#define MPC_AUTOTUNE // Include a method to do MPC auto-tuning (~5664-5882 bytes of flash)
690-
//#define MPC_AUTOTUNE_FANCY // Include a fancier method to do MPC auto-tuning (~7120 bytes of flash)
690+
//#define MPC_AUTOTUNE_FANCY // Include a fancier method to do MPC auto-tuning (~5466 bytes of flash)
691691
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
692692
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)
693693

Marlin/src/module/temperature.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,19 @@ volatile bool Temperature::raw_temps_ready = false;
946946

947947
#define DEBUG_MPC_AUTOTUNE 1
948948

949+
millis_t Temperature::MPC_autotuner::curr_time_ms, Temperature::MPC_autotuner::next_report_ms;
950+
951+
celsius_float_t Temperature::MPC_autotuner::temp_samples[16];
952+
uint8_t Temperature::MPC_autotuner::sample_count;
953+
uint16_t Temperature::MPC_autotuner::sample_distance;
954+
955+
// Parameters from differential analysis
956+
celsius_float_t Temperature::MPC_autotuner::temp_fastest;
957+
958+
#if HAS_FAN
959+
float Temperature::MPC_autotuner::power_fan255;
960+
#endif
961+
949962
Temperature::MPC_autotuner::MPC_autotuner(const uint8_t extruderIdx) : e(extruderIdx) {
950963
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = false);
951964
}
@@ -973,7 +986,7 @@ volatile bool Temperature::raw_temps_ready = false;
973986
millis_t next_test_ms = curr_time_ms + test_interval_ms;
974987
ambient_temp = current_temp = degHotend(e);
975988
wait_for_heatup = true;
976-
989+
977990
for (;;) { // Can be interrupted with M108
978991
if (housekeeping() == CANCELLED) return CANCELLED;
979992

Marlin/src/module/temperature.h

+14-13
Original file line numberDiff line numberDiff line change
@@ -1234,41 +1234,42 @@ class Temperature {
12341234

12351235
float get_elapsed_heating_time() { return elapsed_heating_time; }
12361236
float get_sample_1_time() { return t1_time; }
1237-
float get_sample_1_temp() { return temp_samples[0]; }
1238-
float get_sample_2_temp() { return temp_samples[(sample_count - 1) >> 1]; }
1239-
float get_sample_3_temp() { return temp_samples[sample_count - 1]; }
1240-
float get_sample_interval() { return sample_distance * (sample_count >> 1); }
1237+
static float get_sample_1_temp() { return temp_samples[0]; }
1238+
static float get_sample_2_temp() { return temp_samples[(sample_count - 1) >> 1]; }
1239+
static float get_sample_3_temp() { return temp_samples[sample_count - 1]; }
1240+
static float get_sample_interval() { return sample_distance * (sample_count >> 1); }
12411241

1242-
celsius_float_t get_temp_fastest() { return temp_fastest; }
1242+
static celsius_float_t get_temp_fastest() { return temp_fastest; }
12431243
float get_time_fastest() { return time_fastest; }
12441244
float get_rate_fastest() { return rate_fastest; }
12451245

12461246
float get_power_fan0() { return power_fan0; }
12471247
#if HAS_FAN
1248-
float get_power_fan255() { return power_fan255; }
1248+
static float get_power_fan255() { return power_fan255; }
12491249
#endif
12501250

12511251
protected:
1252-
void init_timers() { curr_time_ms = next_report_ms = millis(); }
1252+
static void init_timers() { curr_time_ms = next_report_ms = millis(); }
12531253
MeasurementState housekeeping();
12541254

1255-
millis_t curr_time_ms, next_report_ms;
12561255
uint8_t e;
12571256

12581257
float elapsed_heating_time;
12591258
celsius_float_t ambient_temp, current_temp;
1260-
celsius_float_t temp_samples[16];
1261-
uint8_t sample_count;
1262-
uint16_t sample_distance;
12631259
float t1_time;
12641260

1261+
static millis_t curr_time_ms, next_report_ms;
1262+
static celsius_float_t temp_samples[16];
1263+
static uint8_t sample_count;
1264+
static uint16_t sample_distance;
1265+
12651266
// Parameters from differential analysis
1266-
celsius_float_t temp_fastest;
1267+
static celsius_float_t temp_fastest;
12671268
float time_fastest, rate_fastest;
12681269

12691270
float power_fan0;
12701271
#if HAS_FAN
1271-
float power_fan255;
1272+
static float power_fan255;
12721273
#endif
12731274
};
12741275

0 commit comments

Comments
 (0)