Prevent 'current' name conflict, if needed
This commit is contained in:
parent
4f5e197c80
commit
565a0e11ed
6 changed files with 87 additions and 88 deletions
|
@ -831,9 +831,8 @@ void TMC26XStepper::debugLastStatus() {
|
|||
SERIAL_ECHOPAIR("\n Stall Guard value:", value);
|
||||
}
|
||||
else if (readout_config == READ_STALL_GUARD_AND_COOL_STEP) {
|
||||
int16_t stallGuard = value & 0xF, current = value & 0x1F0;
|
||||
SERIAL_ECHOPAIR("\n Approx Stall Guard: ", stallGuard);
|
||||
SERIAL_ECHOPAIR("\n Current level", current);
|
||||
SERIAL_ECHOPAIR("\n Approx Stall Guard: ", value & 0xF);
|
||||
SERIAL_ECHOPAIR("\n Current level", value & 0x1F0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -757,10 +757,10 @@
|
|||
do {
|
||||
if (do_ubl_mesh_map) display_map(g29_map_type);
|
||||
|
||||
const int current = (GRID_MAX_POINTS) - count + 1;
|
||||
SERIAL_ECHOLNPAIR("\nProbing mesh point ", current, "/", int(GRID_MAX_POINTS), ".\n");
|
||||
const int point_num = (GRID_MAX_POINTS) - count + 1;
|
||||
SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n");
|
||||
#if HAS_DISPLAY
|
||||
ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), current, int(GRID_MAX_POINTS));
|
||||
ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), point_num, int(GRID_MAX_POINTS));
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
@ -1477,7 +1477,7 @@
|
|||
|
||||
bool zig_zag = false;
|
||||
|
||||
uint16_t total_points = g29_grid_size * g29_grid_size, current = 1;
|
||||
uint16_t total_points = g29_grid_size * g29_grid_size, point_num = 1;
|
||||
|
||||
for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
|
||||
const float rx = float(x_min) + ix * dx;
|
||||
|
@ -1485,9 +1485,9 @@
|
|||
const float ry = float(y_min) + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
|
||||
|
||||
if (!abort_flag) {
|
||||
SERIAL_ECHOLNPAIR("Tilting mesh point ", current, "/", total_points, "\n");
|
||||
SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
|
||||
#if HAS_DISPLAY
|
||||
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), current, total_points);
|
||||
ui.status_printf_P(0, PSTR(MSG_LCD_TILTING_MESH " %i/%i"), point_num, total_points);
|
||||
#endif
|
||||
|
||||
measured_z = probe_pt(rx, ry, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
|
||||
|
@ -1518,7 +1518,7 @@
|
|||
incremental_LSF(&lsf_results, rx, ry, measured_z);
|
||||
}
|
||||
|
||||
current++;
|
||||
point_num++;
|
||||
}
|
||||
|
||||
zig_zag ^= true;
|
||||
|
|
|
@ -166,14 +166,14 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
|
|||
|
||||
// Temperature Data
|
||||
#if HOTENDS >= 1
|
||||
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[0].current, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
|
||||
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[0].celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
|
||||
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[0].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
|
||||
VPHELPER(VP_Flowrate_E1, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
|
||||
VPHELPER(VP_EPos, &destination[3], nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<2>),
|
||||
VPHELPER(VP_MOVE_E1, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),
|
||||
#endif
|
||||
#if HOTENDS >= 2
|
||||
VPHELPER(VP_T_E2_I, &thermalManager.temp_hotend[1].current, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>),
|
||||
VPHELPER(VP_T_E2_I, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>),
|
||||
VPHELPER(VP_T_E2_S, &thermalManager.temp_hotend[1].target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
|
||||
VPHELPER(VP_Flowrate_E2, nullptr, DGUSScreenVariableHandler::HandleFlowRateChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
|
||||
VPHELPER(VP_MOVE_E2, nullptr, &DGUSScreenVariableHandler::HandleManualExtrude, nullptr),
|
||||
|
@ -182,7 +182,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
|
|||
#error More than 2 Hotends currently not implemented on the Display UI design.
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.current, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
|
||||
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, DGUSScreenVariableHandler::DGUSLCD_SendFloatAsLongValueToDisplay<0>),
|
||||
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, DGUSScreenVariableHandler::HandleTemperatureChanged, &DGUSScreenVariableHandler::DGUSLCD_SendWordValueToDisplay),
|
||||
#endif
|
||||
|
||||
|
|
|
@ -994,23 +994,23 @@ void Planner::forward_pass() {
|
|||
// pass will never modify the values at the tail.
|
||||
uint8_t block_index = block_buffer_planned;
|
||||
|
||||
block_t *current;
|
||||
block_t *block;
|
||||
const block_t * previous = nullptr;
|
||||
while (block_index != block_buffer_head) {
|
||||
|
||||
// Perform the forward pass
|
||||
current = &block_buffer[block_index];
|
||||
block = &block_buffer[block_index];
|
||||
|
||||
// Skip SYNC blocks
|
||||
if (!TEST(current->flag, BLOCK_BIT_SYNC_POSITION)) {
|
||||
if (!TEST(block->flag, BLOCK_BIT_SYNC_POSITION)) {
|
||||
// If there's no previous block or the previous block is not
|
||||
// BUSY (thus, modifiable) run the forward_pass_kernel. Otherwise,
|
||||
// the previous block became BUSY, so assume the current block's
|
||||
// entry speed can't be altered (since that would also require
|
||||
// updating the exit speed of the previous block).
|
||||
if (!previous || !stepper.is_block_busy(previous))
|
||||
forward_pass_kernel(previous, current, block_index);
|
||||
previous = current;
|
||||
forward_pass_kernel(previous, block, block_index);
|
||||
previous = block;
|
||||
}
|
||||
// Advance to the previous
|
||||
block_index = next_block_index(block_index);
|
||||
|
@ -1045,7 +1045,7 @@ void Planner::recalculate_trapezoids() {
|
|||
}
|
||||
|
||||
// Go from the tail (currently executed block) to the first block, without including it)
|
||||
block_t *current = nullptr, *next = nullptr;
|
||||
block_t *block = nullptr, *next = nullptr;
|
||||
float current_entry_speed = 0.0, next_entry_speed = 0.0;
|
||||
while (block_index != head_block_index) {
|
||||
|
||||
|
@ -1055,41 +1055,41 @@ void Planner::recalculate_trapezoids() {
|
|||
if (!TEST(next->flag, BLOCK_BIT_SYNC_POSITION)) {
|
||||
next_entry_speed = SQRT(next->entry_speed_sqr);
|
||||
|
||||
if (current) {
|
||||
if (block) {
|
||||
// Recalculate if current block entry or exit junction speed has changed.
|
||||
if (TEST(current->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE)) {
|
||||
if (TEST(block->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE)) {
|
||||
|
||||
// Mark the current block as RECALCULATE, to protect it from the Stepper ISR running it.
|
||||
// Note that due to the above condition, there's a chance the current block isn't marked as
|
||||
// RECALCULATE yet, but the next one is. That's the reason for the following line.
|
||||
SBI(current->flag, BLOCK_BIT_RECALCULATE);
|
||||
SBI(block->flag, BLOCK_BIT_RECALCULATE);
|
||||
|
||||
// But there is an inherent race condition here, as the block maybe
|
||||
// became BUSY, just before it was marked as RECALCULATE, so check
|
||||
// if that is the case!
|
||||
if (!stepper.is_block_busy(current)) {
|
||||
if (!stepper.is_block_busy(block)) {
|
||||
// Block is not BUSY, we won the race against the Stepper ISR:
|
||||
|
||||
// NOTE: Entry and exit factors always > 0 by all previous logic operations.
|
||||
const float current_nominal_speed = SQRT(current->nominal_speed_sqr),
|
||||
const float current_nominal_speed = SQRT(block->nominal_speed_sqr),
|
||||
nomr = 1.0f / current_nominal_speed;
|
||||
calculate_trapezoid_for_block(current, current_entry_speed * nomr, next_entry_speed * nomr);
|
||||
calculate_trapezoid_for_block(block, current_entry_speed * nomr, next_entry_speed * nomr);
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
if (current->use_advance_lead) {
|
||||
const float comp = current->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS];
|
||||
current->max_adv_steps = current_nominal_speed * comp;
|
||||
current->final_adv_steps = next_entry_speed * comp;
|
||||
if (block->use_advance_lead) {
|
||||
const float comp = block->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS];
|
||||
block->max_adv_steps = current_nominal_speed * comp;
|
||||
block->final_adv_steps = next_entry_speed * comp;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Reset current only to ensure next trapezoid is computed - The
|
||||
// stepper is free to use the block from now on.
|
||||
CBI(current->flag, BLOCK_BIT_RECALCULATE);
|
||||
CBI(block->flag, BLOCK_BIT_RECALCULATE);
|
||||
}
|
||||
}
|
||||
|
||||
current = next;
|
||||
block = next;
|
||||
current_entry_speed = next_entry_speed;
|
||||
}
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ void Planner::recalculate_trapezoids() {
|
|||
// But there is an inherent race condition here, as the block maybe
|
||||
// became BUSY, just before it was marked as RECALCULATE, so check
|
||||
// if that is the case!
|
||||
if (!stepper.is_block_busy(current)) {
|
||||
if (!stepper.is_block_busy(block)) {
|
||||
// Block is not BUSY, we won the race against the Stepper ISR:
|
||||
|
||||
const float next_nominal_speed = SQRT(next->nominal_speed_sqr),
|
||||
|
|
|
@ -346,7 +346,7 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
|||
* temperature to succeed.
|
||||
*/
|
||||
void Temperature::PID_autotune(const float &target, const heater_ind_t heater, const int8_t ncycles, const bool set_result/*=false*/) {
|
||||
float current = 0.0;
|
||||
float current_temp = 0.0;
|
||||
int cycles = 0;
|
||||
bool heating = true;
|
||||
|
||||
|
@ -410,7 +410,7 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
|||
|
||||
wait_for_heatup = true; // Can be interrupted with M108
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
const float start_temp = GHV(temp_bed.current, temp_hotend[heater].current);
|
||||
const float start_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius);
|
||||
LEDColor color = ONHEATINGSTART();
|
||||
#endif
|
||||
|
||||
|
@ -427,12 +427,12 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
|||
updateTemperaturesFromRawValues();
|
||||
|
||||
// Get the current temperature and constrain it
|
||||
current = GHV(temp_bed.current, temp_hotend[heater].current);
|
||||
NOLESS(maxT, current);
|
||||
NOMORE(minT, current);
|
||||
current_temp = GHV(temp_bed.celsius, temp_hotend[heater].celsius);
|
||||
NOLESS(maxT, current_temp);
|
||||
NOMORE(minT, current_temp);
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
ONHEATING(start_temp, current, target);
|
||||
ONHEATING(start_temp, current_temp, target);
|
||||
#endif
|
||||
|
||||
#if HAS_AUTO_FAN
|
||||
|
@ -442,7 +442,7 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
|||
}
|
||||
#endif
|
||||
|
||||
if (heating && current > target) {
|
||||
if (heating && current_temp > target) {
|
||||
if (ELAPSED(ms, t2 + 5000UL)) {
|
||||
heating = false;
|
||||
SHV((bias - d) >> 1, (bias - d) >> 1);
|
||||
|
@ -452,7 +452,7 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
|||
}
|
||||
}
|
||||
|
||||
if (!heating && current < target) {
|
||||
if (!heating && current_temp < target) {
|
||||
if (ELAPSED(ms, t1 + 5000UL)) {
|
||||
heating = true;
|
||||
t2 = ms;
|
||||
|
@ -510,7 +510,7 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
|||
#ifndef MAX_OVERSHOOT_PID_AUTOTUNE
|
||||
#define MAX_OVERSHOOT_PID_AUTOTUNE 20
|
||||
#endif
|
||||
if (current > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
|
||||
if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) {
|
||||
SERIAL_ECHOLNPGM(MSG_PID_TEMP_TOO_HIGH);
|
||||
break;
|
||||
}
|
||||
|
@ -535,15 +535,15 @@ temp_range_t Temperature::temp_range[HOTENDS] = ARRAY_BY_HOTENDS(sensor_heater_0
|
|||
#endif
|
||||
) {
|
||||
if (!heated) { // If not yet reached target...
|
||||
if (current > next_watch_temp) { // Over the watch temp?
|
||||
next_watch_temp = current + watch_temp_increase; // - set the next temp to watch for
|
||||
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
|
||||
if (current > watch_temp_target) heated = true; // - Flag if target temperature reached
|
||||
if (current_temp > watch_temp_target) heated = true; // - Flag if target temperature reached
|
||||
}
|
||||
else if (ELAPSED(ms, temp_change_ms)) // Watch timer expired
|
||||
_temp_error(heater, PSTR(MSG_T_HEATING_FAILED), TEMP_ERR_PSTR(MSG_HEATING_FAILED_LCD, heater));
|
||||
}
|
||||
else if (current < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
|
||||
else if (current_temp < target - (MAX_OVERSHOOT_PID_AUTOTUNE)) // Heated, then temperature fell too far?
|
||||
_temp_error(heater, PSTR(MSG_T_THERMAL_RUNAWAY), TEMP_ERR_PSTR(MSG_THERMAL_RUNAWAY, heater));
|
||||
}
|
||||
#endif
|
||||
|
@ -685,11 +685,11 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
|
|||
uint8_t fanState = 0;
|
||||
|
||||
HOTEND_LOOP()
|
||||
if (temp_hotend[e].current >= EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||
if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||
SBI(fanState, pgm_read_byte(&fanBit[e]));
|
||||
|
||||
#if HAS_AUTO_CHAMBER_FAN
|
||||
if (temp_chamber.current >= CHAMBER_AUTO_FAN_TEMPERATURE)
|
||||
if (temp_chamber.celsius >= CHAMBER_AUTO_FAN_TEMPERATURE)
|
||||
SBI(fanState, pgm_read_byte(&fanBit[CHAMBER_FAN_INDEX]));
|
||||
#endif
|
||||
|
||||
|
@ -831,7 +831,7 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
static float temp_iState[HOTENDS] = { 0 },
|
||||
temp_dState[HOTENDS] = { 0 };
|
||||
static bool pid_reset[HOTENDS] = { false };
|
||||
const float pid_error = temp_hotend[ee].target - temp_hotend[ee].current;
|
||||
const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius;
|
||||
|
||||
if (temp_hotend[ee].target == 0
|
||||
|| pid_error < -(PID_FUNCTIONAL_RANGE)
|
||||
|
@ -853,7 +853,7 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
pid_reset[ee] = false;
|
||||
}
|
||||
|
||||
work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].current) - work_pid[ee].Kd);
|
||||
work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].celsius) - work_pid[ee].Kd);
|
||||
const float max_power_over_i_gain = float(PID_MAX) / PID_PARAM(Ki, ee) - float(MIN_POWER);
|
||||
temp_iState[ee] = constrain(temp_iState[ee] + pid_error, 0, max_power_over_i_gain);
|
||||
work_pid[ee].Kp = PID_PARAM(Kp, ee) * pid_error;
|
||||
|
@ -880,7 +880,7 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
|
||||
LIMIT(pid_output, 0, PID_MAX);
|
||||
}
|
||||
temp_dState[ee] = temp_hotend[ee].current;
|
||||
temp_dState[ee] = temp_hotend[ee].celsius;
|
||||
|
||||
#else // PID_OPENLOOP
|
||||
|
||||
|
@ -893,7 +893,7 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOPAIR(
|
||||
MSG_PID_DEBUG, ee,
|
||||
MSG_PID_DEBUG_INPUT, temp_hotend[ee].current,
|
||||
MSG_PID_DEBUG_INPUT, temp_hotend[ee].celsius,
|
||||
MSG_PID_DEBUG_OUTPUT, pid_output
|
||||
);
|
||||
#if DISABLED(PID_OPENLOOP)
|
||||
|
@ -917,7 +917,7 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
#else
|
||||
#define _TIMED_OUT_TEST false
|
||||
#endif
|
||||
pid_output = (!_TIMED_OUT_TEST && temp_hotend[ee].current < temp_hotend[ee].target) ? BANG_MAX : 0;
|
||||
pid_output = (!_TIMED_OUT_TEST && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0;
|
||||
#undef _TIMED_OUT_TEST
|
||||
|
||||
#endif
|
||||
|
@ -936,7 +936,7 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
static bool pid_reset = true;
|
||||
float pid_output = 0;
|
||||
const float max_power_over_i_gain = float(MAX_BED_POWER) / temp_bed.pid.Ki - float(MIN_BED_POWER),
|
||||
pid_error = temp_bed.target - temp_bed.current;
|
||||
pid_error = temp_bed.target - temp_bed.celsius;
|
||||
|
||||
if (!temp_bed.target || pid_error < -(PID_FUNCTIONAL_RANGE)) {
|
||||
pid_output = 0;
|
||||
|
@ -957,9 +957,9 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
|
||||
work_pid.Kp = temp_bed.pid.Kp * pid_error;
|
||||
work_pid.Ki = temp_bed.pid.Ki * temp_iState;
|
||||
work_pid.Kd = work_pid.Kd + PID_K2 * (temp_bed.pid.Kd * (temp_dState - temp_bed.current) - work_pid.Kd);
|
||||
work_pid.Kd = work_pid.Kd + PID_K2 * (temp_bed.pid.Kd * (temp_dState - temp_bed.celsius) - work_pid.Kd);
|
||||
|
||||
temp_dState = temp_bed.current;
|
||||
temp_dState = temp_bed.celsius;
|
||||
|
||||
pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_BED_POWER), 0, MAX_BED_POWER);
|
||||
}
|
||||
|
@ -973,7 +973,7 @@ float Temperature::get_pid_output_hotend(const uint8_t e) {
|
|||
#if ENABLED(PID_BED_DEBUG)
|
||||
SERIAL_ECHO_START();
|
||||
SERIAL_ECHOLNPAIR(
|
||||
" PID_BED_DEBUG : Input ", temp_bed.current, " Output ", pid_output,
|
||||
" PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output,
|
||||
#if DISABLED(PID_OPENLOOP)
|
||||
MSG_PID_DEBUG_PTERM, work_pid.Kp,
|
||||
MSG_PID_DEBUG_ITERM, work_pid.Ki,
|
||||
|
@ -1016,13 +1016,13 @@ void Temperature::manage_heater() {
|
|||
updateTemperaturesFromRawValues(); // also resets the watchdog
|
||||
|
||||
#if ENABLED(HEATER_0_USES_MAX6675)
|
||||
if (temp_hotend[0].current > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
|
||||
if (temp_hotend[0].current < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
|
||||
if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, HEATER_0_MAX6675_TMAX - 1.0)) max_temp_error(H_E0);
|
||||
if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, HEATER_0_MAX6675_TMIN + .01)) min_temp_error(H_E0);
|
||||
#endif
|
||||
|
||||
#if ENABLED(HEATER_1_USES_MAX6675)
|
||||
if (temp_hotend[1].current > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
|
||||
if (temp_hotend[1].current < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
|
||||
if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, HEATER_1_MAX6675_TMAX - 1.0)) max_temp_error(H_E1);
|
||||
if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, HEATER_1_MAX6675_TMIN + .01)) min_temp_error(H_E1);
|
||||
#endif
|
||||
|
||||
#if HAS_THERMAL_PROTECTION || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN || HEATER_IDLE_HANDLER
|
||||
|
@ -1041,10 +1041,10 @@ void Temperature::manage_heater() {
|
|||
|
||||
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
||||
// Check for thermal runaway
|
||||
thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].current, temp_hotend[e].target, (heater_ind_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
|
||||
thermal_runaway_protection(tr_state_machine[e], temp_hotend[e].celsius, temp_hotend[e].target, (heater_ind_t)e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
|
||||
#endif
|
||||
|
||||
temp_hotend[e].soft_pwm_amount = (temp_hotend[e].current > temp_range[e].mintemp || is_preheating(e)) && temp_hotend[e].current < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
|
||||
temp_hotend[e].soft_pwm_amount = (temp_hotend[e].celsius > temp_range[e].mintemp || is_preheating(e)) && temp_hotend[e].celsius < temp_range[e].maxtemp ? (int)get_pid_output_hotend(e) >> 1 : 0;
|
||||
|
||||
#if WATCH_HOTENDS
|
||||
// Make sure temperature is increasing
|
||||
|
@ -1058,7 +1058,7 @@ void Temperature::manage_heater() {
|
|||
|
||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||
// Make sure measured temperatures are close together
|
||||
if (ABS(temp_hotend[0].current - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
|
||||
if (ABS(temp_hotend[0].celsius - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
|
||||
_temp_error(H_E0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
|
||||
#endif
|
||||
|
||||
|
@ -1120,7 +1120,7 @@ void Temperature::manage_heater() {
|
|||
#endif
|
||||
|
||||
#if HAS_THERMALLY_PROTECTED_BED
|
||||
thermal_runaway_protection(tr_state_machine_bed, temp_bed.current, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS);
|
||||
thermal_runaway_protection(tr_state_machine_bed, temp_bed.celsius, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS);
|
||||
#endif
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
|
@ -1134,17 +1134,17 @@ void Temperature::manage_heater() {
|
|||
#endif
|
||||
{
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
temp_bed.soft_pwm_amount = WITHIN(temp_bed.current, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
||||
temp_bed.soft_pwm_amount = WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
||||
#else
|
||||
// Check if temperature is within the correct band
|
||||
if (WITHIN(temp_bed.current, BED_MINTEMP, BED_MAXTEMP)) {
|
||||
if (WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP)) {
|
||||
#if ENABLED(BED_LIMIT_SWITCHING)
|
||||
if (temp_bed.current >= temp_bed.target + BED_HYSTERESIS)
|
||||
if (temp_bed.celsius >= temp_bed.target + BED_HYSTERESIS)
|
||||
temp_bed.soft_pwm_amount = 0;
|
||||
else if (temp_bed.current <= temp_bed.target - (BED_HYSTERESIS))
|
||||
else if (temp_bed.celsius <= temp_bed.target - (BED_HYSTERESIS))
|
||||
temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1;
|
||||
#else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
|
||||
temp_bed.soft_pwm_amount = temp_bed.current < temp_bed.target ? MAX_BED_POWER >> 1 : 0;
|
||||
temp_bed.soft_pwm_amount = temp_bed.celsius < temp_bed.target ? MAX_BED_POWER >> 1 : 0;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
|
@ -1182,14 +1182,14 @@ void Temperature::manage_heater() {
|
|||
if (ELAPSED(ms, next_chamber_check_ms)) {
|
||||
next_chamber_check_ms = ms + CHAMBER_CHECK_INTERVAL;
|
||||
|
||||
if (WITHIN(temp_chamber.current, CHAMBER_MINTEMP, CHAMBER_MAXTEMP)) {
|
||||
if (WITHIN(temp_chamber.celsius, CHAMBER_MINTEMP, CHAMBER_MAXTEMP)) {
|
||||
#if ENABLED(CHAMBER_LIMIT_SWITCHING)
|
||||
if (temp_chamber.current >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS)
|
||||
if (temp_chamber.celsius >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS)
|
||||
temp_chamber.soft_pwm_amount = 0;
|
||||
else if (temp_chamber.current <= temp_chamber.target - (TEMP_CHAMBER_HYSTERESIS))
|
||||
else if (temp_chamber.celsius <= temp_chamber.target - (TEMP_CHAMBER_HYSTERESIS))
|
||||
temp_chamber.soft_pwm_amount = MAX_CHAMBER_POWER >> 1;
|
||||
#else
|
||||
temp_chamber.soft_pwm_amount = temp_chamber.current < temp_chamber.target ? MAX_CHAMBER_POWER >> 1 : 0;
|
||||
temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? MAX_CHAMBER_POWER >> 1 : 0;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
|
@ -1198,12 +1198,12 @@ void Temperature::manage_heater() {
|
|||
}
|
||||
|
||||
#if ENABLED(THERMAL_PROTECTION_CHAMBER)
|
||||
thermal_runaway_protection(tr_state_machine_chamber, temp_chamber.current, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS);
|
||||
thermal_runaway_protection(tr_state_machine_chamber, temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS);
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Implement true PID pwm
|
||||
//temp_bed.soft_pwm_amount = WITHIN(temp_chamber.current, CHAMBER_MINTEMP, CHAMBER_MAXTEMP) ? (int)get_pid_output_chamber() >> 1 : 0;
|
||||
//temp_bed.soft_pwm_amount = WITHIN(temp_chamber.celsius, CHAMBER_MINTEMP, CHAMBER_MAXTEMP) ? (int)get_pid_output_chamber() >> 1 : 0;
|
||||
|
||||
#endif // HAS_HEATED_CHAMBER
|
||||
}
|
||||
|
@ -1500,12 +1500,12 @@ void Temperature::updateTemperaturesFromRawValues() {
|
|||
#if ENABLED(HEATER_1_USES_MAX6675)
|
||||
temp_hotend[1].raw = READ_MAX6675(1);
|
||||
#endif
|
||||
HOTEND_LOOP() temp_hotend[e].current = analog_to_celsius_hotend(temp_hotend[e].raw, e);
|
||||
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
|
||||
#if HAS_HEATED_BED
|
||||
temp_bed.current = analog_to_celsius_bed(temp_bed.raw);
|
||||
temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw);
|
||||
#endif
|
||||
#if HAS_TEMP_CHAMBER
|
||||
temp_chamber.current = analog_to_celsius_chamber(temp_chamber.raw);
|
||||
temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw);
|
||||
#endif
|
||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||
redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1);
|
||||
|
|
|
@ -158,7 +158,7 @@ enum ADCSensorState : char {
|
|||
typedef struct TempInfo {
|
||||
uint16_t acc;
|
||||
int16_t raw;
|
||||
float current;
|
||||
float celsius;
|
||||
inline void reset() { acc = 0; }
|
||||
inline void sample(const uint16_t s) { acc += s; }
|
||||
inline void update() { raw = acc; }
|
||||
|
@ -577,7 +577,7 @@ class Temperature {
|
|||
|
||||
FORCE_INLINE static float degHotend(const uint8_t e) {
|
||||
E_UNUSED();
|
||||
return temp_hotend[HOTEND_INDEX].current;
|
||||
return temp_hotend[HOTEND_INDEX].celsius;
|
||||
}
|
||||
|
||||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
|
@ -625,12 +625,12 @@ class Temperature {
|
|||
|
||||
FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
|
||||
E_UNUSED();
|
||||
return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].current;
|
||||
return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius;
|
||||
}
|
||||
|
||||
FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
|
||||
E_UNUSED();
|
||||
return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].current;
|
||||
return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius;
|
||||
}
|
||||
|
||||
#if HAS_TEMP_HOTEND
|
||||
|
@ -650,10 +650,10 @@ class Temperature {
|
|||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; }
|
||||
#endif
|
||||
FORCE_INLINE static float degBed() { return temp_bed.current; }
|
||||
FORCE_INLINE static float degBed() { return temp_bed.celsius; }
|
||||
FORCE_INLINE static int16_t degTargetBed() { return temp_bed.target; }
|
||||
FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.current; }
|
||||
FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.current; }
|
||||
FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; }
|
||||
FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; }
|
||||
|
||||
#if WATCH_BED
|
||||
static void start_watching_bed();
|
||||
|
@ -687,11 +687,11 @@ class Temperature {
|
|||
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
||||
FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; }
|
||||
#endif
|
||||
FORCE_INLINE static float degChamber() { return temp_chamber.current; }
|
||||
FORCE_INLINE static float degChamber() { return temp_chamber.celsius; }
|
||||
#if HAS_HEATED_CHAMBER
|
||||
FORCE_INLINE static int16_t degTargetChamber() { return temp_chamber.target; }
|
||||
FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.current; }
|
||||
FORCE_INLINE static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.current; }
|
||||
FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; }
|
||||
FORCE_INLINE static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; }
|
||||
|
||||
static bool wait_for_chamber(const bool no_wait_for_cooling=true);
|
||||
#endif
|
||||
|
|
Reference in a new issue