Add millis helper macros
This commit is contained in:
@ -399,7 +399,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
const uint16_t watch_temp_period = GTV(WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD);
|
||||
const uint8_t watch_temp_increase = GTV(WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE);
|
||||
const float watch_temp_target = target - float(watch_temp_increase + GTV(TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1);
|
||||
millis_t temp_change_ms = next_temp_ms + watch_temp_period * 1000UL;
|
||||
millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period);
|
||||
float next_watch_temp = 0.0;
|
||||
bool heated = false;
|
||||
#endif
|
||||
@ -546,7 +546,7 @@ volatile bool Temperature::raw_temps_ready = false;
|
||||
if (!heated) { // If not yet reached target...
|
||||
if (current_temp > next_watch_temp) { // Over the watch temp?
|
||||
next_watch_temp = current_temp + watch_temp_increase; // - set the next temp to watch for
|
||||
temp_change_ms = ms + watch_temp_period * 1000UL; // - move the expiration timer up
|
||||
temp_change_ms = ms + SEC_TO_MS(watch_temp_period); // - move the expiration timer up
|
||||
if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached
|
||||
}
|
||||
else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired
|
||||
@ -2051,7 +2051,7 @@ void Temperature::init() {
|
||||
#endif
|
||||
|
||||
if (current >= tr_target_temperature[heater_index] - hysteresis_degc) {
|
||||
sm.timer = millis() + period_seconds * 1000UL;
|
||||
sm.timer = millis() + SEC_TO_MS(period_seconds);
|
||||
break;
|
||||
}
|
||||
else if (PENDING(millis(), sm.timer)) break;
|
||||
@ -3124,7 +3124,7 @@ void Temperature::tick() {
|
||||
millis_t residency_start_ms = 0;
|
||||
bool first_loop = true;
|
||||
// Loop until the temperature has stabilized
|
||||
#define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_RESIDENCY_TIME) * 1000UL))
|
||||
#define TEMP_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + SEC_TO_MS(TEMP_RESIDENCY_TIME)))
|
||||
#else
|
||||
// Loop until the temperature is very close target
|
||||
#define TEMP_CONDITIONS (wants_to_cool ? isCoolingHotend(target_extruder) : isHeatingHotend(target_extruder))
|
||||
@ -3160,7 +3160,7 @@ void Temperature::tick() {
|
||||
#if TEMP_RESIDENCY_TIME > 0
|
||||
SERIAL_ECHOPGM(" W:");
|
||||
if (residency_start_ms)
|
||||
SERIAL_ECHO(long((((TEMP_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
|
||||
SERIAL_ECHO(long((SEC_TO_MS(TEMP_RESIDENCY_TIME) - (now - residency_start_ms)) / 1000UL));
|
||||
else
|
||||
SERIAL_CHAR('?');
|
||||
#endif
|
||||
@ -3185,7 +3185,7 @@ void Temperature::tick() {
|
||||
// Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
|
||||
if (temp_diff < TEMP_WINDOW) {
|
||||
residency_start_ms = now;
|
||||
if (first_loop) residency_start_ms += (TEMP_RESIDENCY_TIME) * 1000UL;
|
||||
if (first_loop) residency_start_ms += SEC_TO_MS(TEMP_RESIDENCY_TIME);
|
||||
}
|
||||
}
|
||||
else if (temp_diff > TEMP_HYSTERESIS) {
|
||||
@ -3247,7 +3247,7 @@ void Temperature::tick() {
|
||||
millis_t residency_start_ms = 0;
|
||||
bool first_loop = true;
|
||||
// Loop until the temperature has stabilized
|
||||
#define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
|
||||
#define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + SEC_TO_MS(TEMP_BED_RESIDENCY_TIME)))
|
||||
#else
|
||||
// Loop until the temperature is very close target
|
||||
#define TEMP_BED_CONDITIONS (wants_to_cool ? isCoolingBed() : isHeatingBed())
|
||||
@ -3284,7 +3284,7 @@ void Temperature::tick() {
|
||||
#if TEMP_BED_RESIDENCY_TIME > 0
|
||||
SERIAL_ECHOPGM(" W:");
|
||||
if (residency_start_ms)
|
||||
SERIAL_ECHO(long((((TEMP_BED_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
|
||||
SERIAL_ECHO(long((SEC_TO_MS(TEMP_BED_RESIDENCY_TIME) - (now - residency_start_ms)) / 1000UL));
|
||||
else
|
||||
SERIAL_CHAR('?');
|
||||
#endif
|
||||
@ -3309,7 +3309,7 @@ void Temperature::tick() {
|
||||
// Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
|
||||
if (temp_diff < TEMP_BED_WINDOW) {
|
||||
residency_start_ms = now;
|
||||
if (first_loop) residency_start_ms += (TEMP_BED_RESIDENCY_TIME) * 1000UL;
|
||||
if (first_loop) residency_start_ms += SEC_TO_MS(TEMP_BED_RESIDENCY_TIME);
|
||||
}
|
||||
}
|
||||
else if (temp_diff > TEMP_BED_HYSTERESIS) {
|
||||
@ -3373,7 +3373,7 @@ void Temperature::tick() {
|
||||
millis_t residency_start_ms = 0;
|
||||
bool first_loop = true;
|
||||
// Loop until the temperature has stabilized
|
||||
#define TEMP_CHAMBER_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_CHAMBER_RESIDENCY_TIME) * 1000UL))
|
||||
#define TEMP_CHAMBER_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + SEC_TO_MS(TEMP_CHAMBER_RESIDENCY_TIME)))
|
||||
#else
|
||||
// Loop until the temperature is very close target
|
||||
#define TEMP_CHAMBER_CONDITIONS (wants_to_cool ? isCoolingChamber() : isHeatingChamber())
|
||||
@ -3405,7 +3405,7 @@ void Temperature::tick() {
|
||||
#if TEMP_CHAMBER_RESIDENCY_TIME > 0
|
||||
SERIAL_ECHOPGM(" W:");
|
||||
if (residency_start_ms)
|
||||
SERIAL_ECHO(long((((TEMP_CHAMBER_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL));
|
||||
SERIAL_ECHO(long((SEC_TO_MS(TEMP_CHAMBER_RESIDENCY_TIME) - (now - residency_start_ms)) / 1000UL));
|
||||
else
|
||||
SERIAL_CHAR('?');
|
||||
#endif
|
||||
@ -3425,7 +3425,7 @@ void Temperature::tick() {
|
||||
// Start the TEMP_CHAMBER_RESIDENCY_TIME timer when we reach target temp for the first time.
|
||||
if (temp_diff < TEMP_CHAMBER_WINDOW) {
|
||||
residency_start_ms = now;
|
||||
if (first_loop) residency_start_ms += (TEMP_CHAMBER_RESIDENCY_TIME) * 1000UL;
|
||||
if (first_loop) residency_start_ms += SEC_TO_MS(TEMP_CHAMBER_RESIDENCY_TIME);
|
||||
}
|
||||
}
|
||||
else if (temp_diff > TEMP_CHAMBER_HYSTERESIS) {
|
||||
|
@ -241,7 +241,7 @@ struct HeaterWatch {
|
||||
const int16_t newtarget = curr + INCREASE;
|
||||
if (newtarget < tgt - HYSTERESIS - 1) {
|
||||
target = newtarget;
|
||||
next_ms = millis() + PERIOD * 1000UL;
|
||||
next_ms = millis() + SEC_TO_MS(PERIOD);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user