next_ vars faster than previous_

- Change some `previous_` time vars to `next_` so an add only happens
at intervals
- Fix `HEATER_0_USES_MAX6675` polling too frequently, or not at all
master
Scott Lahteine 10 years ago
parent cfa60bdb97
commit e4b1e8651b

@ -118,7 +118,7 @@ static volatile bool temp_meas_ready = false;
static float temp_iState_min_bed; static float temp_iState_min_bed;
static float temp_iState_max_bed; static float temp_iState_max_bed;
#else //PIDTEMPBED #else //PIDTEMPBED
static millis_t previous_bed_check_ms; static millis_t next_bed_check_ms;
#endif //PIDTEMPBED #endif //PIDTEMPBED
static unsigned char soft_pwm[EXTRUDERS]; static unsigned char soft_pwm[EXTRUDERS];
@ -126,7 +126,7 @@ static volatile bool temp_meas_ready = false;
static unsigned char soft_pwm_fan; static unsigned char soft_pwm_fan;
#endif #endif
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
static millis_t previous_auto_fan_check_ms; static millis_t next_auto_fan_check_ms;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
@ -205,7 +205,7 @@ void PID_autotune(float temp, int extruder, int ncycles)
float max = 0, min = 10000; float max = 0, min = 10000;
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
millis_t previous_auto_fan_check_ms = temp_ms; millis_t next_auto_fan_check_ms = temp_ms + 2500;
#endif #endif
if (extruder >= EXTRUDERS if (extruder >= EXTRUDERS
@ -240,9 +240,9 @@ void PID_autotune(float temp, int extruder, int ncycles)
min = min(min, input); min = min(min, input);
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
if (ms > previous_auto_fan_check_ms + 2500) { if (ms > next_auto_fan_check_ms) {
checkExtruderAutoFans(); checkExtruderAutoFans();
previous_auto_fan_check_ms = ms; next_auto_fan_check_ms = ms + 2500;
} }
#endif #endif
@ -631,16 +631,16 @@ void manage_heater() {
} // Extruders Loop } // Extruders Loop
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
if (ms > previous_auto_fan_check_ms + 2500) { // only need to check fan state very infrequently if (ms > next_auto_fan_check_ms) { // only need to check fan state very infrequently
checkExtruderAutoFans(); checkExtruderAutoFans();
previous_auto_fan_check_ms = ms; next_auto_fan_check_ms = ms + 2500;
} }
#endif #endif
#ifndef PIDTEMPBED #ifndef PIDTEMPBED
if (ms < previous_bed_check_ms + BED_CHECK_INTERVAL) return; if (ms < previous_bed_check_ms) return;
previous_bed_check_ms = ms; next_bed_check_ms = ms + BED_CHECK_INTERVAL;
#endif //PIDTEMPBED #endif
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
@ -1109,16 +1109,18 @@ void disable_heater() {
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
#define MAX6675_HEAT_INTERVAL 250u #define MAX6675_HEAT_INTERVAL 250u
millis_t previous_max6675_ms = MAX6675_HEAT_INTERVAL; static millis_t next_max6675_ms = 0;
int max6675_temp = 2000; int max6675_temp = 2000;
static int read_max6675() { static int read_max6675() {
millis_t ms = millis(); millis_t ms = millis();
if (ms < previous_max6675_ms + MAX6675_HEAT_INTERVAL)
if (ms < next_max6675_ms)
return max6675_temp; return max6675_temp;
previous_max6675_ms = ms; next_max6675_ms = ms + MAX6675_HEAT_INTERVAL;
max6675_temp = 0; max6675_temp = 0;
#ifdef PRR #ifdef PRR

Loading…
Cancel
Save