|
@@ -34,7 +34,7 @@
|
34
|
34
|
#define K2 (1.0-K1)
|
35
|
35
|
#endif
|
36
|
36
|
|
37
|
|
-#if defined(PIDTEMPBED) || defined(PIDTEMP)
|
|
37
|
+#if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMP)
|
38
|
38
|
#define PID_dT ((OVERSAMPLENR * 12.0)/(F_CPU / 64.0 / 256.0))
|
39
|
39
|
#endif
|
40
|
40
|
|
|
@@ -48,39 +48,39 @@ int current_temperature_raw[4] = { 0 };
|
48
|
48
|
float current_temperature[4] = { 0.0 };
|
49
|
49
|
int current_temperature_bed_raw = 0;
|
50
|
50
|
float current_temperature_bed = 0.0;
|
51
|
|
-#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
|
51
|
+#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
52
|
52
|
int redundant_temperature_raw = 0;
|
53
|
53
|
float redundant_temperature = 0.0;
|
54
|
54
|
#endif
|
55
|
55
|
|
56
|
|
-#ifdef PIDTEMPBED
|
|
56
|
+#if ENABLED(PIDTEMPBED)
|
57
|
57
|
float bedKp=DEFAULT_bedKp;
|
58
|
58
|
float bedKi=(DEFAULT_bedKi*PID_dT);
|
59
|
59
|
float bedKd=(DEFAULT_bedKd/PID_dT);
|
60
|
60
|
#endif //PIDTEMPBED
|
61
|
61
|
|
62
|
|
-#ifdef FAN_SOFT_PWM
|
|
62
|
+#if ENABLED(FAN_SOFT_PWM)
|
63
|
63
|
unsigned char fanSpeedSoftPwm;
|
64
|
64
|
#endif
|
65
|
65
|
|
66
|
66
|
unsigned char soft_pwm_bed;
|
67
|
67
|
|
68
|
|
-#ifdef BABYSTEPPING
|
|
68
|
+#if ENABLED(BABYSTEPPING)
|
69
|
69
|
volatile int babystepsTodo[3] = { 0 };
|
70
|
70
|
#endif
|
71
|
71
|
|
72
|
|
-#ifdef FILAMENT_SENSOR
|
|
72
|
+#if ENABLED(FILAMENT_SENSOR)
|
73
|
73
|
int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only
|
74
|
74
|
#endif
|
75
|
75
|
|
76
|
|
-#if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED)
|
|
76
|
+#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED)
|
77
|
77
|
enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway };
|
78
|
78
|
void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
|
79
|
|
- #ifdef THERMAL_PROTECTION_HOTENDS
|
|
79
|
+ #if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
80
|
80
|
static TRState thermal_runaway_state_machine[4] = { TRReset, TRReset, TRReset, TRReset };
|
81
|
81
|
static millis_t thermal_runaway_timer[4]; // = {0,0,0,0};
|
82
|
82
|
#endif
|
83
|
|
- #if defined(THERMAL_PROTECTION_BED) && TEMP_SENSOR_BED != 0
|
|
83
|
+ #if ENABLED(THERMAL_PROTECTION_BED) && TEMP_SENSOR_BED != 0
|
84
|
84
|
static TRState thermal_runaway_bed_state_machine = TRReset;
|
85
|
85
|
static millis_t thermal_runaway_bed_timer;
|
86
|
86
|
#endif
|
|
@@ -92,7 +92,7 @@ unsigned char soft_pwm_bed;
|
92
|
92
|
|
93
|
93
|
static volatile bool temp_meas_ready = false;
|
94
|
94
|
|
95
|
|
-#ifdef PIDTEMP
|
|
95
|
+#if ENABLED(PIDTEMP)
|
96
|
96
|
//static cannot be external:
|
97
|
97
|
static float temp_iState[EXTRUDERS] = { 0 };
|
98
|
98
|
static float temp_dState[EXTRUDERS] = { 0 };
|
|
@@ -105,7 +105,7 @@ static volatile bool temp_meas_ready = false;
|
105
|
105
|
static float temp_iState_max[EXTRUDERS];
|
106
|
106
|
static bool pid_reset[EXTRUDERS];
|
107
|
107
|
#endif //PIDTEMP
|
108
|
|
-#ifdef PIDTEMPBED
|
|
108
|
+#if ENABLED(PIDTEMPBED)
|
109
|
109
|
//static cannot be external:
|
110
|
110
|
static float temp_iState_bed = { 0 };
|
111
|
111
|
static float temp_dState_bed = { 0 };
|
|
@@ -121,26 +121,26 @@ static volatile bool temp_meas_ready = false;
|
121
|
121
|
#endif //PIDTEMPBED
|
122
|
122
|
static unsigned char soft_pwm[EXTRUDERS];
|
123
|
123
|
|
124
|
|
-#ifdef FAN_SOFT_PWM
|
|
124
|
+#if ENABLED(FAN_SOFT_PWM)
|
125
|
125
|
static unsigned char soft_pwm_fan;
|
126
|
126
|
#endif
|
127
|
127
|
#if HAS_AUTO_FAN
|
128
|
128
|
static millis_t next_auto_fan_check_ms;
|
129
|
129
|
#endif
|
130
|
130
|
|
131
|
|
-#ifdef PIDTEMP
|
132
|
|
- #ifdef PID_PARAMS_PER_EXTRUDER
|
|
131
|
+#if ENABLED(PIDTEMP)
|
|
132
|
+ #if ENABLED(PID_PARAMS_PER_EXTRUDER)
|
133
|
133
|
float Kp[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Kp);
|
134
|
134
|
float Ki[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Ki*PID_dT);
|
135
|
135
|
float Kd[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Kd / PID_dT);
|
136
|
|
- #ifdef PID_ADD_EXTRUSION_RATE
|
|
136
|
+ #if ENABLED(PID_ADD_EXTRUSION_RATE)
|
137
|
137
|
float Kc[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(DEFAULT_Kc);
|
138
|
138
|
#endif // PID_ADD_EXTRUSION_RATE
|
139
|
139
|
#else //PID_PARAMS_PER_EXTRUDER
|
140
|
140
|
float Kp = DEFAULT_Kp;
|
141
|
141
|
float Ki = DEFAULT_Ki * PID_dT;
|
142
|
142
|
float Kd = DEFAULT_Kd / PID_dT;
|
143
|
|
- #ifdef PID_ADD_EXTRUSION_RATE
|
|
143
|
+ #if ENABLED(PID_ADD_EXTRUSION_RATE)
|
144
|
144
|
float Kc = DEFAULT_Kc;
|
145
|
145
|
#endif // PID_ADD_EXTRUSION_RATE
|
146
|
146
|
#endif // PID_PARAMS_PER_EXTRUDER
|
|
@@ -158,7 +158,7 @@ static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP;
|
158
|
158
|
static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
|
159
|
159
|
#endif
|
160
|
160
|
|
161
|
|
-#ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
|
161
|
+#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
162
|
162
|
static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE };
|
163
|
163
|
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
|
164
|
164
|
#else
|
|
@@ -170,7 +170,7 @@ static float analog2temp(int raw, uint8_t e);
|
170
|
170
|
static float analog2tempBed(int raw);
|
171
|
171
|
static void updateTemperaturesFromRawValues();
|
172
|
172
|
|
173
|
|
-#ifdef THERMAL_PROTECTION_HOTENDS
|
|
173
|
+#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
174
|
174
|
int watch_target_temp[EXTRUDERS] = { 0 };
|
175
|
175
|
millis_t watch_heater_next_ms[EXTRUDERS] = { 0 };
|
176
|
176
|
#endif
|
|
@@ -179,11 +179,11 @@ static void updateTemperaturesFromRawValues();
|
179
|
179
|
#define SOFT_PWM_SCALE 0
|
180
|
180
|
#endif
|
181
|
181
|
|
182
|
|
-#ifdef FILAMENT_SENSOR
|
|
182
|
+#if ENABLED(FILAMENT_SENSOR)
|
183
|
183
|
static int meas_shift_index; //used to point to a delayed sample in buffer for filament width sensor
|
184
|
184
|
#endif
|
185
|
185
|
|
186
|
|
-#ifdef HEATER_0_USES_MAX6675
|
|
186
|
+#if ENABLED(HEATER_0_USES_MAX6675)
|
187
|
187
|
static int read_max6675();
|
188
|
188
|
#endif
|
189
|
189
|
|
|
@@ -354,12 +354,12 @@ void PID_autotune(float temp, int extruder, int ncycles) {
|
354
|
354
|
}
|
355
|
355
|
|
356
|
356
|
void updatePID() {
|
357
|
|
- #ifdef PIDTEMP
|
|
357
|
+ #if ENABLED(PIDTEMP)
|
358
|
358
|
for (int e = 0; e < EXTRUDERS; e++) {
|
359
|
359
|
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
|
360
|
360
|
}
|
361
|
361
|
#endif
|
362
|
|
- #ifdef PIDTEMPBED
|
|
362
|
+ #if ENABLED(PIDTEMPBED)
|
363
|
363
|
temp_iState_max_bed = PID_BED_INTEGRAL_DRIVE_MAX / bedKi;
|
364
|
364
|
#endif
|
365
|
365
|
}
|
|
@@ -453,7 +453,7 @@ inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) {
|
453
|
453
|
SERIAL_ERRORPGM(MSG_STOPPED_HEATER);
|
454
|
454
|
if (e >= 0) SERIAL_ERRORLN((int)e); else SERIAL_ERRORLNPGM(MSG_HEATER_BED);
|
455
|
455
|
}
|
456
|
|
- #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
|
|
456
|
+ #if DISABLED(BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE)
|
457
|
457
|
if (!killed) {
|
458
|
458
|
Running = false;
|
459
|
459
|
killed = true;
|
|
@@ -473,8 +473,8 @@ void min_temp_error(uint8_t e) {
|
473
|
473
|
|
474
|
474
|
float get_pid_output(int e) {
|
475
|
475
|
float pid_output;
|
476
|
|
- #ifdef PIDTEMP
|
477
|
|
- #ifndef PID_OPENLOOP
|
|
476
|
+ #if ENABLED(PIDTEMP)
|
|
477
|
+ #if DISABLED(PID_OPENLOOP)
|
478
|
478
|
pid_error[e] = target_temperature[e] - current_temperature[e];
|
479
|
479
|
dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e];
|
480
|
480
|
temp_dState[e] = current_temperature[e];
|
|
@@ -510,7 +510,7 @@ float get_pid_output(int e) {
|
510
|
510
|
pid_output = constrain(target_temperature[e], 0, PID_MAX);
|
511
|
511
|
#endif //PID_OPENLOOP
|
512
|
512
|
|
513
|
|
- #ifdef PID_DEBUG
|
|
513
|
+ #if ENABLED(PID_DEBUG)
|
514
|
514
|
SERIAL_ECHO_START;
|
515
|
515
|
SERIAL_ECHO(MSG_PID_DEBUG);
|
516
|
516
|
SERIAL_ECHO(e);
|
|
@@ -533,10 +533,10 @@ float get_pid_output(int e) {
|
533
|
533
|
return pid_output;
|
534
|
534
|
}
|
535
|
535
|
|
536
|
|
-#ifdef PIDTEMPBED
|
|
536
|
+#if ENABLED(PIDTEMPBED)
|
537
|
537
|
float get_pid_output_bed() {
|
538
|
538
|
float pid_output;
|
539
|
|
- #ifndef PID_OPENLOOP
|
|
539
|
+ #if DISABLED(PID_OPENLOOP)
|
540
|
540
|
pid_error_bed = target_temperature_bed - current_temperature_bed;
|
541
|
541
|
pTerm_bed = bedKp * pid_error_bed;
|
542
|
542
|
temp_iState_bed += pid_error_bed;
|
|
@@ -559,7 +559,7 @@ float get_pid_output(int e) {
|
559
|
559
|
pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
|
560
|
560
|
#endif // PID_OPENLOOP
|
561
|
561
|
|
562
|
|
- #ifdef PID_BED_DEBUG
|
|
562
|
+ #if ENABLED(PID_BED_DEBUG)
|
563
|
563
|
SERIAL_ECHO_START;
|
564
|
564
|
SERIAL_ECHO(" PID_BED_DEBUG ");
|
565
|
565
|
SERIAL_ECHO(": Input ");
|
|
@@ -592,20 +592,20 @@ void manage_heater() {
|
592
|
592
|
|
593
|
593
|
updateTemperaturesFromRawValues();
|
594
|
594
|
|
595
|
|
- #ifdef HEATER_0_USES_MAX6675
|
|
595
|
+ #if ENABLED(HEATER_0_USES_MAX6675)
|
596
|
596
|
float ct = current_temperature[0];
|
597
|
597
|
if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
|
598
|
598
|
if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
|
599
|
599
|
#endif
|
600
|
600
|
|
601
|
|
- #if defined(THERMAL_PROTECTION_HOTENDS) || !defined(PIDTEMPBED) || HAS_AUTO_FAN
|
|
601
|
+ #if ENABLED(THERMAL_PROTECTION_HOTENDS) || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
|
602
|
602
|
millis_t ms = millis();
|
603
|
603
|
#endif
|
604
|
604
|
|
605
|
605
|
// Loop through all extruders
|
606
|
606
|
for (int e = 0; e < EXTRUDERS; e++) {
|
607
|
607
|
|
608
|
|
- #ifdef THERMAL_PROTECTION_HOTENDS
|
|
608
|
+ #if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
609
|
609
|
thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
|
610
|
610
|
#endif
|
611
|
611
|
|
|
@@ -615,7 +615,7 @@ void manage_heater() {
|
615
|
615
|
soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
|
616
|
616
|
|
617
|
617
|
// Check if the temperature is failing to increase
|
618
|
|
- #ifdef THERMAL_PROTECTION_HOTENDS
|
|
618
|
+ #if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
619
|
619
|
|
620
|
620
|
// Is it time to check this extruder's heater?
|
621
|
621
|
if (watch_heater_next_ms[e] && ms > watch_heater_next_ms[e]) {
|
|
@@ -632,7 +632,7 @@ void manage_heater() {
|
632
|
632
|
|
633
|
633
|
#endif // THERMAL_PROTECTION_HOTENDS
|
634
|
634
|
|
635
|
|
- #ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
|
635
|
+ #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
636
|
636
|
if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
|
637
|
637
|
_temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
|
638
|
638
|
}
|
|
@@ -648,7 +648,7 @@ void manage_heater() {
|
648
|
648
|
#endif
|
649
|
649
|
|
650
|
650
|
// Control the extruder rate based on the width sensor
|
651
|
|
- #ifdef FILAMENT_SENSOR
|
|
651
|
+ #if ENABLED(FILAMENT_SENSOR)
|
652
|
652
|
if (filament_sensor) {
|
653
|
653
|
meas_shift_index = delay_index1 - meas_delay_cm;
|
654
|
654
|
if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed
|
|
@@ -662,23 +662,23 @@ void manage_heater() {
|
662
|
662
|
}
|
663
|
663
|
#endif //FILAMENT_SENSOR
|
664
|
664
|
|
665
|
|
- #ifndef PIDTEMPBED
|
|
665
|
+ #if DISABLED(PIDTEMPBED)
|
666
|
666
|
if (ms < next_bed_check_ms) return;
|
667
|
667
|
next_bed_check_ms = ms + BED_CHECK_INTERVAL;
|
668
|
668
|
#endif
|
669
|
669
|
|
670
|
670
|
#if TEMP_SENSOR_BED != 0
|
671
|
671
|
|
672
|
|
- #ifdef THERMAL_PROTECTION_BED
|
|
672
|
+ #if ENABLED(THERMAL_PROTECTION_BED)
|
673
|
673
|
thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS);
|
674
|
674
|
#endif
|
675
|
675
|
|
676
|
|
- #ifdef PIDTEMPBED
|
|
676
|
+ #if ENABLED(PIDTEMPBED)
|
677
|
677
|
float pid_output = get_pid_output_bed();
|
678
|
678
|
|
679
|
679
|
soft_pwm_bed = current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP ? (int)pid_output >> 1 : 0;
|
680
|
680
|
|
681
|
|
- #elif defined(BED_LIMIT_SWITCHING)
|
|
681
|
+ #elif ENABLED(BED_LIMIT_SWITCHING)
|
682
|
682
|
// Check if temperature is within the correct band
|
683
|
683
|
if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) {
|
684
|
684
|
if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
|
|
@@ -707,7 +707,7 @@ void manage_heater() {
|
707
|
707
|
// Derived from RepRap FiveD extruder::getTemperature()
|
708
|
708
|
// For hot end temperature measurement.
|
709
|
709
|
static float analog2temp(int raw, uint8_t e) {
|
710
|
|
- #ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
|
710
|
+ #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
711
|
711
|
if (e > EXTRUDERS)
|
712
|
712
|
#else
|
713
|
713
|
if (e >= EXTRUDERS)
|
|
@@ -720,7 +720,7 @@ static float analog2temp(int raw, uint8_t e) {
|
720
|
720
|
return 0.0;
|
721
|
721
|
}
|
722
|
722
|
|
723
|
|
- #ifdef HEATER_0_USES_MAX6675
|
|
723
|
+ #if ENABLED(HEATER_0_USES_MAX6675)
|
724
|
724
|
if (e == 0) return 0.25 * raw;
|
725
|
725
|
#endif
|
726
|
726
|
|
|
@@ -750,7 +750,7 @@ static float analog2temp(int raw, uint8_t e) {
|
750
|
750
|
// Derived from RepRap FiveD extruder::getTemperature()
|
751
|
751
|
// For bed temperature measurement.
|
752
|
752
|
static float analog2tempBed(int raw) {
|
753
|
|
- #ifdef BED_USES_THERMISTOR
|
|
753
|
+ #if ENABLED(BED_USES_THERMISTOR)
|
754
|
754
|
float celsius = 0;
|
755
|
755
|
byte i;
|
756
|
756
|
|
|
@@ -778,14 +778,14 @@ static float analog2tempBed(int raw) {
|
778
|
778
|
/* Called to get the raw values into the the actual temperatures. The raw values are created in interrupt context,
|
779
|
779
|
and this function is called from normal context as it is too slow to run in interrupts and will block the stepper routine otherwise */
|
780
|
780
|
static void updateTemperaturesFromRawValues() {
|
781
|
|
- #ifdef HEATER_0_USES_MAX6675
|
|
781
|
+ #if ENABLED(HEATER_0_USES_MAX6675)
|
782
|
782
|
current_temperature_raw[0] = read_max6675();
|
783
|
783
|
#endif
|
784
|
784
|
for (uint8_t e = 0; e < EXTRUDERS; e++) {
|
785
|
785
|
current_temperature[e] = analog2temp(current_temperature_raw[e], e);
|
786
|
786
|
}
|
787
|
787
|
current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
|
788
|
|
- #ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
|
788
|
+ #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
789
|
789
|
redundant_temperature = analog2temp(redundant_temperature_raw, 1);
|
790
|
790
|
#endif
|
791
|
791
|
#if HAS_FILAMENT_SENSOR
|
|
@@ -800,7 +800,7 @@ static void updateTemperaturesFromRawValues() {
|
800
|
800
|
}
|
801
|
801
|
|
802
|
802
|
|
803
|
|
-#ifdef FILAMENT_SENSOR
|
|
803
|
+#if ENABLED(FILAMENT_SENSOR)
|
804
|
804
|
|
805
|
805
|
// Convert raw Filament Width to millimeters
|
806
|
806
|
float analog2widthFil() {
|
|
@@ -834,11 +834,11 @@ void tp_init() {
|
834
|
834
|
for (int e = 0; e < EXTRUDERS; e++) {
|
835
|
835
|
// populate with the first value
|
836
|
836
|
maxttemp[e] = maxttemp[0];
|
837
|
|
- #ifdef PIDTEMP
|
|
837
|
+ #if ENABLED(PIDTEMP)
|
838
|
838
|
temp_iState_min[e] = 0.0;
|
839
|
839
|
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
|
840
|
840
|
#endif //PIDTEMP
|
841
|
|
- #ifdef PIDTEMPBED
|
|
841
|
+ #if ENABLED(PIDTEMPBED)
|
842
|
842
|
temp_iState_min_bed = 0.0;
|
843
|
843
|
temp_iState_max_bed = PID_BED_INTEGRAL_DRIVE_MAX / bedKi;
|
844
|
844
|
#endif //PIDTEMPBED
|
|
@@ -861,17 +861,17 @@ void tp_init() {
|
861
|
861
|
#endif
|
862
|
862
|
#if HAS_FAN
|
863
|
863
|
SET_OUTPUT(FAN_PIN);
|
864
|
|
- #ifdef FAST_PWM_FAN
|
|
864
|
+ #if ENABLED(FAST_PWM_FAN)
|
865
|
865
|
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
866
|
866
|
#endif
|
867
|
|
- #ifdef FAN_SOFT_PWM
|
|
867
|
+ #if ENABLED(FAN_SOFT_PWM)
|
868
|
868
|
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
869
|
869
|
#endif
|
870
|
870
|
#endif
|
871
|
871
|
|
872
|
|
- #ifdef HEATER_0_USES_MAX6675
|
|
872
|
+ #if ENABLED(HEATER_0_USES_MAX6675)
|
873
|
873
|
|
874
|
|
- #ifndef SDSUPPORT
|
|
874
|
+ #if DISABLED(SDSUPPORT)
|
875
|
875
|
OUT_WRITE(SCK_PIN, LOW);
|
876
|
876
|
OUT_WRITE(MOSI_PIN, HIGH);
|
877
|
877
|
OUT_WRITE(MISO_PIN, HIGH);
|
|
@@ -1004,7 +1004,7 @@ void tp_init() {
|
1004
|
1004
|
#endif //BED_MAXTEMP
|
1005
|
1005
|
}
|
1006
|
1006
|
|
1007
|
|
-#ifdef THERMAL_PROTECTION_HOTENDS
|
|
1007
|
+#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
1008
|
1008
|
/**
|
1009
|
1009
|
* Start Heating Sanity Check for hotends that are below
|
1010
|
1010
|
* their target temperature by a configurable margin.
|
|
@@ -1020,7 +1020,7 @@ void tp_init() {
|
1020
|
1020
|
}
|
1021
|
1021
|
#endif
|
1022
|
1022
|
|
1023
|
|
-#if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED)
|
|
1023
|
+#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED)
|
1024
|
1024
|
|
1025
|
1025
|
void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
|
1026
|
1026
|
|
|
@@ -1115,7 +1115,7 @@ void disable_all_heaters() {
|
1115
|
1115
|
#endif
|
1116
|
1116
|
}
|
1117
|
1117
|
|
1118
|
|
-#ifdef HEATER_0_USES_MAX6675
|
|
1118
|
+#if ENABLED(HEATER_0_USES_MAX6675)
|
1119
|
1119
|
#define MAX6675_HEAT_INTERVAL 250u
|
1120
|
1120
|
static millis_t next_max6675_ms = 0;
|
1121
|
1121
|
int max6675_temp = 2000;
|
|
@@ -1196,11 +1196,11 @@ static unsigned long raw_temp_value[4] = { 0 };
|
1196
|
1196
|
static unsigned long raw_temp_bed_value = 0;
|
1197
|
1197
|
|
1198
|
1198
|
static void set_current_temp_raw() {
|
1199
|
|
- #if HAS_TEMP_0 && !defined(HEATER_0_USES_MAX6675)
|
|
1199
|
+ #if HAS_TEMP_0 && DISABLED(HEATER_0_USES_MAX6675)
|
1200
|
1200
|
current_temperature_raw[0] = raw_temp_value[0];
|
1201
|
1201
|
#endif
|
1202
|
1202
|
#if HAS_TEMP_1
|
1203
|
|
- #ifdef TEMP_SENSOR_1_AS_REDUNDANT
|
|
1203
|
+ #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
1204
|
1204
|
redundant_temperature_raw = raw_temp_value[1];
|
1205
|
1205
|
#else
|
1206
|
1206
|
current_temperature_raw[1] = raw_temp_value[1];
|
|
@@ -1230,7 +1230,7 @@ ISR(TIMER0_COMPB_vect) {
|
1230
|
1230
|
static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
|
1231
|
1231
|
|
1232
|
1232
|
// Static members for each heater
|
1233
|
|
- #ifdef SLOW_PWM_HEATERS
|
|
1233
|
+ #if ENABLED(SLOW_PWM_HEATERS)
|
1234
|
1234
|
static unsigned char slow_pwm_count = 0;
|
1235
|
1235
|
#define ISR_STATICS(n) \
|
1236
|
1236
|
static unsigned char soft_pwm_ ## n; \
|
|
@@ -1242,7 +1242,7 @@ ISR(TIMER0_COMPB_vect) {
|
1242
|
1242
|
|
1243
|
1243
|
// Statics per heater
|
1244
|
1244
|
ISR_STATICS(0);
|
1245
|
|
- #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL)
|
|
1245
|
+ #if (EXTRUDERS > 1) || ENABLED(HEATERS_PARALLEL)
|
1246
|
1246
|
ISR_STATICS(1);
|
1247
|
1247
|
#if EXTRUDERS > 2
|
1248
|
1248
|
ISR_STATICS(2);
|
|
@@ -1259,7 +1259,7 @@ ISR(TIMER0_COMPB_vect) {
|
1259
|
1259
|
static unsigned long raw_filwidth_value = 0;
|
1260
|
1260
|
#endif
|
1261
|
1261
|
|
1262
|
|
- #ifndef SLOW_PWM_HEATERS
|
|
1262
|
+ #if DISABLED(SLOW_PWM_HEATERS)
|
1263
|
1263
|
/**
|
1264
|
1264
|
* standard PWM modulation
|
1265
|
1265
|
*/
|
|
@@ -1287,7 +1287,7 @@ ISR(TIMER0_COMPB_vect) {
|
1287
|
1287
|
soft_pwm_BED = soft_pwm_bed;
|
1288
|
1288
|
WRITE_HEATER_BED(soft_pwm_BED > 0 ? 1 : 0);
|
1289
|
1289
|
#endif
|
1290
|
|
- #ifdef FAN_SOFT_PWM
|
|
1290
|
+ #if ENABLED(FAN_SOFT_PWM)
|
1291
|
1291
|
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
1292
|
1292
|
WRITE_FAN(soft_pwm_fan > 0 ? 1 : 0);
|
1293
|
1293
|
#endif
|
|
@@ -1308,7 +1308,7 @@ ISR(TIMER0_COMPB_vect) {
|
1308
|
1308
|
if (soft_pwm_BED < pwm_count) WRITE_HEATER_BED(0);
|
1309
|
1309
|
#endif
|
1310
|
1310
|
|
1311
|
|
- #ifdef FAN_SOFT_PWM
|
|
1311
|
+ #if ENABLED(FAN_SOFT_PWM)
|
1312
|
1312
|
if (soft_pwm_fan < pwm_count) WRITE_FAN(0);
|
1313
|
1313
|
#endif
|
1314
|
1314
|
|
|
@@ -1385,7 +1385,7 @@ ISR(TIMER0_COMPB_vect) {
|
1385
|
1385
|
PWM_OFF_ROUTINE(BED); // BED
|
1386
|
1386
|
#endif
|
1387
|
1387
|
|
1388
|
|
- #ifdef FAN_SOFT_PWM
|
|
1388
|
+ #if ENABLED(FAN_SOFT_PWM)
|
1389
|
1389
|
if (pwm_count == 0) {
|
1390
|
1390
|
soft_pwm_fan = fanSpeedSoftPwm / 2;
|
1391
|
1391
|
WRITE_FAN(soft_pwm_fan > 0 ? 1 : 0);
|
|
@@ -1540,7 +1540,7 @@ ISR(TIMER0_COMPB_vect) {
|
1540
|
1540
|
for (int i = 0; i < 4; i++) raw_temp_value[i] = 0;
|
1541
|
1541
|
raw_temp_bed_value = 0;
|
1542
|
1542
|
|
1543
|
|
- #if HAS_TEMP_0 && !defined(HEATER_0_USES_MAX6675)
|
|
1543
|
+ #if HAS_TEMP_0 && DISABLED(HEATER_0_USES_MAX6675)
|
1544
|
1544
|
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
|
1545
|
1545
|
#define GE0 <=
|
1546
|
1546
|
#else
|
|
@@ -1592,7 +1592,7 @@ ISR(TIMER0_COMPB_vect) {
|
1592
|
1592
|
|
1593
|
1593
|
} // temp_count >= OVERSAMPLENR
|
1594
|
1594
|
|
1595
|
|
- #ifdef BABYSTEPPING
|
|
1595
|
+ #if ENABLED(BABYSTEPPING)
|
1596
|
1596
|
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) {
|
1597
|
1597
|
int curTodo = babystepsTodo[axis]; //get rid of volatile for performance
|
1598
|
1598
|
|
|
@@ -1608,7 +1608,7 @@ ISR(TIMER0_COMPB_vect) {
|
1608
|
1608
|
#endif //BABYSTEPPING
|
1609
|
1609
|
}
|
1610
|
1610
|
|
1611
|
|
-#ifdef PIDTEMP
|
|
1611
|
+#if ENABLED(PIDTEMP)
|
1612
|
1612
|
// Apply the scale factors to the PID values
|
1613
|
1613
|
float scalePID_i(float i) { return i * PID_dT; }
|
1614
|
1614
|
float unscalePID_i(float i) { return i / PID_dT; }
|