Browse Source

Merge pull request #3924 from thinkyhead/rc_statics_temperature

Apply static to Temperature class
Scott Lahteine 8 years ago
parent
commit
3fd9b331f0
2 changed files with 255 additions and 130 deletions
  1. 154
    27
      Marlin/temperature.cpp
  2. 101
    103
      Marlin/temperature.h

+ 154
- 27
Marlin/temperature.cpp View File

48
 
48
 
49
 Temperature thermalManager;
49
 Temperature thermalManager;
50
 
50
 
51
+// public:
52
+
53
+int Temperature::current_temperature_raw[EXTRUDERS] = { 0 };
54
+float Temperature::current_temperature[EXTRUDERS] = { 0.0 };
55
+int Temperature::target_temperature[EXTRUDERS] = { 0 };
56
+
57
+int Temperature::current_temperature_bed_raw = 0;
58
+float Temperature::current_temperature_bed = 0.0;
59
+int Temperature::target_temperature_bed = 0;
60
+
61
+#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
62
+  float Temperature::redundant_temperature = 0.0;
63
+#endif
64
+
65
+unsigned char Temperature::soft_pwm_bed;
66
+
67
+#if ENABLED(FAN_SOFT_PWM)
68
+  unsigned char Temperature::fanSpeedSoftPwm[FAN_COUNT];
69
+#endif
70
+
71
+#if ENABLED(PIDTEMP)
72
+  #if ENABLED(PID_PARAMS_PER_EXTRUDER)
73
+    float Temperature::Kp[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Kp),
74
+          Temperature::Ki[EXTRUDERS] = ARRAY_BY_EXTRUDERS1((DEFAULT_Ki) * (PID_dT)),
75
+          Temperature::Kd[EXTRUDERS] = ARRAY_BY_EXTRUDERS1((DEFAULT_Kd) / (PID_dT));
76
+    #if ENABLED(PID_ADD_EXTRUSION_RATE)
77
+      float Temperature::Kc[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Kc);
78
+    #endif
79
+  #else
80
+    float Temperature::Kp = DEFAULT_Kp,
81
+          Temperature::Ki = (DEFAULT_Ki) * (PID_dT),
82
+          Temperature::Kd = (DEFAULT_Kd) / (PID_dT);
83
+    #if ENABLED(PID_ADD_EXTRUSION_RATE)
84
+      float Temperature::Kc = DEFAULT_Kc;
85
+    #endif
86
+  #endif
87
+#endif
88
+
89
+#if ENABLED(PIDTEMPBED)
90
+  float Temperature::bedKp = DEFAULT_bedKp,
91
+        Temperature::bedKi = ((DEFAULT_bedKi) * PID_dT),
92
+        Temperature::bedKd = ((DEFAULT_bedKd) / PID_dT);
93
+#endif
94
+
95
+#if ENABLED(BABYSTEPPING)
96
+  volatile int Temperature::babystepsTodo[3] = { 0 };
97
+#endif
98
+
99
+#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
100
+  int Temperature::watch_target_temp[EXTRUDERS] = { 0 };
101
+  millis_t Temperature::watch_heater_next_ms[EXTRUDERS] = { 0 };
102
+#endif
103
+
104
+#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_BED_TEMP_PERIOD > 0
105
+  int Temperature::watch_target_bed_temp = 0;
106
+  millis_t Temperature::watch_bed_next_ms = 0;
107
+#endif
108
+
109
+#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
110
+  float Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
111
+#endif
112
+
113
+// private:
114
+
115
+#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
116
+  int Temperature::redundant_temperature_raw = 0;
117
+  float Temperature::redundant_temperature = 0.0;
118
+#endif
119
+
120
+volatile bool Temperature::temp_meas_ready = false;
121
+
122
+#if ENABLED(PIDTEMP)
123
+  float Temperature::temp_iState[EXTRUDERS] = { 0 };
124
+  float Temperature::temp_dState[EXTRUDERS] = { 0 };
125
+  float Temperature::pTerm[EXTRUDERS];
126
+  float Temperature::iTerm[EXTRUDERS];
127
+  float Temperature::dTerm[EXTRUDERS];
128
+
129
+  #if ENABLED(PID_ADD_EXTRUSION_RATE)
130
+    float Temperature::cTerm[EXTRUDERS];
131
+    long Temperature::last_position[EXTRUDERS];
132
+    long Temperature::lpq[LPQ_MAX_LEN];
133
+    int Temperature::lpq_ptr = 0;
134
+  #endif
135
+
136
+  float Temperature::pid_error[EXTRUDERS];
137
+  float Temperature::temp_iState_min[EXTRUDERS];
138
+  float Temperature::temp_iState_max[EXTRUDERS];
139
+  bool Temperature::pid_reset[EXTRUDERS];
140
+#endif
141
+
142
+#if ENABLED(PIDTEMPBED)
143
+  float Temperature::temp_iState_bed = { 0 };
144
+  float Temperature::temp_dState_bed = { 0 };
145
+  float Temperature::pTerm_bed;
146
+  float Temperature::iTerm_bed;
147
+  float Temperature::dTerm_bed;
148
+  float Temperature::pid_error_bed;
149
+  float Temperature::temp_iState_min_bed;
150
+  float Temperature::temp_iState_max_bed;
151
+#else
152
+  millis_t Temperature::next_bed_check_ms;
153
+#endif
154
+
155
+unsigned long Temperature::raw_temp_value[4] = { 0 };
156
+unsigned long Temperature::raw_temp_bed_value = 0;
157
+
158
+// Init min and max temp with extreme values to prevent false errors during startup
159
+int Temperature::minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
160
+int Temperature::maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
161
+int Temperature::minttemp[EXTRUDERS] = { 0 };
162
+int Temperature::maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(16383);
163
+
164
+#ifdef BED_MINTEMP
165
+  int Temperature::bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP;
166
+#endif
167
+
168
+#ifdef BED_MAXTEMP
169
+  int Temperature::bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
170
+#endif
171
+
172
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
173
+  int Temperature::meas_shift_index;  // Index of a delayed sample in buffer
174
+#endif
175
+
176
+#if HAS_AUTO_FAN
177
+  millis_t Temperature::next_auto_fan_check_ms;
178
+#endif
179
+
180
+unsigned char Temperature::soft_pwm[EXTRUDERS];
181
+
182
+#if ENABLED(FAN_SOFT_PWM)
183
+  unsigned char Temperature::soft_pwm_fan[FAN_COUNT];
184
+#endif
185
+
186
+#if ENABLED(FILAMENT_WIDTH_SENSOR)
187
+  int Temperature::current_raw_filwidth = 0;  //Holds measured filament diameter - one extruder only
188
+#endif
189
+
51
 #if HAS_PID_HEATING
