|
@ -254,6 +254,11 @@ int getHeaterPower(int heater) { |
|
|
|
|
|
|
|
|
void manage_heater() |
|
|
void manage_heater() |
|
|
{ |
|
|
{ |
|
|
|
|
|
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER |
|
|
|
|
|
static int bed_needs_heating=0; |
|
|
|
|
|
static int bed_is_on=0; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#ifdef USE_WATCHDOG |
|
|
#ifdef USE_WATCHDOG |
|
|
wd_reset(); |
|
|
wd_reset(); |
|
|
#endif |
|
|
#endif |
|
@ -333,12 +338,26 @@ void manage_heater() |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER |
|
|
|
|
|
if (bed_needs_heating){ |
|
|
|
|
|
if (bed_is_on==0) |
|
|
|
|
|
WRITE(HEATER_BED_PIN,HIGH); |
|
|
|
|
|
if (bed_is_on==1) |
|
|
|
|
|
WRITE(HEATER_BED_PIN,LOW); |
|
|
|
|
|
bed_is_on=(bed_is_on+1) % HEATER_BED_DUTY_CYCLE_DIVIDER; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) |
|
|
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) |
|
|
return; |
|
|
return; |
|
|
previous_millis_bed_heater = millis(); |
|
|
previous_millis_bed_heater = millis(); |
|
|
|
|
|
|
|
|
#if TEMP_BED_PIN > -1 |
|
|
#if TEMP_BED_PIN > -1 |
|
|
|
|
|
|
|
|
|
|
|
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER |
|
|
|
|
|
bed_needs_heating=0; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef BED_LIMIT_SWITCHING |
|
|
#ifndef BED_LIMIT_SWITCHING |
|
|
// Check if temperature is within the correct range
|
|
|
// Check if temperature is within the correct range
|
|
|
if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) { |
|
|
if((current_raw_bed > bed_minttemp) && (current_raw_bed < bed_maxttemp)) { |
|
@ -348,6 +367,9 @@ void manage_heater() |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER |
|
|
|
|
|
bed_needs_heating=1; |
|
|
|
|
|
#endif |
|
|
WRITE(HEATER_BED_PIN,HIGH); |
|
|
WRITE(HEATER_BED_PIN,HIGH); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -364,6 +386,9 @@ void manage_heater() |
|
|
else |
|
|
else |
|
|
if(current_raw_bed <= target_bed_low_temp) |
|
|
if(current_raw_bed <= target_bed_low_temp) |
|
|
{ |
|
|
{ |
|
|
|
|
|
#ifdef HEATER_BED_DUTY_CYCLE_DIVIDER |
|
|
|
|
|
bed_needs_heating=1; |
|
|
|
|
|
#endif |
|
|
WRITE(HEATER_BED_PIN,HIGH); |
|
|
WRITE(HEATER_BED_PIN,HIGH); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|