Browse Source

Merge pull request #6559 from thinkyhead/rc_more_optimal

Compact smart_fill_mesh slightly
pull/1/head
Scott Lahteine 8 years ago
committed by GitHub
parent
commit
e1b85ff67b
  1. 31
      Marlin/G26_Mesh_Validation_Tool.cpp
  2. 2
      Marlin/M100_Free_Mem_Chk.cpp
  3. 16
      Marlin/Marlin.h
  4. 85
      Marlin/Marlin_main.cpp
  5. 5
      Marlin/planner.cpp
  6. 56
      Marlin/temperature.cpp
  7. 60
      Marlin/temperature.h
  8. 37
      Marlin/ubl_G29.cpp
  9. 4
      Marlin/ultralcd.cpp

31
Marlin/G26_Mesh_Validation_Tool.cpp

@ -126,6 +126,8 @@
void set_destination_to_current(); void set_destination_to_current();
void set_current_to_destination(); void set_current_to_destination();
float code_value_float(); float code_value_float();
float code_value_linear_units();
float code_value_axis_units(const AxisEnum axis);
bool code_value_bool(); bool code_value_bool();
bool code_has_value(); bool code_has_value();
void lcd_init(); void lcd_init();
@ -164,10 +166,11 @@
filament_diameter = FILAMENT, filament_diameter = FILAMENT,
prime_length = PRIME_LENGTH, prime_length = PRIME_LENGTH,
x_pos, y_pos, x_pos, y_pos,
bed_temp = BED_TEMP,
hotend_temp = HOTEND_TEMP,
ooze_amount = OOZE_AMOUNT; ooze_amount = OOZE_AMOUNT;
static int16_t bed_temp = BED_TEMP,
hotend_temp = HOTEND_TEMP;
static int8_t prime_flag = 0; static int8_t prime_flag = 0;
static bool keep_heaters_on = false; static bool keep_heaters_on = false;
@ -379,9 +382,9 @@
if (!keep_heaters_on) { if (!keep_heaters_on) {
#if HAS_TEMP_BED #if HAS_TEMP_BED
thermalManager.setTargetBed(0.0); thermalManager.setTargetBed(0);
#endif #endif
thermalManager.setTargetHotend(0.0, 0); thermalManager.setTargetHotend(0, 0);
} }
} }
@ -640,8 +643,8 @@
keep_heaters_on = false; keep_heaters_on = false;
if (code_seen('B')) { if (code_seen('B')) {
bed_temp = code_value_float(); bed_temp = code_value_temp_abs();
if (!WITHIN(bed_temp, 15.0, 140.0)) { if (!WITHIN(bed_temp, 15, 140)) {
SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible."); SERIAL_PROTOCOLLNPGM("?Specified bed temperature not plausible.");
return UBL_ERR; return UBL_ERR;
} }
@ -650,7 +653,7 @@
if (code_seen('C')) continue_with_closest++; if (code_seen('C')) continue_with_closest++;
if (code_seen('L')) { if (code_seen('L')) {
layer_height = code_value_float(); layer_height = code_value_linear_units();
if (!WITHIN(layer_height, 0.0, 2.0)) { if (!WITHIN(layer_height, 0.0, 2.0)) {
SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible."); SERIAL_PROTOCOLLNPGM("?Specified layer height not plausible.");
return UBL_ERR; return UBL_ERR;
@ -682,14 +685,14 @@
if (code_seen('K')) keep_heaters_on++; if (code_seen('K')) keep_heaters_on++;
if (code_seen('O') && code_has_value()) if (code_seen('O') && code_has_value())
ooze_amount = code_value_float(); ooze_amount = code_value_linear_units();
if (code_seen('P')) { if (code_seen('P')) {
if (!code_has_value()) if (!code_has_value())
prime_flag = -1; prime_flag = -1;
else { else {
prime_flag++; prime_flag++;
prime_length = code_value_float(); prime_length = code_value_linear_units();
if (!WITHIN(prime_length, 0.0, 25.0)) { if (!WITHIN(prime_length, 0.0, 25.0)) {
SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible."); SERIAL_PROTOCOLLNPGM("?Specified prime length not plausible.");
return UBL_ERR; return UBL_ERR;
@ -698,7 +701,7 @@
} }
if (code_seen('F')) { if (code_seen('F')) {
filament_diameter = code_value_float(); filament_diameter = code_value_linear_units();
if (!WITHIN(filament_diameter, 1.0, 4.0)) { if (!WITHIN(filament_diameter, 1.0, 4.0)) {
SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible."); SERIAL_PROTOCOLLNPGM("?Specified filament size not plausible.");
return UBL_ERR; return UBL_ERR;
@ -711,8 +714,8 @@
extrusion_multiplier *= filament_diameter * sq(nozzle) / sq(0.3); // Scale up by nozzle size extrusion_multiplier *= filament_diameter * sq(nozzle) / sq(0.3); // Scale up by nozzle size
if (code_seen('H')) { if (code_seen('H')) {
hotend_temp = code_value_float(); hotend_temp = code_value_temp_abs();
if (!WITHIN(hotend_temp, 165.0, 280.0)) { if (!WITHIN(hotend_temp, 165, 280)) {
SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible."); SERIAL_PROTOCOLLNPGM("?Specified nozzle temperature not plausible.");
return UBL_ERR; return UBL_ERR;
} }
@ -727,7 +730,7 @@
y_pos = current_position[Y_AXIS]; y_pos = current_position[Y_AXIS];
if (code_seen('X')) { if (code_seen('X')) {
x_pos = code_value_float(); x_pos = code_value_axis_units(X_AXIS);
if (!WITHIN(x_pos, X_MIN_POS, X_MAX_POS)) { if (!WITHIN(x_pos, X_MIN_POS, X_MAX_POS)) {
SERIAL_PROTOCOLLNPGM("?Specified X coordinate not plausible."); SERIAL_PROTOCOLLNPGM("?Specified X coordinate not plausible.");
return UBL_ERR; return UBL_ERR;
@ -736,7 +739,7 @@
else else
if (code_seen('Y')) { if (code_seen('Y')) {
y_pos = code_value_float(); y_pos = code_value_axis_units(Y_AXIS);
if (!WITHIN(y_pos, Y_MIN_POS, Y_MAX_POS)) { if (!WITHIN(y_pos, Y_MIN_POS, Y_MAX_POS)) {
SERIAL_PROTOCOLLNPGM("?Specified Y coordinate not plausible."); SERIAL_PROTOCOLLNPGM("?Specified Y coordinate not plausible.");
return UBL_ERR; return UBL_ERR;

2
Marlin/M100_Free_Mem_Chk.cpp

@ -241,7 +241,7 @@ void gcode_M100() {
SERIAL_ECHOPAIR("\n__brkval : ", hex_address(__brkval)); SERIAL_ECHOPAIR("\n__brkval : ", hex_address(__brkval));
SERIAL_ECHOPAIR("\n__bss_end : ", hex_address(&__bss_end)); SERIAL_ECHOPAIR("\n__bss_end : ", hex_address(&__bss_end));
uint8_t *ptr = END_OF_HEAP(), *sp = top_of_stack(); char *ptr = END_OF_HEAP(), *sp = top_of_stack();
SERIAL_ECHOPAIR("\nstart of free space : ", hex_address(ptr)); SERIAL_ECHOPAIR("\nstart of free space : ", hex_address(ptr));
SERIAL_ECHOLNPAIR("\nStack Pointer : ", hex_address(sp)); SERIAL_ECHOLNPAIR("\nStack Pointer : ", hex_address(sp));

16
Marlin/Marlin.h

@ -290,8 +290,18 @@ extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
// GCode support for external objects // GCode support for external objects
bool code_seen(char); bool code_seen(char);
int code_value_int(); int code_value_int();
float code_value_temp_abs(); int16_t code_value_temp_abs();
float code_value_temp_diff(); int16_t code_value_temp_diff();
#if ENABLED(INCH_MODE_SUPPORT)
float code_value_linear_units();
float code_value_axis_units(const AxisEnum axis);
float code_value_per_axis_unit(const AxisEnum axis);
#else
#define code_value_linear_units() code_value_float()
#define code_value_axis_units(A) code_value_float()
#define code_value_per_axis_unit(A) code_value_float()
#endif
#if IS_KINEMATIC #if IS_KINEMATIC
extern float delta[ABC]; extern float delta[ABC];
@ -351,7 +361,7 @@ float code_value_temp_diff();
#endif #endif
#if FAN_COUNT > 0 #if FAN_COUNT > 0
extern int fanSpeeds[FAN_COUNT]; extern int16_t fanSpeeds[FAN_COUNT];
#endif #endif
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)

85
Marlin/Marlin_main.cpp

@ -440,7 +440,7 @@ float soft_endstop_min[XYZ] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS },
soft_endstop_max[XYZ] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; soft_endstop_max[XYZ] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
#if FAN_COUNT > 0 #if FAN_COUNT > 0
int fanSpeeds[FAN_COUNT] = { 0 }; int16_t fanSpeeds[FAN_COUNT] = { 0 };
#endif #endif
// The active extruder (tool). Set with T<extruder> command. // The active extruder (tool). Set with T<extruder> command.
@ -1292,32 +1292,24 @@ inline bool code_value_bool() { return !code_has_value() || code_value_byte() >
inline float code_value_linear_units() { return code_value_float() * linear_unit_factor; } inline float code_value_linear_units() { return code_value_float() * linear_unit_factor; }
inline float code_value_axis_units(const AxisEnum axis) { return code_value_float() * axis_unit_factor(axis); } inline float code_value_axis_units(const AxisEnum axis) { return code_value_float() * axis_unit_factor(axis); }
inline float code_value_per_axis_unit(const AxisEnum axis) { return code_value_float() / axis_unit_factor(axis); } inline float code_value_per_axis_unit(const AxisEnum axis) { return code_value_float() / axis_unit_factor(axis); }
#else
#define code_value_linear_units() code_value_float()
#define code_value_axis_units(A) code_value_float()
#define code_value_per_axis_unit(A) code_value_float()
#endif #endif
#if ENABLED(TEMPERATURE_UNITS_SUPPORT) #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
inline void set_input_temp_units(TempUnit units) { input_temp_units = units; } inline void set_input_temp_units(TempUnit units) { input_temp_units = units; }
float code_value_temp_abs() { int16_t code_value_temp_abs() {
switch (input_temp_units) { switch (input_temp_units) {
case TEMPUNIT_C:
return code_value_float();
case TEMPUNIT_F: case TEMPUNIT_F:
return (code_value_float() - 32) * 0.5555555556; return (code_value_float() - 32) * 0.5555555556;
case TEMPUNIT_K: case TEMPUNIT_K:
return code_value_float() - 273.15; return code_value_float() - 273.15;
case TEMPUNIT_C:
default: default:
return code_value_float(); return code_value_int();
} }
} }
float code_value_temp_diff() { int16_t code_value_temp_diff() {
switch (input_temp_units) { switch (input_temp_units) {
case TEMPUNIT_C: case TEMPUNIT_C:
case TEMPUNIT_K: case TEMPUNIT_K:
@ -1329,8 +1321,8 @@ inline bool code_value_bool() { return !code_has_value() || code_value_byte() >
} }
} }
#else #else
float code_value_temp_abs() { return code_value_float(); } int16_t code_value_temp_abs() { return code_value_int(); }
float code_value_temp_diff() { return code_value_float(); } int16_t code_value_temp_diff() { return code_value_int(); }
#endif #endif
FORCE_INLINE millis_t code_value_millis() { return code_value_ulong(); } FORCE_INLINE millis_t code_value_millis() { return code_value_ulong(); }
@ -1391,7 +1383,7 @@ bool get_target_extruder_from_command(int code) {
static float raised_parked_position[XYZE]; // used in mode 1 static float raised_parked_position[XYZE]; // used in mode 1
static millis_t delayed_move_time = 0; // used in mode 1 static millis_t delayed_move_time = 0; // used in mode 1
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
static float duplicate_extruder_temp_offset = 0; // used in mode 2 static int16_t duplicate_extruder_temp_offset = 0; // used in mode 2
#endif // DUAL_X_CARRIAGE #endif // DUAL_X_CARRIAGE
@ -2080,10 +2072,10 @@ static void clean_up_after_endstop_or_probe_move() {
void set_heaters_for_bltouch(const bool deploy) { void set_heaters_for_bltouch(const bool deploy) {
static bool heaters_were_disabled = false; static bool heaters_were_disabled = false;
static millis_t next_emi_protection = 0; static millis_t next_emi_protection = 0;
static float temps_at_entry[HOTENDS]; static int16_t temps_at_entry[HOTENDS];
#if HAS_TEMP_BED #if HAS_TEMP_BED
static float bed_temp_at_entry; static int16_t bed_temp_at_entry;
#endif #endif
// If called out of order or far apart something is seriously wrong // If called out of order or far apart something is seriously wrong
@ -2588,7 +2580,7 @@ static void clean_up_after_endstop_or_probe_move() {
/** /**
* Extrapolate a single point from its neighbors * Extrapolate a single point from its neighbors
*/ */
static void extrapolate_one_point(uint8_t x, uint8_t y, int8_t xdir, int8_t ydir) { static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPGM("Extrapolate ["); SERIAL_ECHOPGM("Extrapolate [");
@ -2611,9 +2603,10 @@ static void clean_up_after_endstop_or_probe_move() {
SERIAL_EOL; SERIAL_EOL;
// Get X neighbors, Y neighbors, and XY neighbors // Get X neighbors, Y neighbors, and XY neighbors
float a1 = z_values[x + xdir][y], a2 = z_values[x + xdir * 2][y], const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir;
b1 = z_values[x][y + ydir], b2 = z_values[x][y + ydir * 2], float a1 = z_values[x1][y ], a2 = z_values[x2][y ],
c1 = z_values[x + xdir][y + ydir], c2 = z_values[x + xdir * 2][y + ydir * 2]; b1 = z_values[x ][y1], b2 = z_values[x ][y2],
c1 = z_values[x1][y1], c2 = z_values[x2][y2];
// Treat far unprobed points as zero, near as equal to far // Treat far unprobed points as zero, near as equal to far
if (isnan(a2)) a2 = 0.0; if (isnan(a1)) a1 = a2; if (isnan(a2)) a2 = 0.0; if (isnan(a1)) a1 = a2;
@ -2647,19 +2640,19 @@ static void clean_up_after_endstop_or_probe_move() {
*/ */
static void extrapolate_unprobed_bed_level() { static void extrapolate_unprobed_bed_level() {
#ifdef HALF_IN_X #ifdef HALF_IN_X
const uint8_t ctrx2 = 0, xlen = GRID_MAX_POINTS_X - 1; constexpr uint8_t ctrx2 = 0, xlen = GRID_MAX_POINTS_X - 1;
#else #else
const uint8_t ctrx1 = (GRID_MAX_POINTS_X - 1) / 2, // left-of-center constexpr uint8_t ctrx1 = (GRID_MAX_POINTS_X - 1) / 2, // left-of-center
ctrx2 = GRID_MAX_POINTS_X / 2, // right-of-center ctrx2 = (GRID_MAX_POINTS_X) / 2, // right-of-center
xlen = ctrx1; xlen = ctrx1;
#endif #endif
#ifdef HALF_IN_Y #ifdef HALF_IN_Y
const uint8_t ctry2 = 0, ylen = GRID_MAX_POINTS_Y - 1; constexpr uint8_t ctry2 = 0, ylen = GRID_MAX_POINTS_Y - 1;
#else #else
const uint8_t ctry1 = (GRID_MAX_POINTS_Y - 1) / 2, // top-of-center constexpr uint8_t ctry1 = (GRID_MAX_POINTS_Y - 1) / 2, // top-of-center
ctry2 = GRID_MAX_POINTS_Y / 2, // bottom-of-center ctry2 = (GRID_MAX_POINTS_Y) / 2, // bottom-of-center
ylen = ctry1; ylen = ctry1;
#endif #endif
for (uint8_t xo = 0; xo <= xlen; xo++) for (uint8_t xo = 0; xo <= xlen; xo++)
@ -6477,10 +6470,11 @@ inline void gcode_M104() {
#endif #endif
if (code_seen('S')) { if (code_seen('S')) {
thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder); const int16_t temp = code_value_temp_abs();
thermalManager.setTargetHotend(temp, target_extruder);
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0) if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
thermalManager.setTargetHotend(code_value_temp_abs() == 0.0 ? 0.0 : code_value_temp_abs() + duplicate_extruder_temp_offset, 1); thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
#endif #endif
#if ENABLED(PRINTJOB_TIMER_AUTOSTART) #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
@ -6490,7 +6484,7 @@ inline void gcode_M104() {
* standby mode, for instance in a dual extruder setup, without affecting * standby mode, for instance in a dual extruder setup, without affecting
* the running print timer. * the running print timer.
*/ */
if (code_value_temp_abs() <= (EXTRUDE_MINTEMP)/2) { if (code_value_temp_abs() <= (EXTRUDE_MINTEMP) / 2) {
print_job_timer.stop(); print_job_timer.stop();
LCD_MESSAGEPGM(WELCOME_MSG); LCD_MESSAGEPGM(WELCOME_MSG);
} }
@ -6513,7 +6507,7 @@ inline void gcode_M104() {
SERIAL_PROTOCOLPGM(" /"); SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(target_extruder), 1); SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(target_extruder), 1);
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_raw[target_extruder] / OVERSAMPLENR); SERIAL_PROTOCOLPAIR(" (", thermalManager.rawHotendTemp(target_extruder) / OVERSAMPLENR);
SERIAL_PROTOCOLCHAR(')'); SERIAL_PROTOCOLCHAR(')');
#endif #endif
#endif #endif
@ -6523,7 +6517,7 @@ inline void gcode_M104() {
SERIAL_PROTOCOLPGM(" /"); SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(thermalManager.degTargetBed(), 1); SERIAL_PROTOCOL_F(thermalManager.degTargetBed(), 1);
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_bed_raw / OVERSAMPLENR); SERIAL_PROTOCOLPAIR(" (", thermalManager.rawBedTemp() / OVERSAMPLENR);
SERIAL_PROTOCOLCHAR(')'); SERIAL_PROTOCOLCHAR(')');
#endif #endif
#endif #endif
@ -6535,7 +6529,7 @@ inline void gcode_M104() {
SERIAL_PROTOCOLPGM(" /"); SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(e), 1); SERIAL_PROTOCOL_F(thermalManager.degTargetHotend(e), 1);
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
SERIAL_PROTOCOLPAIR(" (", thermalManager.current_temperature_raw[e] / OVERSAMPLENR); SERIAL_PROTOCOLPAIR(" (", thermalManager.rawHotendTemp(e) / OVERSAMPLENR);
SERIAL_PROTOCOLCHAR(')'); SERIAL_PROTOCOLCHAR(')');
#endif #endif
} }
@ -6671,10 +6665,11 @@ inline void gcode_M109() {
const bool no_wait_for_cooling = code_seen('S'); const bool no_wait_for_cooling = code_seen('S');
if (no_wait_for_cooling || code_seen('R')) { if (no_wait_for_cooling || code_seen('R')) {
thermalManager.setTargetHotend(code_value_temp_abs(), target_extruder); const int16_t temp = code_value_temp_abs();
thermalManager.setTargetHotend(temp, target_extruder);
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0) if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
thermalManager.setTargetHotend(code_value_temp_abs() == 0.0 ? 0.0 : code_value_temp_abs() + duplicate_extruder_temp_offset, 1); thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
#endif #endif
#if ENABLED(PRINTJOB_TIMER_AUTOSTART) #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
@ -7202,7 +7197,7 @@ inline void gcode_M92() {
LOOP_XYZE(i) { LOOP_XYZE(i) {
if (code_seen(axis_codes[i])) { if (code_seen(axis_codes[i])) {
if (i == E_AXIS) { if (i == E_AXIS) {
const float value = code_value_per_axis_unit(E_AXIS + TARGET_EXTRUDER); const float value = code_value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
if (value < 20.0) { if (value < 20.0) {
float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab. float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
planner.max_jerk[E_AXIS] *= factor; planner.max_jerk[E_AXIS] *= factor;
@ -7212,7 +7207,7 @@ inline void gcode_M92() {
planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value; planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] = value;
} }
else { else {
planner.axis_steps_per_mm[i] = code_value_per_axis_unit(i); planner.axis_steps_per_mm[i] = code_value_per_axis_unit((AxisEnum)i);
} }
} }
} }
@ -8106,11 +8101,11 @@ inline void gcode_M226() {
*/ */
inline void gcode_M303() { inline void gcode_M303() {
#if HAS_PID_HEATING #if HAS_PID_HEATING
int e = code_seen('E') ? code_value_int() : 0; const int e = code_seen('E') ? code_value_int() : 0,
int c = code_seen('C') ? code_value_int() : 5; c = code_seen('C') ? code_value_int() : 5;
bool u = code_seen('U') && code_value_bool(); const bool u = code_seen('U') && code_value_bool();
float temp = code_seen('S') ? code_value_temp_abs() : (e < 0 ? 70.0 : 150.0); int16_t temp = code_seen('S') ? code_value_temp_abs() : (e < 0 ? 70 : 150);
if (WITHIN(e, 0, HOTENDS - 1)) if (WITHIN(e, 0, HOTENDS - 1))
target_extruder = e; target_extruder = e;
@ -8747,7 +8742,6 @@ inline void gcode_M503() {
const millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL; const millis_t nozzle_timeout = millis() + (millis_t)(FILAMENT_CHANGE_NOZZLE_TIMEOUT) * 1000UL;
bool nozzle_timed_out = false; bool nozzle_timed_out = false;
float temps[4];
// Wait for filament insert by user and press button // Wait for filament insert by user and press button
lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT); lcd_filament_change_show_message(FILAMENT_CHANGE_MESSAGE_INSERT);
@ -8758,6 +8752,7 @@ inline void gcode_M503() {
idle(); idle();
int16_t temps[HOTENDS];
HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps HOTEND_LOOP() temps[e] = thermalManager.target_temperature[e]; // Save nozzle temps
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);

5
Marlin/planner.cpp

@ -387,10 +387,7 @@ void Planner::recalculate() {
float t = autotemp_min + high * autotemp_factor; float t = autotemp_min + high * autotemp_factor;
t = constrain(t, autotemp_min, autotemp_max); t = constrain(t, autotemp_min, autotemp_max);
if (oldt > t) { if (t < oldt) t = t * (1 - (AUTOTEMP_OLDWEIGHT)) + oldt * (AUTOTEMP_OLDWEIGHT);
t *= (1 - (AUTOTEMP_OLDWEIGHT));
t += (AUTOTEMP_OLDWEIGHT) * oldt;
}
oldt = t; oldt = t;
thermalManager.setTargetHotend(t, 0); thermalManager.setTargetHotend(t, 0);
} }

56
Marlin/temperature.cpp

@ -64,10 +64,10 @@ Temperature thermalManager;
float Temperature::current_temperature[HOTENDS] = { 0.0 }, float Temperature::current_temperature[HOTENDS] = { 0.0 },
Temperature::current_temperature_bed = 0.0; Temperature::current_temperature_bed = 0.0;
int Temperature::current_temperature_raw[HOTENDS] = { 0 }, int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
Temperature::target_temperature[HOTENDS] = { 0 }, Temperature::target_temperature[HOTENDS] = { 0 },
Temperature::current_temperature_bed_raw = 0, Temperature::current_temperature_bed_raw = 0,
Temperature::target_temperature_bed = 0; Temperature::target_temperature_bed = 0;
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
float Temperature::redundant_temperature = 0.0; float Temperature::redundant_temperature = 0.0;
@ -160,33 +160,33 @@ volatile bool Temperature::temp_meas_ready = false;
millis_t Temperature::next_bed_check_ms; millis_t Temperature::next_bed_check_ms;
#endif #endif
unsigned long Temperature::raw_temp_value[MAX_EXTRUDERS] = { 0 }; uint16_t Temperature::raw_temp_value[MAX_EXTRUDERS] = { 0 },
unsigned long Temperature::raw_temp_bed_value = 0; Temperature::raw_temp_bed_value = 0;
// Init min and max temp with extreme values to prevent false errors during startup // Init min and max temp with extreme values to prevent false errors during startup
int Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP, HEATER_4_RAW_LO_TEMP), int16_t Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP, HEATER_4_RAW_LO_TEMP),
Temperature::maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP, HEATER_4_RAW_HI_TEMP), Temperature::maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP, HEATER_4_RAW_HI_TEMP),
Temperature::minttemp[HOTENDS] = { 0 }, Temperature::minttemp[HOTENDS] = { 0 },
Temperature::maxttemp[HOTENDS] = ARRAY_BY_HOTENDS1(16383); Temperature::maxttemp[HOTENDS] = ARRAY_BY_HOTENDS1(16383);
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
int Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 }; uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };
#endif #endif
#ifdef MILLISECONDS_PREHEAT_TIME #ifdef MILLISECONDS_PREHEAT_TIME
unsigned long Temperature::preheat_end_time[HOTENDS] = { 0 }; millis_t Temperature::preheat_end_time[HOTENDS] = { 0 };
#endif #endif
#ifdef BED_MINTEMP #ifdef BED_MINTEMP
int Temperature::bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; int16_t Temperature::bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP;
#endif #endif
#ifdef BED_MAXTEMP #ifdef BED_MAXTEMP
int Temperature::bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP; int16_t Temperature::bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
#endif #endif
#if ENABLED(FILAMENT_WIDTH_SENSOR) #if ENABLED(FILAMENT_WIDTH_SENSOR)
int Temperature::meas_shift_index; // Index of a delayed sample in buffer int16_t Temperature::meas_shift_index; // Index of a delayed sample in buffer
#endif #endif
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
@ -1242,7 +1242,7 @@ void Temperature::init() {
millis_t Temperature::thermal_runaway_bed_timer; millis_t Temperature::thermal_runaway_bed_timer;
#endif #endif
void Temperature::thermal_runaway_protection(Temperature::TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { void Temperature::thermal_runaway_protection(Temperature::TRState* state, millis_t* timer, float current, float target, int heater_id, int period_seconds, int hysteresis_degc) {
static float tr_target_temperature[HOTENDS + 1] = { 0.0 }; static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
@ -1252,17 +1252,17 @@ void Temperature::init() {
if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHO(heater_id); if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHO(heater_id);
SERIAL_ECHOPAIR(" ; State:", *state); SERIAL_ECHOPAIR(" ; State:", *state);
SERIAL_ECHOPAIR(" ; Timer:", *timer); SERIAL_ECHOPAIR(" ; Timer:", *timer);
SERIAL_ECHOPAIR(" ; Temperature:", temperature); SERIAL_ECHOPAIR(" ; Temperature:", current);
SERIAL_ECHOPAIR(" ; Target Temp:", target_temperature); SERIAL_ECHOPAIR(" ; Target Temp:", target);
SERIAL_EOL; SERIAL_EOL;
*/ */
int heater_index = heater_id >= 0 ? heater_id : HOTENDS; int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
// If the target temperature changes, restart // If the target temperature changes, restart
if (tr_target_temperature[heater_index] != target_temperature) { if (tr_target_temperature[heater_index] != target) {
tr_target_temperature[heater_index] = target_temperature; tr_target_temperature[heater_index] = target;
*state = target_temperature > 0 ? TRFirstHeating : TRInactive; *state = target > 0 ? TRFirstHeating : TRInactive;
} }
switch (*state) { switch (*state) {
@ -1270,11 +1270,11 @@ void Temperature::init() {
case TRInactive: break; case TRInactive: break;
// When first heating, wait for the temperature to be reached then go to Stable state // When first heating, wait for the temperature to be reached then go to Stable state
case TRFirstHeating: case TRFirstHeating:
if (temperature < tr_target_temperature[heater_index]) break; if (current < tr_target_temperature[heater_index]) break;
*state = TRStable; *state = TRStable;
// While the temperature is stable watch for a bad temperature // While the temperature is stable watch for a bad temperature
case TRStable: case TRStable:
if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) { if (current >= tr_target_temperature[heater_index] - hysteresis_degc) {
*timer = millis() + period_seconds * 1000UL; *timer = millis() + period_seconds * 1000UL;
break; break;
} }
@ -1961,9 +1961,9 @@ void Temperature::isr() {
}; };
for (uint8_t e = 0; e < COUNT(temp_dir); e++) { for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
const int tdir = temp_dir[e], rawtemp = current_temperature_raw[e] * tdir; const int16_t tdir = temp_dir[e], rawtemp = current_temperature_raw[e] * tdir;
if (rawtemp > maxttemp_raw[e] * tdir && target_temperature[e] > 0.0f) max_temp_error(e); if (rawtemp > maxttemp_raw[e] * tdir && target_temperature[e] > 0) max_temp_error(e);
if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && target_temperature[e] > 0.0f) { if (rawtemp < minttemp_raw[e] * tdir && !is_preheating(e) && target_temperature[e] > 0) {
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)
#endif #endif
@ -1981,8 +1981,8 @@ void Temperature::isr() {
#else #else
#define GEBED >= #define GEBED >=
#endif #endif
if (current_temperature_bed_raw GEBED bed_maxttemp_raw && target_temperature_bed > 0.0f) max_temp_error(-1); if (current_temperature_bed_raw GEBED bed_maxttemp_raw && target_temperature_bed > 0) max_temp_error(-1);
if (bed_minttemp_raw GEBED current_temperature_bed_raw && target_temperature_bed > 0.0f) min_temp_error(-1); if (bed_minttemp_raw GEBED current_temperature_bed_raw && target_temperature_bed > 0) min_temp_error(-1);
#endif #endif
} // temp_count >= OVERSAMPLENR } // temp_count >= OVERSAMPLENR

60
Marlin/temperature.h

@ -99,10 +99,10 @@ class Temperature {
static float current_temperature[HOTENDS], static float current_temperature[HOTENDS],
current_temperature_bed; current_temperature_bed;
static int current_temperature_raw[HOTENDS], static int16_t current_temperature_raw[HOTENDS],
target_temperature[HOTENDS], target_temperature[HOTENDS],
current_temperature_bed_raw, current_temperature_bed_raw,
target_temperature_bed; target_temperature_bed;
static volatile bool in_temp_isr; static volatile bool in_temp_isr;
@ -217,33 +217,33 @@ class Temperature {
static millis_t next_bed_check_ms; static millis_t next_bed_check_ms;
#endif #endif
static unsigned long raw_temp_value[MAX_EXTRUDERS], static uint16_t raw_temp_value[MAX_EXTRUDERS],
raw_temp_bed_value; raw_temp_bed_value;
// Init min and max temp with extreme values to prevent false errors during startup // Init min and max temp with extreme values to prevent false errors during startup
static int minttemp_raw[HOTENDS], static int16_t minttemp_raw[HOTENDS],
maxttemp_raw[HOTENDS], maxttemp_raw[HOTENDS],
minttemp[HOTENDS], minttemp[HOTENDS],
maxttemp[HOTENDS]; maxttemp[HOTENDS];
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
static int consecutive_low_temperature_error[HOTENDS]; static uint8_t consecutive_low_temperature_error[HOTENDS];
#endif #endif
#ifdef MILLISECONDS_PREHEAT_TIME #ifdef MILLISECONDS_PREHEAT_TIME
static unsigned long preheat_end_time[HOTENDS]; static millis_t preheat_end_time[HOTENDS];
#endif #endif
#ifdef BED_MINTEMP #ifdef BED_MINTEMP
static int bed_minttemp_raw; static int16_t bed_minttemp_raw;
#endif #endif
#ifdef BED_MAXTEMP #ifdef BED_MAXTEMP
static int bed_maxttemp_raw; static int16_t bed_maxttemp_raw;
#endif #endif
#if ENABLED(FILAMENT_WIDTH_SENSOR) #if ENABLED(FILAMENT_WIDTH_SENSOR)
static int meas_shift_index; // Index of a delayed sample in buffer static int16_t meas_shift_index; // Index of a delayed sample in buffer
#endif #endif
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
@ -323,31 +323,31 @@ class Temperature {
//inline so that there is no performance decrease. //inline so that there is no performance decrease.
//deg=degreeCelsius //deg=degreeCelsius
static float degHotend(uint8_t e) { static int16_t degHotend(uint8_t e) {
#if HOTENDS == 1 #if HOTENDS == 1
UNUSED(e); UNUSED(e);
#endif #endif
return current_temperature[HOTEND_INDEX]; return current_temperature[HOTEND_INDEX];
} }
static float degBed() { return current_temperature_bed; } static int16_t degBed() { return current_temperature_bed; }
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
static float rawHotendTemp(uint8_t e) { static int16_t rawHotendTemp(uint8_t e) {
#if HOTENDS == 1 #if HOTENDS == 1
UNUSED(e); UNUSED(e);
#endif #endif
return current_temperature_raw[HOTEND_INDEX]; return current_temperature_raw[HOTEND_INDEX];
} }
static float rawBedTemp() { return current_temperature_bed_raw; } static int16_t rawBedTemp() { return current_temperature_bed_raw; }
#endif #endif
static float degTargetHotend(uint8_t e) { static int16_t degTargetHotend(uint8_t e) {
#if HOTENDS == 1 #if HOTENDS == 1
UNUSED(e); UNUSED(e);
#endif #endif
return target_temperature[HOTEND_INDEX]; return target_temperature[HOTEND_INDEX];
} }
static float degTargetBed() { return target_temperature_bed; } static int16_t degTargetBed() { return target_temperature_bed; }
#if WATCH_HOTENDS #if WATCH_HOTENDS
static void start_watching_heater(uint8_t e = 0); static void start_watching_heater(uint8_t e = 0);
@ -357,14 +357,14 @@ class Temperature {
static void start_watching_bed(); static void start_watching_bed();
#endif #endif
static void setTargetHotend(const float& celsius, uint8_t e) { static void setTargetHotend(const int16_t &celsius, uint8_t e) {
#if HOTENDS == 1 #if HOTENDS == 1
UNUSED(e); UNUSED(e);
#endif #endif
#ifdef MILLISECONDS_PREHEAT_TIME #ifdef MILLISECONDS_PREHEAT_TIME
if (celsius == 0.0f) if (celsius == 0)
reset_preheat_time(HOTEND_INDEX); reset_preheat_time(HOTEND_INDEX);
else if (target_temperature[HOTEND_INDEX] == 0.0f) else if (target_temperature[HOTEND_INDEX] == 0)
start_preheat_time(HOTEND_INDEX); start_preheat_time(HOTEND_INDEX);
#endif #endif
target_temperature[HOTEND_INDEX] = celsius; target_temperature[HOTEND_INDEX] = celsius;
@ -373,7 +373,7 @@ class Temperature {
#endif #endif
} }
static void setTargetBed(const float& celsius) { static void setTargetBed(const int16_t &celsius) {
target_temperature_bed = celsius; target_temperature_bed = celsius;
#if WATCH_THE_BED #if WATCH_THE_BED
start_watching_bed(); start_watching_bed();

37
Marlin/ubl_G29.cpp

@ -1522,10 +1522,8 @@
if (isnan(ubl.z_values[x][y]) && !isnan(ubl.z_values[x1][y1]) && !isnan(ubl.z_values[x2][y2])) { if (isnan(ubl.z_values[x][y]) && !isnan(ubl.z_values[x1][y1]) && !isnan(ubl.z_values[x2][y2])) {
if (ubl.z_values[x1][y1] < ubl.z_values[x2][y2]) // Angled downward? if (ubl.z_values[x1][y1] < ubl.z_values[x2][y2]) // Angled downward?
ubl.z_values[x][y] = ubl.z_values[x1][y1]; // Use nearest (maybe a little too high.) ubl.z_values[x][y] = ubl.z_values[x1][y1]; // Use nearest (maybe a little too high.)
else { else
const float diff = ubl.z_values[x1][y1] - ubl.z_values[x2][y2]; // Angled upward ubl.z_values[x][y] = 2.0 * ubl.z_values[x1][y1] - ubl.z_values[x2][y2]; // Angled upward...
ubl.z_values[x][y] = ubl.z_values[x1][y1] + diff; // Use closest plus difference
}
return true; return true;
} }
return false; return false;
@ -1533,21 +1531,6 @@
typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info; typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info;
void smart_fill_loop(const smart_fill_info &f) {
if (f.yfirst) {
const int8_t dir = f.ex > f.sx ? 1 : -1;
for (uint8_t y = f.sy; y != f.ey; ++y)
for (uint8_t x = f.sx; x != f.ex; x += dir)
if (smart_fill_one(x, y, dir, 0)) break;
}
else {
const int8_t dir = f.ey > f.sy ? 1 : -1;
for (uint8_t x = f.sx; x != f.ex; ++x)
for (uint8_t y = f.sy; y != f.ey; y += dir)
if (smart_fill_one(x, y, 0, dir)) break;
}
}
void smart_fill_mesh() { void smart_fill_mesh() {
const smart_fill_info info[] = { const smart_fill_info info[] = {
{ 0, GRID_MAX_POINTS_X, 0, GRID_MAX_POINTS_Y - 2, false }, // Bottom of the mesh looking up { 0, GRID_MAX_POINTS_X, 0, GRID_MAX_POINTS_Y - 2, false }, // Bottom of the mesh looking up
@ -1555,7 +1538,21 @@
{ 0, GRID_MAX_POINTS_X - 2, 0, GRID_MAX_POINTS_Y, true }, // Left side of the mesh looking right { 0, GRID_MAX_POINTS_X - 2, 0, GRID_MAX_POINTS_Y, true }, // Left side of the mesh looking right
{ GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true } // Right side of the mesh looking left { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true } // Right side of the mesh looking left
}; };
for (uint8_t i = 0; i < COUNT(info); ++i) smart_fill_loop(info[i]); for (uint8_t i = 0; i < COUNT(info); ++i) {
const smart_fill_info &f = info[i];
if (f.yfirst) {
const int8_t dir = f.ex > f.sx ? 1 : -1;
for (uint8_t y = f.sy; y != f.ey; ++y)
for (uint8_t x = f.sx; x != f.ex; x += dir)
if (smart_fill_one(x, y, dir, 0)) break;
}
else {
const int8_t dir = f.ey > f.sy ? 1 : -1;
for (uint8_t x = f.sx; x != f.ex; ++x)
for (uint8_t y = f.sy; y != f.ey; y += dir)
if (smart_fill_one(x, y, 0, dir)) break;
}
}
} }
void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map) { void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map) {

4
Marlin/ultralcd.cpp

@ -1179,14 +1179,14 @@ void kill_screen(const char* lcd_msg) {
} }
#endif #endif
constexpr int heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP); constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP);
/** /**
* *
* "Prepare" submenu items * "Prepare" submenu items
* *
*/ */
void _lcd_preheat(int endnum, const float temph, const float tempb, const int fan) { void _lcd_preheat(const int endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum); if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
if (tempb >= 0) thermalManager.setTargetBed(tempb); if (tempb >= 0) thermalManager.setTargetBed(tempb);

Loading…
Cancel
Save