190
 #if HAS_PID_HEATING
52
 
191
 
53
   void Temperature::PID_autotune(float temp, int extruder, int ncycles, bool set_result/*=false*/) {
192
   void Temperature::PID_autotune(float temp, int extruder, int ncycles, bool set_result/*=false*/) {
283
 
422
 
284
 #endif // HAS_PID_HEATING
423
 #endif // HAS_PID_HEATING
285
 
424
 
286
-#if ENABLED(PIDTEMP)
287
-
288
-  #if ENABLED(PID_PARAMS_PER_EXTRUDER)
289
-
290
-    float Temperature::Kp[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Kp),
291
-          Temperature::Ki[EXTRUDERS] = ARRAY_BY_EXTRUDERS1((DEFAULT_Ki) * (PID_dT)),
292
-          Temperature::Kd[EXTRUDERS] = ARRAY_BY_EXTRUDERS1((DEFAULT_Kd) / (PID_dT));
293
-
294
-    #if ENABLED(PID_ADD_EXTRUSION_RATE)
295
-      float Temperature::Kc[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Kc);
296
-    #endif
297
-
298
-  #else
299
-
300
-    float Temperature::Kp = DEFAULT_Kp,
301
-          Temperature::Ki = (DEFAULT_Ki) * (PID_dT),
302
-          Temperature::Kd = (DEFAULT_Kd) / (PID_dT);
303
-
304
-    #if ENABLED(PID_ADD_EXTRUSION_RATE)
305
-      float Temperature::Kc = DEFAULT_Kc;
306
-    #endif
307
-
308
-  #endif
309
-
310
-#endif
425
+/**
426
+ * Class and Instance Methods
427
+ */
311
 
428
 
312
 Temperature::Temperature() { }
429
 Temperature::Temperature() { }
313
 
430
 
1045
 
1162
 
1046
 #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
1163
 #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
1047
 
1164
 
1048
-  void Temperature::thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
1165
+  #if ENABLED(THERMAL_PROTECTION_HOTENDS)
1166
+    Temperature::TRState Temperature::thermal_runaway_state_machine[EXTRUDERS] = { TRInactive };
1167
+    millis_t Temperature::thermal_runaway_timer[EXTRUDERS] = { 0 };
1168
+  #endif
1169
+
1170
+  #if HAS_THERMALLY_PROTECTED_BED
1171
+    Temperature::TRState Temperature::thermal_runaway_bed_state_machine = TRInactive;
1172
+    millis_t Temperature::thermal_runaway_bed_timer;
1173
+  #endif
1174
+
1175
+  void Temperature::thermal_runaway_protection(Temperature::TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
1049
 
1176
 
1050
     static float tr_target_temperature[EXTRUDERS + 1] = { 0.0 };
1177
     static float tr_target_temperature[EXTRUDERS + 1] = { 0.0 };
1051
 
1178
 
1242
  *  - Check new temperature values for MIN/MAX errors
1369
  *  - Check new temperature values for MIN/MAX errors
1243
  *  - Step the babysteps value for each axis towards 0
1370
  *  - Step the babysteps value for each axis towards 0
1244
  */
1371
  */
1245
-ISR(TIMER0_COMPB_vect) { thermalManager.isr(); }
1372
+ISR(TIMER0_COMPB_vect) { Temperature::isr(); }
1246
 
1373
 
1247
 void Temperature::isr() {
1374
 void Temperature::isr() {
1248
 
1375
 

+ 101
- 103
Marlin/temperature.h View File

42
 
42
 
43
   public:
43
   public:
44
 
44
 
45
-    int current_temperature_raw[EXTRUDERS] = { 0 };
46
-    float current_temperature[EXTRUDERS] = { 0.0 };
47
-    int target_temperature[EXTRUDERS] = { 0 };
45
+    static int current_temperature_raw[EXTRUDERS];
46
+    static float current_temperature[EXTRUDERS];
47
+    static int target_temperature[EXTRUDERS];
48
 
48
 
49
-    int current_temperature_bed_raw = 0;
50
-    float current_temperature_bed = 0.0;
51
-    int target_temperature_bed = 0;
49
+    static int current_temperature_bed_raw;
50
+    static float current_temperature_bed;
51
+    static int target_temperature_bed;
52
 
52
 
53
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
53
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
54
-      float redundant_temperature = 0.0;
54
+      static float redundant_temperature;
55
     #endif
55
     #endif
56
 
56
 
57
-    unsigned char soft_pwm_bed;
57
+    static unsigned char soft_pwm_bed;
58
 
58
 
59
     #if ENABLED(FAN_SOFT_PWM)
59
     #if ENABLED(FAN_SOFT_PWM)
60
-      unsigned char fanSpeedSoftPwm[FAN_COUNT];
60
+      static unsigned char fanSpeedSoftPwm[FAN_COUNT];
61
     #endif
61
     #endif
62
 
62
 
63
     #if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
63
     #if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
70
 
70
 
71
         static float Kp[EXTRUDERS], Ki[EXTRUDERS], Kd[EXTRUDERS];
71
         static float Kp[EXTRUDERS], Ki[EXTRUDERS], Kd[EXTRUDERS];
72
         #if ENABLED(PID_ADD_EXTRUSION_RATE)
72
         #if ENABLED(PID_ADD_EXTRUSION_RATE)
73
-          float Kc[EXTRUDERS];
73
+          static float Kc[EXTRUDERS];
74
         #endif
74
         #endif
75
         #define PID_PARAM(param, e) Temperature::param[e]
75
         #define PID_PARAM(param, e) Temperature::param[e]
76
 
76
 
93
     #endif
93
     #endif
94
 
94
 
95
     #if ENABLED(PIDTEMPBED)
95
     #if ENABLED(PIDTEMPBED)
96
-      float bedKp = DEFAULT_bedKp,
97
-            bedKi = ((DEFAULT_bedKi) * PID_dT),
98
-            bedKd = ((DEFAULT_bedKd) / PID_dT);
96
+      static float bedKp, bedKi, bedKd;
99
     #endif
97
     #endif
100
 
98
 
101
     #if ENABLED(BABYSTEPPING)
99
     #if ENABLED(BABYSTEPPING)
102
-      volatile int babystepsTodo[3] = { 0 };
100
+      static volatile int babystepsTodo[3];
103
     #endif
101
     #endif
104
 
102
 
105
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
103
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
106
-      int watch_target_temp[EXTRUDERS] = { 0 };
107
-      millis_t watch_heater_next_ms[EXTRUDERS] = { 0 };
104
+      static int watch_target_temp[EXTRUDERS];
105
+      static millis_t watch_heater_next_ms[EXTRUDERS];
108
     #endif
106
     #endif
109
 
107
 
110
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_BED_TEMP_PERIOD > 0
108
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_BED_TEMP_PERIOD > 0
111
-      int watch_target_bed_temp = 0;
112
-      millis_t watch_bed_next_ms = 0;
109
+      static int watch_target_bed_temp;
110
+      static millis_t watch_bed_next_ms;
113
     #endif
111
     #endif
114
 
112
 
115
     #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
113
     #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
116
-      float extrude_min_temp = EXTRUDE_MINTEMP;
117
-      FORCE_INLINE bool tooColdToExtrude(uint8_t e) { return degHotend(e) < extrude_min_temp; }
114
+      static float extrude_min_temp;
115
+      static bool tooColdToExtrude(uint8_t e) { return degHotend(e) < extrude_min_temp; }
118
     #else
116
     #else
119
-      FORCE_INLINE bool tooColdToExtrude(uint8_t e) { UNUSED(e); return false; }
117
+      static bool tooColdToExtrude(uint8_t e) { UNUSED(e); return false; }
120
     #endif
118
     #endif
121
 
119
 
122
   private:
120
   private:
123
 
121
 
124
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
122
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
125
-      int redundant_temperature_raw = 0;
126
-      float redundant_temperature = 0.0;
123
+      static int redundant_temperature_raw;
124
+      static float redundant_temperature;
127
     #endif
125
     #endif
128
 
126
 
129
-    volatile bool temp_meas_ready = false;
127
+    static volatile bool temp_meas_ready;
130
 
128
 
131
     #if ENABLED(PIDTEMP)
129
     #if ENABLED(PIDTEMP)
132
-      float temp_iState[EXTRUDERS] = { 0 };
133
-      float temp_dState[EXTRUDERS] = { 0 };
134
-      float pTerm[EXTRUDERS];
135
-      float iTerm[EXTRUDERS];
136
-      float dTerm[EXTRUDERS];
130
+      static float temp_iState[EXTRUDERS];
131
+      static float temp_dState[EXTRUDERS];
132
+      static float pTerm[EXTRUDERS];
133
+      static float iTerm[EXTRUDERS];
134
+      static float dTerm[EXTRUDERS];
137
 
135
 
138
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
136
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
139
-        float cTerm[EXTRUDERS];
140
-        long last_position[EXTRUDERS];
141
-        long lpq[LPQ_MAX_LEN];
142
-        int lpq_ptr = 0;
137
+        static float cTerm[EXTRUDERS];
138
+        static long last_position[EXTRUDERS];
139
+        static long lpq[LPQ_MAX_LEN];
140
+        static int lpq_ptr;
143
       #endif
141
       #endif
144
 
142
 
145
-      float pid_error[EXTRUDERS];
146
-      float temp_iState_min[EXTRUDERS];
147
-      float temp_iState_max[EXTRUDERS];
148
-      bool pid_reset[EXTRUDERS];
143
+      static float pid_error[EXTRUDERS];
144
+      static float temp_iState_min[EXTRUDERS];
145
+      static float temp_iState_max[EXTRUDERS];
146
+      static bool pid_reset[EXTRUDERS];
149
     #endif
147
     #endif
150
 
148
 
151
     #if ENABLED(PIDTEMPBED)
149
     #if ENABLED(PIDTEMPBED)
152
-      float temp_iState_bed = { 0 };
153
-      float temp_dState_bed = { 0 };
154
-      float pTerm_bed;
155
-      float iTerm_bed;
156
-      float dTerm_bed;
157
-      float pid_error_bed;
158
-      float temp_iState_min_bed;
159
-      float temp_iState_max_bed;
150
+      static float temp_iState_bed;
151
+      static float temp_dState_bed;
152
+      static float pTerm_bed;
153
+      static float iTerm_bed;
154
+      static float dTerm_bed;
155
+      static float pid_error_bed;
156
+      static float temp_iState_min_bed;
157
+      static float temp_iState_max_bed;
160
     #else
158
     #else
161
-      millis_t next_bed_check_ms;
159
+      static millis_t next_bed_check_ms;
162
     #endif
160
     #endif
163
 
161
 
164
-    unsigned long raw_temp_value[4] = { 0 };
165
-    unsigned long raw_temp_bed_value = 0;
162
+    static unsigned long raw_temp_value[4];
163
+    static unsigned long raw_temp_bed_value;
166
 
164
 
167
     // Init min and max temp with extreme values to prevent false errors during startup
165
     // Init min and max temp with extreme values to prevent false errors during startup
168
-    int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
169
-    int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
170
-    int minttemp[EXTRUDERS] = { 0 };
171
-    int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(16383);
166
+    static int minttemp_raw[EXTRUDERS];
167
+    static int maxttemp_raw[EXTRUDERS];
168
+    static int minttemp[EXTRUDERS];
169
+    static int maxttemp[EXTRUDERS];
172
 
170
 
173
     #ifdef BED_MINTEMP
171
     #ifdef BED_MINTEMP
174
-      int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP;
172
+      static int bed_minttemp_raw;
175
     #endif
173
     #endif
176
 
174
 
177
     #ifdef BED_MAXTEMP
175
     #ifdef BED_MAXTEMP
178
-      int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
176
+      static int bed_maxttemp_raw;
179
     #endif
177
     #endif
180
 
178
 
181
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
179
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
182
-      int meas_shift_index;  // Index of a delayed sample in buffer
180
+      static int meas_shift_index;  // Index of a delayed sample in buffer
183
     #endif
181
     #endif
184
 
182
 
185
     #if HAS_AUTO_FAN
183
     #if HAS_AUTO_FAN
186
-      millis_t next_auto_fan_check_ms;
184
+      static millis_t next_auto_fan_check_ms;
187
     #endif
185
     #endif
188
 
186
 
189
-    unsigned char soft_pwm[EXTRUDERS];
187
+    static unsigned char soft_pwm[EXTRUDERS];
190
 
188
 
191
     #if ENABLED(FAN_SOFT_PWM)
189
     #if ENABLED(FAN_SOFT_PWM)
192
-      unsigned char soft_pwm_fan[FAN_COUNT];
190
+      static unsigned char soft_pwm_fan[FAN_COUNT];
193
     #endif
191
     #endif
194
 
192
 
195
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
193
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
196
-      int current_raw_filwidth = 0;  //Holds measured filament diameter - one extruder only
194
+      static int current_raw_filwidth;  //Holds measured filament diameter - one extruder only
197
     #endif
195
     #endif
198
 
196
 
199
   public:
197
   public:
200
 
198
 
201
     /**
199
     /**
202
-     * Static (class) methods
203
-     */
204
-    static float analog2temp(int raw, uint8_t e);
205
-    static float analog2tempBed(int raw);
206
-
207
-    /**
208
      * Instance Methods
200
      * Instance Methods
209
      */
201
      */
210
 
202
 
213
     void init();
205
     void init();
214
 
206
 
215
     /**
207
     /**
208
+     * Static (class) methods
209
+     */
210
+    static float analog2temp(int raw, uint8_t e);
211
+    static float analog2tempBed(int raw);
212
+
213
+    /**
216
      * Called from the Temperature ISR
214
      * Called from the Temperature ISR
217
      */
215
      */
218
-    void isr();
216
+    static void isr();
219
 
217
 
220
     /**
218
     /**
221
      * Call periodically to manage heaters
219
      * Call periodically to manage heaters
222
      */
220
      */
223
-    void manage_heater();
221
+    static void manage_heater();
224
 
222
 
225
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
223
     #if ENABLED(FILAMENT_WIDTH_SENSOR)
226
-      float analog2widthFil(); // Convert raw Filament Width to millimeters
227
-      int widthFil_to_size_ratio(); // Convert raw Filament Width to an extrusion ratio
224
+      static float analog2widthFil(); // Convert raw Filament Width to millimeters
225
+      static int widthFil_to_size_ratio(); // Convert raw Filament Width to an extrusion ratio
228
     #endif
226
     #endif
229
 
227
 
230
 
228
 
232
     //inline so that there is no performance decrease.
230
     //inline so that there is no performance decrease.
233
     //deg=degreeCelsius
231
     //deg=degreeCelsius
234
 
232
 
235
-    FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }
236
-    FORCE_INLINE float degBed() { return current_temperature_bed; }
233
+    static float degHotend(uint8_t extruder) { return current_temperature[extruder]; }
234
+    static float degBed() { return current_temperature_bed; }
237
 
235
 
238
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
236
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
239
-    FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }
240
-    FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
237
+    static float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }
238
+    static float rawBedTemp() { return current_temperature_bed_raw; }
241
     #endif
239
     #endif
242
 
240
 
243
-    FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }
244
-    FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
241
+    static float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }
242
+    static float degTargetBed() { return target_temperature_bed; }
245
 
