From a5198e32a3d041024fbf327d0e380bbd69543a5f Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 29 Jan 2020 22:44:19 +0200 Subject: [PATCH] Just keep the current state. ON or OFF. No switching allowed --- Firmware/heatbed_pwm.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Firmware/heatbed_pwm.cpp b/Firmware/heatbed_pwm.cpp index 1e467c4e8..612cf3c86 100755 --- a/Firmware/heatbed_pwm.cpp +++ b/Firmware/heatbed_pwm.cpp @@ -139,19 +139,15 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine break; case States::ONE: // state ONE - we'll either stay in ONE or change to FALL OCR0B = 255; + if (bedPWMDisabled) return; slowCounter += slowInc; // this does software timer_clk/256 or less - if (!bedPWMDisabled){ //disable heating as soon as possible - if( slowCounter < pwm ){ - return; - } - if( (soft_pwm_bed << 1) >= (255 - slowInc - 1) ){ //@@TODO simplify & explain - // if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating - return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf - } - } - else if (pwm > 200){ //if duty cycle is high and BED PWM is disabled keep heater on. Prevents overcooling + if( slowCounter < pwm ){ return; } + if( (soft_pwm_bed << 1) >= (255 - slowInc - 1) ){ //@@TODO simplify & explain + // if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating + return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf + } // otherwise moving towards FALL // @@TODO it looks like ONE_TO_FALL isn't necessary, there are no artefacts at all state = States::ONE;//_TO_FALL;