Browse Source

Tweaks to temperature code

Scott Lahteine 7 years ago
parent
commit
7769a22064
3 changed files with 22 additions and 22 deletions
  1. 12
    12
      Marlin/temperature.cpp
  2. 4
    4
      Marlin/temperature.h
  3. 6
    6
      Marlin/thermistortable_20.h

+ 12
- 12
Marlin/temperature.cpp View File

@@ -421,13 +421,13 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
421 421
           bedKp = workKp; \
422 422
           bedKi = scalePID_i(workKi); \
423 423
           bedKd = scalePID_d(workKd); \
424
-          updatePID(); } while(0)
424
+          updatePID(); }while(0)
425 425
 
426 426
         #define _SET_EXTRUDER_PID() do { \
427 427
           PID_PARAM(Kp, hotend) = workKp; \
428 428
           PID_PARAM(Ki, hotend) = scalePID_i(workKi); \
429 429
           PID_PARAM(Kd, hotend) = scalePID_d(workKd); \
430
-          updatePID(); } while(0)
430
+          updatePID(); }while(0)
431 431
 
432 432
         // Use the result? (As with "M303 U1")
433 433
         if (set_result) {
@@ -505,7 +505,7 @@ int Temperature::getHeaterPower(int heater) {
505 505
 //
506 506
 // Temperature Error Handlers
507 507
 //
508
-void Temperature::_temp_error(int e, const char* serial_msg, const char* lcd_msg) {
508
+void Temperature::_temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg) {
509 509
   static bool killed = false;
510 510
   if (IsRunning()) {
511 511
     SERIAL_ERROR_START();
@@ -524,7 +524,7 @@ void Temperature::_temp_error(int e, const char* serial_msg, const char* lcd_msg
524 524
   #endif
525 525
 }
526 526
 
527
-void Temperature::max_temp_error(int8_t e) {
527
+void Temperature::max_temp_error(const int8_t e) {
528 528
   #if HAS_TEMP_BED
529 529
     _temp_error(e, PSTR(MSG_T_MAXTEMP), e >= 0 ? PSTR(MSG_ERR_MAXTEMP) : PSTR(MSG_ERR_MAXTEMP_BED));
530 530
   #else
@@ -534,7 +534,7 @@ void Temperature::max_temp_error(int8_t e) {
534 534
     #endif
535 535
   #endif
536 536
 }
537
-void Temperature::min_temp_error(int8_t e) {
537
+void Temperature::min_temp_error(const int8_t e) {
538 538
   #if HAS_TEMP_BED
539 539
     _temp_error(e, PSTR(MSG_T_MINTEMP), e >= 0 ? PSTR(MSG_ERR_MINTEMP) : PSTR(MSG_ERR_MINTEMP_BED));
540 540
   #else
@@ -545,7 +545,7 @@ void Temperature::min_temp_error(int8_t e) {
545 545
   #endif
546 546
 }
547 547
 
548
-float Temperature::get_pid_output(int e) {
548
+float Temperature::get_pid_output(const int8_t e) {
549 549
   #if HOTENDS == 1
550 550
     UNUSED(e);
551 551
     #define _HOTEND_TEST     true
@@ -890,7 +890,7 @@ float Temperature::analog2temp(int raw, uint8_t e) {
890 890
 
891 891
 // Derived from RepRap FiveD extruder::getTemperature()
892 892
 // For bed temperature measurement.
893
-float Temperature::analog2tempBed(int raw) {
893
+float Temperature::analog2tempBed(const int raw) {
894 894
   #if ENABLED(BED_USES_THERMISTOR)
895 895
     float celsius = 0;
896 896
     byte i;
@@ -1148,7 +1148,7 @@ void Temperature::init() {
1148 1148
 
1149 1149
   #define TEMP_MIN_ROUTINE(NR) \
1150 1150
     minttemp[NR] = HEATER_ ##NR## _MINTEMP; \
1151
-    while(analog2temp(minttemp_raw[NR], NR) < HEATER_ ##NR## _MINTEMP) { \
1151
+    while (analog2temp(minttemp_raw[NR], NR) < HEATER_ ##NR## _MINTEMP) { \
1152 1152
       if (HEATER_ ##NR## _RAW_LO_TEMP < HEATER_ ##NR## _RAW_HI_TEMP) \
1153 1153
         minttemp_raw[NR] += OVERSAMPLENR; \
1154 1154
       else \
@@ -1156,7 +1156,7 @@ void Temperature::init() {
1156 1156
     }
1157 1157
   #define TEMP_MAX_ROUTINE(NR) \
1158 1158
     maxttemp[NR] = HEATER_ ##NR## _MAXTEMP; \
1159
-    while(analog2temp(maxttemp_raw[NR], NR) > HEATER_ ##NR## _MAXTEMP) { \
1159
+    while (analog2temp(maxttemp_raw[NR], NR) > HEATER_ ##NR## _MAXTEMP) { \
1160 1160
       if (HEATER_ ##NR## _RAW_LO_TEMP < HEATER_ ##NR## _RAW_HI_TEMP) \
1161 1161
         maxttemp_raw[NR] -= OVERSAMPLENR; \
1162 1162
       else \
@@ -1203,7 +1203,7 @@ void Temperature::init() {
1203 1203
   #endif // HOTENDS > 1
1204 1204
 
1205 1205
   #ifdef BED_MINTEMP
1206
-    while(analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
1206
+    while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
1207 1207
       #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
1208 1208
         bed_minttemp_raw += OVERSAMPLENR;
1209 1209
       #else
@@ -1292,7 +1292,7 @@ void Temperature::init() {
1292 1292
         SERIAL_EOL();
1293 1293
     */
1294 1294
 
1295
-    int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
1295
+    const int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
1296 1296
 
1297 1297
     #if HEATER_IDLE_HANDLER
1298 1298
       // If the heater idle timeout expires, restart
@@ -1922,7 +1922,7 @@ void Temperature::isr() {
1922 1922
     case SensorsReady: {
1923 1923
       // All sensors have been read. Stay in this state for a few
1924 1924
       // ISRs to save on calls to temp update/checking code below.
1925
-      constexpr int extra_loops = MIN_ADC_ISR_LOOPS - (int)SensorsReady;
1925
+      constexpr int8_t extra_loops = MIN_ADC_ISR_LOOPS - (int8_t)SensorsReady;
1926 1926
       static uint8_t delay_count = 0;
1927 1927
       if (extra_loops > 0) {
1928 1928
         if (delay_count == 0) delay_count = extra_loops;   // Init this delay

+ 4
- 4
Marlin/temperature.h View File

@@ -535,15 +535,15 @@ class Temperature {
535 535
 
536 536
     static void checkExtruderAutoFans();
537 537
 
538
-    static float get_pid_output(int e);
538
+    static float get_pid_output(const int8_t e);
539 539
 
540 540
     #if ENABLED(PIDTEMPBED)
541 541
       static float get_pid_output_bed();
542 542
     #endif
543 543
 
544
-    static void _temp_error(int e, const char* serial_msg, const char* lcd_msg);
545
-    static void min_temp_error(int8_t e);
546
-    static void max_temp_error(int8_t e);
544
+    static void _temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg);
545
+    static void min_temp_error(const int8_t e);
546
+    static void max_temp_error(const int8_t e);
547 547
 
548 548
     #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
549 549
 

+ 6
- 6
Marlin/thermistortable_20.h View File

@@ -23,27 +23,27 @@
23 23
 // PT100 with INA826 amp on Ultimaker v2.0 electronics
24 24
 // The PT100 in the Ultimaker v2.0 electronics has a high sample value for a high temperature.
25 25
 // This does not match the normal thermistor behaviour so we need to set the following defines
26
-#if (THERMISTORHEATER_0 == 20)
26
+#if THERMISTORHEATER_0 == 20
27 27
   #define HEATER_0_RAW_HI_TEMP 16383
28 28
   #define HEATER_0_RAW_LO_TEMP 0
29 29
 #endif
30
-#if (THERMISTORHEATER_1 == 20)
30
+#if THERMISTORHEATER_1 == 20
31 31
   #define HEATER_1_RAW_HI_TEMP 16383
32 32
   #define HEATER_1_RAW_LO_TEMP 0
33 33
 #endif
34
-#if (THERMISTORHEATER_2 == 20)
34
+#if THERMISTORHEATER_2 == 20
35 35
   #define HEATER_2_RAW_HI_TEMP 16383
36 36
   #define HEATER_2_RAW_LO_TEMP 0
37 37
 #endif
38
-#if (THERMISTORHEATER_3 == 20)
38
+#if THERMISTORHEATER_3 == 20
39 39
   #define HEATER_3_RAW_HI_TEMP 16383
40 40
   #define HEATER_3_RAW_LO_TEMP 0
41 41
 #endif
42
-#if (THERMISTORHEATER_4 == 20)
42
+#if THERMISTORHEATER_4 == 20
43 43
   #define HEATER_4_RAW_HI_TEMP 16383
44 44
   #define HEATER_4_RAW_LO_TEMP 0
45 45
 #endif
46
-#if (THERMISTORBED == 20)
46
+#if THERMISTORBED == 20
47 47
   #define HEATER_BED_RAW_HI_TEMP 16383
48 48
   #define HEATER_BED_RAW_LO_TEMP 0
49 49
 #endif

Loading…
Cancel
Save