243
 
246
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
244
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
247
-      void start_watching_heater(int e = 0);
245
+      static void start_watching_heater(int e = 0);
248
     #endif
246
     #endif
249
 
247
 
250
     #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
248
     #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
251
-      void start_watching_bed();
249
+      static void start_watching_bed();
252
     #endif
250
     #endif
253
 
251
 
254
-    FORCE_INLINE void setTargetHotend(const float& celsius, uint8_t extruder) {
252
+    static void setTargetHotend(const float& celsius, uint8_t extruder) {
255
       target_temperature[extruder] = celsius;
253
       target_temperature[extruder] = celsius;
256
       #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
254
       #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
257
         start_watching_heater(extruder);
255
         start_watching_heater(extruder);
258
       #endif
256
       #endif
259
     }
257
     }
260
 
258
 
261
-    FORCE_INLINE void setTargetBed(const float& celsius) {
259
+    static void setTargetBed(const float& celsius) {
262
       target_temperature_bed = celsius;
260
       target_temperature_bed = celsius;
263
       #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
261
       #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
264
         start_watching_bed();
262
         start_watching_bed();
265
       #endif
263
       #endif
266
     }
264
     }
267
 
265
 
268
-    FORCE_INLINE bool isHeatingHotend(uint8_t extruder) { return target_temperature[extruder] > current_temperature[extruder]; }
269
-    FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
266
+    static bool isHeatingHotend(uint8_t extruder) { return target_temperature[extruder] > current_temperature[extruder]; }
267
+    static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
270
 
