|
@@ -62,6 +62,9 @@ float current_temperature_bed = 0.0;
|
62
|
62
|
float bedKd=(DEFAULT_bedKd/PID_dT);
|
63
|
63
|
#endif //PIDTEMPBED
|
64
|
64
|
|
|
65
|
+#ifdef FAN_SOFT_PWM
|
|
66
|
+ unsigned char fanSpeedSoftPwm;
|
|
67
|
+#endif
|
65
|
68
|
|
66
|
69
|
//===========================================================================
|
67
|
70
|
//=============================private variables============================
|
|
@@ -145,6 +148,10 @@ int watch_start_temp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
|
145
|
148
|
unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
|
146
|
149
|
#endif //WATCH_TEMP_PERIOD
|
147
|
150
|
|
|
151
|
+#ifndef SOFT_PWM_SCALE
|
|
152
|
+#define SOFT_PWM_SCALE 0
|
|
153
|
+#endif
|
|
154
|
+
|
148
|
155
|
//===========================================================================
|
149
|
156
|
//============================= functions ============================
|
150
|
157
|
//===========================================================================
|
|
@@ -720,8 +727,8 @@ void tp_init()
|
720
|
727
|
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
|
721
|
728
|
#endif
|
722
|
729
|
#ifdef FAN_SOFT_PWM
|
723
|
|
- soft_pwm_fan=(unsigned char)fanSpeed;
|
724
|
|
- #endif
|
|
730
|
+ soft_pwm_fan = fanSpeedSoftPwm / 2;
|
|
731
|
+ #endif
|
725
|
732
|
#endif
|
726
|
733
|
|
727
|
734
|
#ifdef HEATER_0_USES_MAX6675
|
|
@@ -1028,7 +1035,7 @@ ISR(TIMER0_COMPB_vect)
|
1028
|
1035
|
static unsigned long raw_temp_2_value = 0;
|
1029
|
1036
|
static unsigned long raw_temp_bed_value = 0;
|
1030
|
1037
|
static unsigned char temp_state = 0;
|
1031
|
|
- static unsigned char pwm_count = 1;
|
|
1038
|
+ static unsigned char pwm_count = (1 << SOFT_PWM_SCALE);
|
1032
|
1039
|
static unsigned char soft_pwm_0;
|
1033
|
1040
|
#if EXTRUDERS > 1
|
1034
|
1041
|
static unsigned char soft_pwm_1;
|
|
@@ -1056,7 +1063,7 @@ ISR(TIMER0_COMPB_vect)
|
1056
|
1063
|
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1);
|
1057
|
1064
|
#endif
|
1058
|
1065
|
#ifdef FAN_SOFT_PWM
|
1059
|
|
- soft_pwm_fan =(unsigned char) fanSpeed;
|
|
1066
|
+ soft_pwm_fan = fanSpeedSoftPwm / 2;
|
1060
|
1067
|
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1);
|
1061
|
1068
|
#endif
|
1062
|
1069
|
}
|
|
@@ -1074,7 +1081,7 @@ ISR(TIMER0_COMPB_vect)
|
1074
|
1081
|
if(soft_pwm_fan <= pwm_count) WRITE(FAN_PIN,0);
|
1075
|
1082
|
#endif
|
1076
|
1083
|
|
1077
|
|
- pwm_count++;
|
|
1084
|
+ pwm_count += (1 << SOFT_PWM_SCALE);
|
1078
|
1085
|
pwm_count &= 0x7f;
|
1079
|
1086
|
|
1080
|
1087
|
switch(temp_state) {
|