268
 
271
-    FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }
272
-    FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
269
+    static bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }
270
+    static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
273
 
271
 
274
     /**
272
     /**
275
      * The software PWM power for a heater
273
      * The software PWM power for a heater
276
      */
274
      */
277
-    int getHeaterPower(int heater);
275
+    static int getHeaterPower(int heater);
278
 
276
 
279
     /**
277
     /**
280
      * Switch off all heaters, set all target temperatures to 0
278
      * Switch off all heaters, set all target temperatures to 0
281
      */
279
      */
282
-    void disable_all_heaters();
280
+    static void disable_all_heaters();
283
 
281
 
284
     /**
282
     /**
285
      * Perform auto-tuning for hotend or bed in response to M303
283
      * Perform auto-tuning for hotend or bed in response to M303
286
      */
284
      */
287
     #if HAS_PID_HEATING
285
     #if HAS_PID_HEATING
288
-      void PID_autotune(float temp, int extruder, int ncycles, bool set_result=false);
286
+      static void PID_autotune(float temp, int extruder, int ncycles, bool set_result=false);
289
     #endif
287
     #endif
290
 
288
 
291
     /**
289
     /**
292
      * Update the temp manager when PID values change
290
      * Update the temp manager when PID values change
293
      */
291
      */
294
-    void updatePID();
292
+    static void updatePID();
295
 
293
 
296
-    FORCE_INLINE void autotempShutdown() {
294
+    static void autotempShutdown() {
297
       #if ENABLED(AUTOTEMP)
295
       #if ENABLED(AUTOTEMP)
298
         if (planner.autotemp_enabled) {
296
         if (planner.autotemp_enabled) {
299
           planner.autotemp_enabled = false;
297
           planner.autotemp_enabled = false;
305
 
303
 
306
     #if ENABLED(BABYSTEPPING)
304
     #if ENABLED(BABYSTEPPING)
307
 
305
 
308
-      FORCE_INLINE void babystep_axis(AxisEnum axis, int distance) {
306
+      static void babystep_axis(AxisEnum axis, int distance) {
309
         #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
307
         #if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
310
           #if ENABLED(BABYSTEP_XY)
308
           #if ENABLED(BABYSTEP_XY)
311
             switch (axis) {
309
             switch (axis) {
337
 
335
 
338
   private:
336
   private:
339
 
337
 
340
-    void set_current_temp_raw();
338
+    static void set_current_temp_raw();
341
 
339
 
342
-    void updateTemperaturesFromRawValues();
340
+    static void updateTemperaturesFromRawValues();
343
 
341
 
344
     #if ENABLED(HEATER_0_USES_MAX6675)
342
     #if ENABLED(HEATER_0_USES_MAX6675)
345
-      int read_max6675();
343
+      static int read_max6675();
346
     #endif
344
     #endif
347
 
345
 
348
-    void checkExtruderAutoFans();
346
+    static void checkExtruderAutoFans();
349
 
347
 
350
-    float get_pid_output(int e);
348
+    static float get_pid_output(int e);
351
 
349
 
352
     #if ENABLED(PIDTEMPBED)
350
     #if ENABLED(PIDTEMPBED)
353
-      float get_pid_output_bed();
351
+      static float get_pid_output_bed();
354
     #endif
352
     #endif
355
 
353
 
356
-    void _temp_error(int e, const char* serial_msg, const char* lcd_msg);
357
-    void min_temp_error(uint8_t e);
358
-    void max_temp_error(uint8_t e);
354
+    static void _temp_error(int e, const char* serial_msg, const char* lcd_msg);
355
+    static void min_temp_error(uint8_t e);
356
+    static void max_temp_error(uint8_t e);
359
 
357
 
360
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
358
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
361
 
359
 
362
       typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
360
       typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
363
 
361
 
364
-      void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
362
+      static void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
365
 
363
 
366
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
364
       #if ENABLED(THERMAL_PROTECTION_HOTENDS)
367
-        TRState thermal_runaway_state_machine[EXTRUDERS] = { TRInactive };
368
-        millis_t thermal_runaway_timer[EXTRUDERS] = { 0 };
365
+        static TRState thermal_runaway_state_machine[EXTRUDERS];
366
+        static millis_t thermal_runaway_timer[EXTRUDERS];
369
       #endif
367
       #endif
370
 
368
 
371
       #if HAS_THERMALLY_PROTECTED_BED
369
       #if HAS_THERMALLY_PROTECTED_BED
372
-        TRState thermal_runaway_bed_state_machine = TRInactive;
373
-        millis_t thermal_runaway_bed_timer;
370
+        static TRState thermal_runaway_bed_state_machine;
371
+        static millis_t thermal_runaway_bed_timer;
374
       #endif
372
       #endif
375
 
373
 
376
     #endif // THERMAL_PROTECTION
374
     #endif // THERMAL_PROTECTION

Loading…
Cancel
Save