Add typedef celsius_t (#21374)

This commit is contained in:
Scott Lahteine 2021-03-24 04:11:43 -05:00
parent 2a011779e9
commit 3226e12037
35 changed files with 252 additions and 298 deletions

View File

@ -72,6 +72,12 @@ struct IF<true, L, R> { typedef L type; };
// //
typedef float feedRate_t; typedef float feedRate_t;
//
// celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14).
// For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100
//
typedef int16_t celsius_t;
// Conversion macros // Conversion macros
#define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f) #define MMM_TO_MMS(MM_M) feedRate_t(float(MM_M) / 60.0f)
#define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f) #define MMS_TO_MMM(MM_S) (float(MM_S) * 60.0f)

View File

@ -775,7 +775,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
bool response = false; bool response = false;
mmu_print_saved = false; mmu_print_saved = false;
xyz_pos_t resume_position; xyz_pos_t resume_position;
int16_t resume_hotend_temp = thermalManager.degTargetHotend(active_extruder); celsius_t resume_hotend_temp = thermalManager.degTargetHotend(active_extruder);
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);

View File

@ -555,7 +555,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
* - Send host action for resume, if configured * - Send host action for resume, if configured
* - Resume the current SD print job, if any * - Resume the current SD print job, if any
*/ */
void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, int16_t targetTemp/*=0*/ DXC_ARGS) { void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, const celsius_t targetTemp/*=0*/ DXC_ARGS) {
DEBUG_SECTION(rp, "resume_print", true); DEBUG_SECTION(rp, "resume_print", true);
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", max_beep_count, " targetTemp:", targetTemp DXC_SAY); DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", max_beep_count, " targetTemp:", targetTemp DXC_SAY);
@ -577,9 +577,8 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
thermalManager.reset_hotend_idle_timer(e); thermalManager.reset_hotend_idle_timer(e);
} }
if (targetTemp > thermalManager.degTargetHotend(active_extruder)) { if (targetTemp > thermalManager.degTargetHotend(active_extruder))
thermalManager.setTargetHotend(targetTemp, active_extruder); thermalManager.setTargetHotend(targetTemp, active_extruder);
}
// Load the new filament // Load the new filament
load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS); load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS);

View File

@ -90,7 +90,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS); void wait_for_confirmation(const bool is_reload=false, const int8_t max_beep_count=0 DXC_PARAMS);
void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, void resume_print(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=ADVANCED_PAUSE_PURGE_LENGTH,
const int8_t max_beep_count=0, int16_t targetTemp=0 DXC_PARAMS); const int8_t max_beep_count=0, const celsius_t targetTemp=0 DXC_PARAMS);
bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0, bool load_filament(const float &slow_load_length=0, const float &fast_load_length=0, const float &extrude_length=0, const int8_t max_beep_count=0,
const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS); const bool show_lcd=false, const bool pause_for_user=false, const PauseMode mode=PAUSE_MODE_PAUSE_PRINT DXC_PARAMS);

View File

@ -201,10 +201,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=0*/
#endif #endif
#if EXTRUDERS #if EXTRUDERS
HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target; HOTEND_LOOP() info.target_temperature[e] = thermalManager.degTargetHotend(e);
#endif #endif
TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.temp_bed.target); TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.degTargetBed());
#if HAS_FAN #if HAS_FAN
COPY(info.fan_speed, thermalManager.fan_speed); COPY(info.fan_speed, thermalManager.fan_speed);
@ -343,7 +343,7 @@ void PrintJobRecovery::resume() {
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
const int16_t bt = info.target_temperature_bed; const celsius_t bt = info.target_temperature_bed;
if (bt) { if (bt) {
// Restore the bed temperature // Restore the bed temperature
sprintf_P(cmd, PSTR("M190 S%i"), bt); sprintf_P(cmd, PSTR("M190 S%i"), bt);
@ -354,7 +354,7 @@ void PrintJobRecovery::resume() {
// Restore all hotend temperatures // Restore all hotend temperatures
#if HAS_HOTEND #if HAS_HOTEND
HOTEND_LOOP() { HOTEND_LOOP() {
const int16_t et = info.target_temperature[e]; const celsius_t et = info.target_temperature[e];
if (et) { if (et) {
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
sprintf_P(cmd, PSTR("T%i S"), e); sprintf_P(cmd, PSTR("T%i S"), e);

View File

@ -66,8 +66,8 @@ typedef struct {
float filament_size[EXTRUDERS]; float filament_size[EXTRUDERS];
#endif #endif
TERN_(HAS_HOTEND, int16_t target_temperature[HOTENDS]); TERN_(HAS_HOTEND, celsius_t target_temperature[HOTENDS]);
TERN_(HAS_HEATED_BED, int16_t target_temperature_bed); TERN_(HAS_HEATED_BED, celsius_t target_temperature_bed);
TERN_(HAS_FAN, uint8_t fan_speed[FAN_COUNT]); TERN_(HAS_FAN, uint8_t fan_speed[FAN_COUNT]);
TERN_(HAS_LEVELING, float fade); TERN_(HAS_LEVELING, float fade);

View File

@ -533,7 +533,7 @@ void GcodeSuite::G26() {
#if HAS_HEATED_BED #if HAS_HEATED_BED
// Get a temperature from 'I' or 'B' // Get a temperature from 'I' or 'B'
int16_t bedtemp = 0; celsius_t bedtemp = 0;
// Use the 'I' index if temperature presets are defined // Use the 'I' index if temperature presets are defined
#if PREHEAT_COUNT #if PREHEAT_COUNT
@ -616,7 +616,7 @@ void GcodeSuite::G26() {
g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size g26_extrusion_multiplier *= g26_filament_diameter * sq(g26_nozzle) / sq(0.3); // Scale up by nozzle size
// Get a temperature from 'I' or 'H' // Get a temperature from 'I' or 'H'
int16_t noztemp = 0; celsius_t noztemp = 0;
// Accept 'I' if temperature presets are defined // Accept 'I' if temperature presets are defined
#if PREHEAT_COUNT #if PREHEAT_COUNT

View File

@ -27,6 +27,10 @@
#include "../gcode.h" #include "../gcode.h"
#include "../../lcd/marlinui.h" #include "../../lcd/marlinui.h"
#if HAS_HOTEND
#include "../../module/temperature.h"
#endif
/** /**
* M145: Set the heatup state for a material in the LCD menu * M145: Set the heatup state for a material in the LCD menu
* *
@ -43,7 +47,7 @@ void GcodeSuite::M145() {
preheat_t &mat = ui.material_preset[material]; preheat_t &mat = ui.material_preset[material];
#if HAS_HOTEND #if HAS_HOTEND
if (parser.seenval('H')) if (parser.seenval('H'))
mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP) - (HOTEND_OVERSHOOT)); mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0));
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
if (parser.seenval('B')) if (parser.seenval('B'))

View File

@ -352,50 +352,45 @@ public:
static inline PGM_P temp_units_name() { static inline PGM_P temp_units_name() {
return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius"); return input_temp_units == TEMPUNIT_K ? PSTR("Kelvin") : input_temp_units == TEMPUNIT_F ? PSTR("Fahrenheit") : PSTR("Celsius");
} }
static inline float to_temp_units(const float &f) { static inline float to_temp_units(celsius_t c) {
switch (input_temp_units) { switch (input_temp_units) {
case TEMPUNIT_F:
return f * 0.5555555556f + 32;
case TEMPUNIT_K:
return f + 273.15f;
case TEMPUNIT_C:
default: default:
return f; case TEMPUNIT_C: return c;
case TEMPUNIT_K: return c + 273.15f;
case TEMPUNIT_F: return c * 0.5555555556f + 32;
} }
} }
#endif // HAS_LCD_MENU && !DISABLE_M503 #endif // HAS_LCD_MENU && !DISABLE_M503
static inline float value_celsius() { static inline celsius_t value_celsius() {
const float f = value_float(); float f = value_float();
switch (input_temp_units) { switch (input_temp_units) {
case TEMPUNIT_F:
return (f - 32) * 0.5555555556f;
case TEMPUNIT_K:
return f - 273.15f;
case TEMPUNIT_C:
default: default:
return f; case TEMPUNIT_C: break;
case TEMPUNIT_K: f -= 273.15f;
case TEMPUNIT_F: f = (f - 32) * 0.5555555556f;
} }
return LROUND(f + 0.5f);
} }
static inline float value_celsius_diff() { static inline celsius_t value_celsius_diff() {
float f = value_float();
switch (input_temp_units) { switch (input_temp_units) {
case TEMPUNIT_F:
return value_float() * 0.5555555556f;
case TEMPUNIT_C:
case TEMPUNIT_K:
default: default:
return value_float(); case TEMPUNIT_C:
case TEMPUNIT_K: break;
case TEMPUNIT_F: f *= 0.5555555556f;
} }
return LROUND(f + 0.5f);
} }
#else // !TEMPERATURE_UNITS_SUPPORT #else // !TEMPERATURE_UNITS_SUPPORT
static inline float to_temp_units(int16_t c) { return (float)c; } static inline float to_temp_units(int16_t c) { return (float)c; }
static inline float value_celsius() { return value_float(); } static inline celsius_t value_celsius() { return value_int(); }
static inline float value_celsius_diff() { return value_float(); } static inline celsius_t value_celsius_diff() { return value_int(); }
#endif // !TEMPERATURE_UNITS_SUPPORT #endif // !TEMPERATURE_UNITS_SUPPORT
@ -404,16 +399,16 @@ public:
void unknown_command_warning(); void unknown_command_warning();
// Provide simple value accessors with default option // Provide simple value accessors with default option
static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; }
static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; }
static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); }
static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; }
static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; }
static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; }
static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; }
static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; }
static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
static inline float celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; } static inline celsius_t celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; }
#if ENABLED(MARLIN_DEV_MODE) #if ENABLED(MARLIN_DEV_MODE)

View File

@ -69,7 +69,7 @@ void GcodeSuite::M104() {
#endif #endif
bool got_temp = false; bool got_temp = false;
int16_t temp = 0; celsius_t temp = 0;
// Accept 'I' if temperature presets are defined // Accept 'I' if temperature presets are defined
#if PREHEAT_COUNT #if PREHEAT_COUNT
@ -145,7 +145,7 @@ void GcodeSuite::M109() {
#endif #endif
bool got_temp = false; bool got_temp = false;
int16_t temp = 0; celsius_t temp = 0;
// Accept 'I' if temperature presets are defined // Accept 'I' if temperature presets are defined
#if PREHEAT_COUNT #if PREHEAT_COUNT
@ -161,7 +161,7 @@ void GcodeSuite::M109() {
if (!got_temp) { if (!got_temp) {
no_wait_for_cooling = parser.seenval('S'); no_wait_for_cooling = parser.seenval('S');
got_temp = no_wait_for_cooling || parser.seenval('R'); got_temp = no_wait_for_cooling || parser.seenval('R');
if (got_temp) temp = int16_t(parser.value_celsius()); if (got_temp) temp = parser.value_celsius();
} }
if (got_temp) { if (got_temp) {

View File

@ -44,7 +44,7 @@ void GcodeSuite::M140() {
if (DEBUGGING(DRYRUN)) return; if (DEBUGGING(DRYRUN)) return;
bool got_temp = false; bool got_temp = false;
int16_t temp = 0; celsius_t temp = 0;
// Accept 'I' if temperature presets are defined // Accept 'I' if temperature presets are defined
#if PREHEAT_COUNT #if PREHEAT_COUNT
@ -94,7 +94,7 @@ void GcodeSuite::M190() {
if (DEBUGGING(DRYRUN)) return; if (DEBUGGING(DRYRUN)) return;
bool got_temp = false; bool got_temp = false;
int16_t temp = 0; celsius_t temp = 0;
// Accept 'I' if temperature presets are defined // Accept 'I' if temperature presets are defined
#if PREHEAT_COUNT #if PREHEAT_COUNT
@ -110,7 +110,7 @@ void GcodeSuite::M190() {
if (!got_temp) { if (!got_temp) {
no_wait_for_cooling = parser.seenval('S'); no_wait_for_cooling = parser.seenval('S');
got_temp = no_wait_for_cooling || parser.seenval('R'); got_temp = no_wait_for_cooling || parser.seenval('R');
if (got_temp) temp = int16_t(parser.value_celsius()); if (got_temp) temp = parser.value_celsius();
} }
if (!got_temp) return; if (!got_temp) return;

View File

@ -520,15 +520,15 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) { FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
#if HAS_HEATED_BED #if HAS_HEATED_BED
const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0); const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0);
const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)), const celsius_t t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)),
t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
#else #else
const float t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id);
#endif #endif
if (prefix >= 0) lcd_put_wchar(prefix); if (prefix >= 0) lcd_put_wchar(prefix);
lcd_put_u8str(i16tostr3rj(t1 + 0.5)); lcd_put_u8str(i16tostr3rj(t1));
lcd_put_wchar('/'); lcd_put_wchar('/');
#if !HEATER_IDLE_HANDLER #if !HEATER_IDLE_HANDLER
@ -541,7 +541,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr
} }
else else
#endif #endif
lcd_put_u8str(i16tostr3left(t2 + 0.5)); lcd_put_u8str(i16tostr3left(t2));
if (prefix >= 0) { if (prefix >= 0) {
lcd_put_wchar(LCD_STR_DEGREE[0]); lcd_put_wchar(LCD_STR_DEGREE[0]);

View File

@ -434,33 +434,32 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p
uint8_t pic_hot_bits; uint8_t pic_hot_bits;
#if HAS_HEATED_BED #if HAS_HEATED_BED
const bool isBed = heater_id < 0; const bool isBed = heater_id < 0;
const float t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)); const celsius_t t1 = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater_id)),
const float t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
#else #else
const float t1 = thermalManager.degHotend(heater_id); const celsius_t t1 = thermalManager.degHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id);
const float t2 = thermalManager.degTargetHotend(heater_id);
#endif #endif
#if HOTENDS < 2 #if HOTENDS < 2
if (heater_id == H_E0) { if (heater_id == H_E0) {
lcd.setCursor(2, 5); lcd.print(prefix); //HE lcd.setCursor(2, 5); lcd.print(prefix); //HE
lcd.setCursor(1, 6); lcd.print(i16tostr3rj(t1 + 0.5)); lcd.setCursor(1, 6); lcd.print(i16tostr3rj(t1));
lcd.setCursor(1, 7); lcd.setCursor(1, 7);
} }
else { else {
lcd.setCursor(6, 5); lcd.print(prefix); //BED lcd.setCursor(6, 5); lcd.print(prefix); //BED
lcd.setCursor(6, 6); lcd.print(i16tostr3rj(t1 + 0.5)); lcd.setCursor(6, 6); lcd.print(i16tostr3rj(t1));
lcd.setCursor(6, 7); lcd.setCursor(6, 7);
} }
#else #else
if (heater_id > H_BED) { if (heater_id > H_BED) {
lcd.setCursor(heater_id * 4, 5); lcd.print(prefix); //HE1 or HE2 or HE3 lcd.setCursor(heater_id * 4, 5); lcd.print(prefix); // HE1 or HE2 or HE3
lcd.setCursor(heater_id * 4, 6); lcd.print(i16tostr3rj(t1 + 0.5)); lcd.setCursor(heater_id * 4, 6); lcd.print(i16tostr3rj(t1));
lcd.setCursor(heater_id * 4, 7); lcd.setCursor(heater_id * 4, 7);
} }
else { else {
lcd.setCursor(13, 5); lcd.print(prefix); //BED lcd.setCursor(13, 5); lcd.print(prefix); //BED
lcd.setCursor(13, 6); lcd.print(i16tostr3rj(t1 + 0.5)); lcd.setCursor(13, 6); lcd.print(i16tostr3rj(t1));
lcd.setCursor(13, 7); lcd.setCursor(13, 7);
} }
#endif // HOTENDS <= 1 #endif // HOTENDS <= 1
@ -475,7 +474,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p
} }
else else
#endif // !HEATER_IDLE_HANDLER #endif // !HEATER_IDLE_HANDLER
lcd.print(i16tostr3rj(t2 + 0.5)); lcd.print(i16tostr3rj(t2));
switch (heater_id) { switch (heater_id) {
case H_BED: pic_hot_bits = ICON_BED; break; case H_BED: pic_hot_bits = ICON_BED; break;

View File

@ -187,7 +187,7 @@
#define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1) #define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1)
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) { FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
const char *str = i16tostr3rj(temp); const char *str = i16tostr3rj(temp);
const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]); lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
@ -206,8 +206,8 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id); const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id);
const float temp = thermalManager.degHotend(heater_id), const celsius_t temp = thermalManager.degHotend(heater_id),
target = thermalManager.degTargetHotend(heater_id); target = thermalManager.degTargetHotend(heater_id);
#if DISABLED(STATUS_HOTEND_ANIM) #if DISABLED(STATUS_HOTEND_ANIM)
#define STATIC_HOTEND true #define STATIC_HOTEND true
@ -277,11 +277,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
#else #else
constexpr bool dodraw = true; constexpr bool dodraw = true;
#endif #endif
if (dodraw) _draw_centered_temp(target + 0.5, tx, 7); if (dodraw) _draw_centered_temp(target, tx, 7);
} }
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(temp + 0.5f, tx, 28); _draw_centered_temp(temp, tx, 28);
if (STATIC_HOTEND && HOTEND_DOT && PAGE_CONTAINS(17, 19)) { if (STATIC_HOTEND && HOTEND_DOT && PAGE_CONTAINS(17, 19)) {
u8g.setColorIndex(0); // set to white on black u8g.setColorIndex(0); // set to white on black
@ -303,8 +303,8 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
const uint8_t tx = STATUS_BED_TEXT_X; const uint8_t tx = STATUS_BED_TEXT_X;
const float temp = thermalManager.degBed(), const celsius_t temp = thermalManager.degBed(),
target = thermalManager.degTargetBed(); target = thermalManager.degTargetBed();
#if ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM) #if ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM)
const bool isHeat = BED_ALT(); const bool isHeat = BED_ALT();
@ -350,11 +350,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
#else #else
constexpr bool dodraw = true; constexpr bool dodraw = true;
#endif #endif
if (dodraw) _draw_centered_temp(target + 0.5, tx, 7); if (dodraw) _draw_centered_temp(target, tx, 7);
} }
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(temp + 0.5f, tx, 28); _draw_centered_temp(temp, tx, 28);
if (STATIC_BED && BED_DOT && PAGE_CONTAINS(17, 19)) { if (STATIC_BED && BED_DOT && PAGE_CONTAINS(17, 19)) {
u8g.setColorIndex(0); // set to white on black u8g.setColorIndex(0); // set to white on black
@ -370,10 +370,10 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
FORCE_INLINE void _draw_chamber_status() { FORCE_INLINE void _draw_chamber_status() {
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
if (PAGE_UNDER(7)) if (PAGE_UNDER(7))
_draw_centered_temp(thermalManager.degTargetChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 7); _draw_centered_temp(thermalManager.degTargetChamber(), STATUS_CHAMBER_TEXT_X, 7);
#endif #endif
if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1)) if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
_draw_centered_temp(thermalManager.degChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 28); _draw_centered_temp(thermalManager.degChamber(), STATUS_CHAMBER_TEXT_X, 28);
} }
#endif #endif

View File

@ -691,15 +691,15 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
// We only add the target temperatures to the checksum // We only add the target temperatures to the checksum
// because the actual temps fluctuate so by updating // because the actual temps fluctuate so by updating
// them only during blinks we gain a bit of stability. // them only during blinks we gain a bit of stability.
const bool blink = ui.get_blink(); const bool blink = ui.get_blink();
const uint16_t feedrate_perc = feedrate_percentage; const uint16_t feedrate_perc = feedrate_percentage;
const uint16_t fs = thermalManager.scaledFanSpeed(0); const uint16_t fs = thermalManager.scaledFanSpeed(0);
const int16_t extruder_1_target = thermalManager.degTargetHotend(0); const celsius_t extruder_1_target = thermalManager.degTargetHotend(0);
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
const int16_t extruder_2_target = thermalManager.degTargetHotend(1); const celsius_t extruder_2_target = thermalManager.degTargetHotend(1);
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
const int16_t bed_target = thermalManager.degTargetBed(); const celsius_t bed_target = thermalManager.degTargetBed();
#endif #endif
static uint16_t last_checksum = 0; static uint16_t last_checksum = 0;
const uint16_t checksum = blink ^ feedrate_perc ^ fs ^ extruder_1_target const uint16_t checksum = blink ^ feedrate_perc ^ fs ^ extruder_1_target
@ -712,19 +712,19 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
if (forceUpdate || indicators_changed()) { if (forceUpdate || indicators_changed()) {
const bool blink = ui.get_blink(); const bool blink = ui.get_blink();
const duration_t elapsed = print_job_timer.duration(); const duration_t elapsed = print_job_timer.duration();
duration_t remaining = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time()); duration_t remaining = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time());
const uint16_t feedrate_perc = feedrate_percentage; const uint16_t feedrate_perc = feedrate_percentage;
const int16_t extruder_1_temp = thermalManager.degHotend(0), const celsius_t extruder_1_temp = thermalManager.degHotend(0),
extruder_1_target = thermalManager.degTargetHotend(0); extruder_1_target = thermalManager.degTargetHotend(0);
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
const int16_t extruder_2_temp = thermalManager.degHotend(1), const celsius_t extruder_2_temp = thermalManager.degHotend(1),
extruder_2_target = thermalManager.degTargetHotend(1); extruder_2_target = thermalManager.degTargetHotend(1);
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
const int16_t bed_temp = thermalManager.degBed(), const celsius_t bed_temp = thermalManager.degBed(),
bed_target = thermalManager.degTargetBed(); bed_target = thermalManager.degTargetBed();
#endif #endif
draw_extruder_1_temp(extruder_1_temp, extruder_1_target, forceUpdate); draw_extruder_1_temp(extruder_1_temp, extruder_1_target, forceUpdate);

View File

@ -1578,20 +1578,22 @@ void _draw_xyz_position(const bool force) {
void update_variable() { void update_variable() {
#if HAS_HOTEND #if HAS_HOTEND
static float _hotendtemp = 0; static celsius_t _hotendtemp = 0, _hotendtarget = 0;
const bool _new_hotend_temp = _hotendtemp != thermalManager.temp_hotend[0].celsius; const celsius_t hc = thermalManager.degHotend(0),
if (_new_hotend_temp) _hotendtemp = thermalManager.temp_hotend[0].celsius; ht = thermalManager.degTargetHotend(0);
static int16_t _hotendtarget = 0; const bool _new_hotend_temp = _hotendtemp != hc,
const bool _new_hotend_target = _hotendtarget != thermalManager.temp_hotend[0].target; _new_hotend_target = _hotendtarget != ht;
if (_new_hotend_target) _hotendtarget = thermalManager.temp_hotend[0].target; if (_new_hotend_temp) _hotendtemp = hc;
if (_new_hotend_target) _hotendtarget = ht;
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
static float _bedtemp = 0; static celsius_t _bedtemp = 0, _bedtarget = 0;
const bool _new_bed_temp = _bedtemp != thermalManager.temp_bed.celsius; const celsius_t bc = thermalManager.degBed(),
if (_new_bed_temp) _bedtemp = thermalManager.temp_bed.celsius; bt = thermalManager.degTargetBed();
static int16_t _bedtarget = 0; const bool _new_bed_temp = _bedtemp != bc,
const bool _new_bed_target = _bedtarget != thermalManager.temp_bed.target; _new_bed_target = _bedtarget != bt;
if (_new_bed_target) _bedtarget = thermalManager.temp_bed.target; if (_new_bed_temp) _bedtemp = bc;
if (_new_bed_target) _bedtarget = bt;
#endif #endif
#if HAS_FAN #if HAS_FAN
static uint8_t _fanspeed = 0; static uint8_t _fanspeed = 0;

View File

@ -234,8 +234,8 @@ extern char print_filename[16];
extern millis_t dwin_heat_time; extern millis_t dwin_heat_time;
typedef struct { typedef struct {
TERN_(HAS_HOTEND, int16_t E_Temp = 0); TERN_(HAS_HOTEND, celsius_t E_Temp = 0);
TERN_(HAS_HEATED_BED, int16_t Bed_Temp = 0); TERN_(HAS_HEATED_BED, celsius_t Bed_Temp = 0);
TERN_(HAS_FAN, int16_t Fan_speed = 0); TERN_(HAS_FAN, int16_t Fan_speed = 0);
int16_t print_speed = 100; int16_t print_speed = 100;
float Max_Feedspeed = 0; float Max_Feedspeed = 0;

View File

@ -388,28 +388,28 @@ void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr
} }
void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t newvalue = swap16(*(uint16_t*)val_ptr); celsius_t newvalue = swap16(*(uint16_t*)val_ptr);
uint16_t acceptedvalue; celsius_t acceptedvalue;
switch (var.VP) { switch (var.VP) {
default: return; default: return;
#if HOTENDS >= 1 #if HOTENDS >= 1
case VP_T_E0_Set: case VP_T_E0_Set:
NOMORE(newvalue, (uint16_t)HEATER_0_MAXTEMP); NOMORE(newvalue, HEATER_0_MAXTEMP);
thermalManager.setTargetHotend(newvalue, 0); thermalManager.setTargetHotend(newvalue, 0);
acceptedvalue = thermalManager.degTargetHotend(0); acceptedvalue = thermalManager.degTargetHotend(0);
break; break;
#endif #endif
#if HOTENDS >= 2 #if HOTENDS >= 2
case VP_T_E1_Set: case VP_T_E1_Set:
NOMORE(newvalue, (uint16_t)HEATER_1_MAXTEMP); NOMORE(newvalue, HEATER_1_MAXTEMP);
thermalManager.setTargetHotend(newvalue, 1); thermalManager.setTargetHotend(newvalue, 1);
acceptedvalue = thermalManager.degTargetHotend(1); acceptedvalue = thermalManager.degTargetHotend(1);
break; break;
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
case VP_T_Bed_Set: case VP_T_Bed_Set:
NOMORE(newvalue, (uint16_t)BED_MAXTEMP); NOMORE(newvalue, BED_MAXTEMP);
thermalManager.setTargetBed(newvalue); thermalManager.setTargetBed(newvalue);
acceptedvalue = thermalManager.degTargetBed(); acceptedvalue = thermalManager.degTargetBed();
break; break;

View File

@ -367,7 +367,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// Temperature Data // Temperature Data
#if HOTENDS >= 1 #if HOTENDS >= 1
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
@ -388,7 +388,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif #endif
#endif #endif
#if HOTENDS >= 2 #if HOTENDS >= 2
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@ -400,7 +400,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload), VPHELPER(VP_E1_FILAMENT_LOAD_UNLOAD, nullptr, &ScreenHandler.HandleFilamentOption, &ScreenHandler.HandleFilamentLoadUnload),
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

View File

@ -364,13 +364,13 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr), VPHELPER(VP_Z_FIRST_LAYER_CAL, nullptr, &ScreenHandler.HandleFirstLayerCal, nullptr),
#endif #endif
{ .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplayPGM }, { .VP = VP_MARLIN_VERSION, .memadr = (void*)MarlinVersion, .size = VP_MARLIN_VERSION_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
// M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr // M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr
{ .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay }, { .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplay },
// Temperature Data // Temperature Data
#if HOTENDS >= 1 #if HOTENDS >= 1
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
@ -391,7 +391,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif #endif
#endif #endif
#if HOTENDS >= 2 #if HOTENDS >= 2
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@ -399,7 +399,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), VPHELPER(VP_E1_STATUS, &thermalManager.temp_hotend[1].target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

View File

@ -548,7 +548,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// Temperature Data // Temperature Data
#if HOTENDS >= 1 #if HOTENDS >= 1
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), VPHELPER(VP_EPos, &destination.e, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
@ -573,7 +573,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif #endif
#if HOTENDS >= 2 #if HOTENDS >= 2
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, &planner.flow_percentage[ExtUI::extruder_t::E1], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@ -593,7 +593,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

View File

@ -216,7 +216,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif #endif
#endif #endif
#if HOTENDS >= 2 #if HOTENDS >= 2
VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_E1_Is, &thermalManager.temp_hotend[1].celsius, nullptr, DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_E1_Set, &thermalManager.temp_hotend[1].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Flowrate_E1, nullptr, ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr), VPHELPER(VP_MOVE_E1, nullptr, &ScreenHandler.HandleManualExtrude, nullptr),
@ -227,7 +227,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
#endif #endif
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<0>), VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr), VPHELPER(VP_BED_CONTROL, &thermalManager.temp_bed.target, &ScreenHandler.HandleHeaterControl, nullptr),
VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay), VPHELPER(VP_BED_STATUS, &thermalManager.temp_bed.target, nullptr, &ScreenHandler.DGUSLCD_SendHeaterStatusToDisplay),

View File

@ -515,7 +515,7 @@ void filament_dialog_handle() {
} }
if (uiCfg.filament_load_heat_flg) { if (uiCfg.filament_load_heat_flg) {
const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
if (abs(diff) < 2 || diff > 0) { if (abs(diff) < 2 || diff > 0) {
uiCfg.filament_load_heat_flg = false; uiCfg.filament_load_heat_flg = false;
lv_clear_dialog(); lv_clear_dialog();
@ -531,7 +531,7 @@ void filament_dialog_handle() {
} }
if (uiCfg.filament_unload_heat_flg) { if (uiCfg.filament_unload_heat_flg) {
const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp; const celsius_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
if (abs(diff) < 2 || diff > 0) { if (abs(diff) < 2 || diff > 0) {
uiCfg.filament_unload_heat_flg = false; uiCfg.filament_unload_heat_flg = false;
lv_clear_dialog(); lv_clear_dialog();

View File

@ -202,7 +202,7 @@ typedef struct {
filamentchange_load_speed, filamentchange_load_speed,
filamentchange_unload_length, filamentchange_unload_length,
filamentchange_unload_speed; filamentchange_unload_speed;
int16_t filament_limit_temp; celsius_t filament_limit_temp;
float pausePosX, pausePosY, pausePosZ; float pausePosX, pausePosY, pausePosZ;
uint32_t curFilesize; uint32_t curFilesize;
} CFG_ITMES; } CFG_ITMES;
@ -244,7 +244,7 @@ typedef struct {
filament_loading_time_cnt, filament_loading_time_cnt,
filament_unloading_time_cnt; filament_unloading_time_cnt;
float move_dist; float move_dist;
float hotendTargetTempBak; celsius_t hotendTargetTempBak;
float current_x_position_bak, float current_x_position_bak,
current_y_position_bak, current_y_position_bak,
current_z_position_bak, current_z_position_bak,

View File

@ -110,9 +110,9 @@
#if PREHEAT_COUNT #if PREHEAT_COUNT
typedef struct { typedef struct {
TERN_(HAS_HOTEND, uint16_t hotend_temp); TERN_(HAS_HOTEND, celsius_t hotend_temp);
TERN_(HAS_HEATED_BED, uint16_t bed_temp ); TERN_(HAS_HEATED_BED, celsius_t bed_temp );
TERN_(HAS_FAN, uint16_t fan_speed ); TERN_(HAS_FAN, uint16_t fan_speed );
} preheat_t; } preheat_t;
#endif #endif

View File

@ -325,10 +325,10 @@ void menu_advanced_settings();
EDIT_ITEM_N(percent, m, MSG_FAN_SPEED, &editable.uint8, 0, 255, []{ ui.material_preset[MenuItemBase::itemIndex].fan_speed = editable.uint8; }); EDIT_ITEM_N(percent, m, MSG_FAN_SPEED, &editable.uint8, 0, 255, []{ ui.material_preset[MenuItemBase::itemIndex].fan_speed = editable.uint8; });
#endif #endif
#if HAS_TEMP_HOTEND #if HAS_TEMP_HOTEND
EDIT_ITEM(uint16_3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - HOTEND_OVERSHOOT); EDIT_ITEM(int3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - (HOTEND_OVERSHOOT));
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
EDIT_ITEM(uint16_3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET); EDIT_ITEM(int3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET);
#endif #endif
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings);

View File

@ -114,7 +114,7 @@ void MarlinUI::draw_kill_screen() {
void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
MarlinImage image = imgHotEnd; MarlinImage image = imgHotEnd;
uint16_t Color; uint16_t Color;
float currentTemperature, targetTemperature; celsius_t currentTemperature, targetTemperature;
if (Heater >= 0) { // HotEnd if (Heater >= 0) { // HotEnd
currentTemperature = thermalManager.degHotend(Heater); currentTemperature = thermalManager.degHotend(Heater);
@ -175,13 +175,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
tft.add_image(0, 18, image, Color); tft.add_image(0, 18, image, Color);
tft_string.set((uint8_t *)i16tostr3rj(currentTemperature + 0.5)); tft_string.set((uint8_t *)i16tostr3rj(currentTemperature));
tft_string.add(LCD_STR_DEGREE); tft_string.add(LCD_STR_DEGREE);
tft_string.trim(); tft_string.trim();
tft.add_text(tft_string.center(64) + 2, 72, Color, tft_string); tft.add_text(tft_string.center(64) + 2, 72, Color, tft_string);
if (targetTemperature >= 0) { if (targetTemperature >= 0) {
tft_string.set((uint8_t *)i16tostr3rj(targetTemperature + 0.5)); tft_string.set((uint8_t *)i16tostr3rj(targetTemperature));
tft_string.add(LCD_STR_DEGREE); tft_string.add(LCD_STR_DEGREE);
tft_string.trim(); tft_string.trim();
tft.add_text(tft_string.center(64) + 2, 8, Color, tft_string); tft.add_text(tft_string.center(64) + 2, 8, Color, tft_string);

View File

@ -114,7 +114,7 @@ void MarlinUI::draw_kill_screen() {
void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
MarlinImage image = imgHotEnd; MarlinImage image = imgHotEnd;
uint16_t Color; uint16_t Color;
float currentTemperature, targetTemperature; celsius_t currentTemperature, targetTemperature;
if (Heater >= 0) { // HotEnd if (Heater >= 0) { // HotEnd
currentTemperature = thermalManager.degHotend(Heater); currentTemperature = thermalManager.degHotend(Heater);
@ -168,13 +168,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) {
tft.add_image(8, 28, image, Color); tft.add_image(8, 28, image, Color);
tft_string.set((uint8_t *)i16tostr3rj(currentTemperature + 0.5)); tft_string.set((uint8_t *)i16tostr3rj(currentTemperature));
tft_string.add(LCD_STR_DEGREE); tft_string.add(LCD_STR_DEGREE);
tft_string.trim(); tft_string.trim();
tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string); tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string);
if (targetTemperature >= 0) { if (targetTemperature >= 0) {
tft_string.set((uint8_t *)i16tostr3rj(targetTemperature + 0.5)); tft_string.set((uint8_t *)i16tostr3rj(targetTemperature));
tft_string.add(LCD_STR_DEGREE); tft_string.add(LCD_STR_DEGREE);
tft_string.trim(); tft_string.trim();
tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string); tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string);

View File

@ -940,11 +940,11 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) {
DualXMode dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; DualXMode dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
float inactive_extruder_x = X2_MAX_POS, // Used in mode 0 & 1 float inactive_extruder_x = X2_MAX_POS, // Used in mode 0 & 1
duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // Used in mode 2 duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // Used in mode 2 & 3
xyz_pos_t raised_parked_position; // Used in mode 1 xyz_pos_t raised_parked_position; // Used in mode 1
bool active_extruder_parked = false; // Used in mode 1 & 2 bool active_extruder_parked = false; // Used in mode 1, 2 & 3
millis_t delayed_move_time = 0; // Used in mode 1 millis_t delayed_move_time = 0; // Used in mode 1
int16_t duplicate_extruder_temp_offset = 0; // Used in mode 2 celsius_t duplicate_extruder_temp_offset = 0; // Used in mode 2 & 3
bool idex_mirrored_mode = false; // Used in mode 3 bool idex_mirrored_mode = false; // Used in mode 3
float x_home_pos(const uint8_t extruder) { float x_home_pos(const uint8_t extruder) {

View File

@ -463,13 +463,13 @@ FORCE_INLINE bool all_axes_trusted() { return xyz_bits ==
}; };
extern DualXMode dual_x_carriage_mode; extern DualXMode dual_x_carriage_mode;
extern float inactive_extruder_x, // Used in mode 0 & 1 extern float inactive_extruder_x, // Used in mode 0 & 1
duplicate_extruder_x_offset; // Used in mode 2 & 3 duplicate_extruder_x_offset; // Used in mode 2 & 3
extern xyz_pos_t raised_parked_position; // Used in mode 1 extern xyz_pos_t raised_parked_position; // Used in mode 1
extern bool active_extruder_parked; // Used in mode 1, 2 & 3 extern bool active_extruder_parked; // Used in mode 1, 2 & 3
extern millis_t delayed_move_time; // Used in mode 1 extern millis_t delayed_move_time; // Used in mode 1
extern int16_t duplicate_extruder_temp_offset; // Used in mode 2 & 3 extern celsius_t duplicate_extruder_temp_offset; // Used in mode 2 & 3
extern bool idex_mirrored_mode; // Used in mode 3 extern bool idex_mirrored_mode; // Used in mode 3
FORCE_INLINE bool idex_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; } FORCE_INLINE bool idex_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; }

View File

@ -197,9 +197,9 @@ float Planner::steps_to_mm[XYZE_N]; // (mm) Millimeters per step
skew_factor_t Planner::skew_factor; // Initialized by settings.load() skew_factor_t Planner::skew_factor; // Initialized by settings.load()
#if ENABLED(AUTOTEMP) #if ENABLED(AUTOTEMP)
float Planner::autotemp_max = 250, celsius_t Planner::autotemp_max = 250,
Planner::autotemp_min = 210, Planner::autotemp_min = 210;
Planner::autotemp_factor = 0.1f; float Planner::autotemp_factor = 0.1f;
bool Planner::autotemp_enabled = false; bool Planner::autotemp_enabled = false;
#endif #endif
@ -1376,7 +1376,7 @@ void Planner::check_axes_activity() {
#if ENABLED(AUTOTEMP_PROPORTIONAL) #if ENABLED(AUTOTEMP_PROPORTIONAL)
void Planner::_autotemp_update_from_hotend() { void Planner::_autotemp_update_from_hotend() {
const int16_t target = thermalManager.degTargetHotend(active_extruder); const celsius_t target = thermalManager.degTargetHotend(active_extruder);
autotemp_min = target + AUTOTEMP_MIN_P; autotemp_min = target + AUTOTEMP_MIN_P;
autotemp_max = target + AUTOTEMP_MAX_P; autotemp_max = target + AUTOTEMP_MAX_P;
} }

View File

@ -896,7 +896,8 @@ class Planner {
#endif #endif
#if ENABLED(AUTOTEMP) #if ENABLED(AUTOTEMP)
static float autotemp_min, autotemp_max, autotemp_factor; static celsius_t autotemp_min, autotemp_max;
static float autotemp_factor;
static bool autotemp_enabled; static bool autotemp_enabled;
static void autotemp_update(); static void autotemp_update();
static void autotemp_M104_M109(); static void autotemp_M104_M109();

View File

@ -253,7 +253,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_HOTEND #if HAS_HOTEND
hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 } hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 }
const uint16_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
#endif #endif
#if ENABLED(AUTO_POWER_E_FANS) #if ENABLED(AUTO_POWER_E_FANS)
@ -368,12 +368,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_HEATED_BED #if HAS_HEATED_BED
bed_info_t Temperature::temp_bed; // = { 0 } bed_info_t Temperature::temp_bed; // = { 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
#ifdef BED_MINTEMP int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP,
int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP; Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
#endif
#ifdef BED_MAXTEMP
int16_t Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP;
#endif
TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 }
IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms);
#endif #endif
@ -383,12 +379,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
millis_t next_cool_check_ms_2 = 0; millis_t next_cool_check_ms_2 = 0;
float old_temp = 9999; float old_temp = 9999;
#ifdef CHAMBER_MINTEMP int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP,
int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP; Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
#endif
#ifdef CHAMBER_MAXTEMP
int16_t Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP;
#endif
TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0});
IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms); IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms);
#endif #endif
@ -400,12 +392,8 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
bool flag_cooler_state; bool flag_cooler_state;
//bool flag_cooler_excess = false; //bool flag_cooler_excess = false;
float previous_temp = 9999; float previous_temp = 9999;
#ifdef COOLER_MINTEMP int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP,
int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP; Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP;
#endif
#ifdef COOLER_MAXTEMP
int16_t Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP;
#endif
#if WATCH_COOLER #if WATCH_COOLER
cooler_watch_t Temperature::watch_cooler{0}; cooler_watch_t Temperature::watch_cooler{0};
#endif #endif
@ -419,7 +407,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if ENABLED(PREVENT_COLD_EXTRUSION) #if ENABLED(PREVENT_COLD_EXTRUSION)
bool Temperature::allow_cold_extrude = false; bool Temperature::allow_cold_extrude = false;
int16_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP; celsius_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
#endif #endif
// private: // private:
@ -429,7 +417,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#endif #endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
uint16_t Temperature::redundant_temperature_raw = 0; celsius_t Temperature::redundant_temperature_raw = 0;
float Temperature::redundant_temperature = 0.0; float Temperature::redundant_temperature = 0.0;
#endif #endif
@ -474,7 +462,7 @@ volatile bool Temperature::raw_temps_ready = false;
#endif #endif
#if ENABLED(SINGLENOZZLE_STANDBY_TEMP) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP)
uint16_t Temperature::singlenozzle_temp[EXTRUDERS]; celsius_t Temperature::singlenozzle_temp[EXTRUDERS];
#if HAS_FAN #if HAS_FAN
uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS]; uint8_t Temperature::singlenozzle_fan_speed[EXTRUDERS];
#endif #endif
@ -1566,22 +1554,22 @@ void Temperature::manage_heater() {
* Bisect search for the range of the 'raw' value, then interpolate * Bisect search for the range of the 'raw' value, then interpolate
* proportionally between the under and over values. * proportionally between the under and over values.
*/ */
#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \ #define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \
uint8_t l = 0, r = LEN, m; \ uint8_t l = 0, r = LEN, m; \
for (;;) { \ for (;;) { \
m = (l + r) >> 1; \ m = (l + r) >> 1; \
if (!m) return int16_t(pgm_read_word(&TBL[0].celsius)); \ if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius)); \
if (m == l || m == r) return int16_t(pgm_read_word(&TBL[LEN-1].celsius)); \ if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \
int16_t v00 = pgm_read_word(&TBL[m-1].value), \ int16_t v00 = pgm_read_word(&TBL[m-1].value), \
v10 = pgm_read_word(&TBL[m-0].value); \ v10 = pgm_read_word(&TBL[m-0].value); \
if (raw < v00) r = m; \ if (raw < v00) r = m; \
else if (raw > v10) l = m; \ else if (raw > v10) l = m; \
else { \ else { \
const int16_t v01 = int16_t(pgm_read_word(&TBL[m-1].celsius)), \ const celsius_t v01 = celsius_t(pgm_read_word(&TBL[m-1].celsius)), \
v11 = int16_t(pgm_read_word(&TBL[m-0].celsius)); \ v11 = celsius_t(pgm_read_word(&TBL[m-0].celsius)); \
return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \ return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \
} \ } \
} \ } \
}while(0) }while(0)
#if HAS_USER_THERMISTORS #if HAS_USER_THERMISTORS
@ -1663,7 +1651,7 @@ void Temperature::manage_heater() {
SERIAL_EOL(); SERIAL_EOL();
} }
float Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) { celsius_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) {
//#if (MOTHERBOARD == BOARD_RAMPS_14_EFB) //#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
// static uint32_t clocks_total = 0; // static uint32_t clocks_total = 0;
// static uint32_t calls = 0; // static uint32_t calls = 0;
@ -1712,7 +1700,7 @@ void Temperature::manage_heater() {
#if HAS_HOTEND #if HAS_HOTEND
// Derived from RepRap FiveD extruder::getTemperature() // Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement. // For hot end temperature measurement.
float Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) { celsius_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) {
if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) { if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
SERIAL_ERROR_START(); SERIAL_ERROR_START();
SERIAL_ECHO(e); SERIAL_ECHO(e);
@ -1821,7 +1809,7 @@ void Temperature::manage_heater() {
#if HAS_HEATED_BED #if HAS_HEATED_BED
// For bed temperature measurement. // For bed temperature measurement.
float Temperature::analog_to_celsius_bed(const int raw) { celsius_t Temperature::analog_to_celsius_bed(const int raw) {
#if TEMP_SENSOR_BED_IS_CUSTOM #if TEMP_SENSOR_BED_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_BED, raw); return user_thermistor_to_deg_c(CTI_BED, raw);
#elif TEMP_SENSOR_BED_IS_THERMISTOR #elif TEMP_SENSOR_BED_IS_THERMISTOR
@ -1839,7 +1827,7 @@ void Temperature::manage_heater() {
#if HAS_TEMP_CHAMBER #if HAS_TEMP_CHAMBER
// For chamber temperature measurement. // For chamber temperature measurement.
float Temperature::analog_to_celsius_chamber(const int raw) { celsius_t Temperature::analog_to_celsius_chamber(const int raw) {
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM #if TEMP_SENSOR_CHAMBER_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_CHAMBER, raw); return user_thermistor_to_deg_c(CTI_CHAMBER, raw);
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
@ -1857,7 +1845,7 @@ void Temperature::manage_heater() {
#if HAS_TEMP_COOLER #if HAS_TEMP_COOLER
// For cooler temperature measurement. // For cooler temperature measurement.
float Temperature::analog_to_celsius_cooler(const int raw) { celsius_t Temperature::analog_to_celsius_cooler(const int raw) {
#if TEMP_SENSOR_COOLER_IS_CUSTOM #if TEMP_SENSOR_COOLER_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_COOLER, raw); return user_thermistor_to_deg_c(CTI_COOLER, raw);
#elif TEMP_SENSOR_COOLER_IS_THERMISTOR #elif TEMP_SENSOR_COOLER_IS_THERMISTOR
@ -1875,7 +1863,7 @@ void Temperature::manage_heater() {
#if HAS_TEMP_PROBE #if HAS_TEMP_PROBE
// For probe temperature measurement. // For probe temperature measurement.
float Temperature::analog_to_celsius_probe(const int raw) { celsius_t Temperature::analog_to_celsius_probe(const int raw) {
#if TEMP_SENSOR_PROBE_IS_CUSTOM #if TEMP_SENSOR_PROBE_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_PROBE, raw); return user_thermistor_to_deg_c(CTI_PROBE, raw);
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR #elif TEMP_SENSOR_PROBE_IS_THERMISTOR
@ -2191,13 +2179,13 @@ void Temperature::init() {
#if HAS_HOTEND #if HAS_HOTEND
#define _TEMP_MIN_E(NR) do{ \ #define _TEMP_MIN_E(NR) do{ \
const int16_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \ const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \
temp_range[NR].mintemp = tmin; \ temp_range[NR].mintemp = tmin; \
while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \ while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \
temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \ temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \
}while(0) }while(0)
#define _TEMP_MAX_E(NR) do{ \ #define _TEMP_MAX_E(NR) do{ \
const int16_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int16_t)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \ const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \
temp_range[NR].maxtemp = tmax; \ temp_range[NR].maxtemp = tmax; \
while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \ while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \
temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
@ -2257,30 +2245,18 @@ void Temperature::init() {
#endif // HAS_HOTEND #endif // HAS_HOTEND
#if HAS_HEATED_BED #if HAS_HEATED_BED
#ifdef BED_MINTEMP while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR);
while (analog_to_celsius_bed(mintemp_raw_BED) < BED_MINTEMP) mintemp_raw_BED += TEMPDIR(BED) * (OVERSAMPLENR); while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR);
#endif #endif
#ifdef BED_MAXTEMP
while (analog_to_celsius_bed(maxtemp_raw_BED) > BED_MAXTEMP) maxtemp_raw_BED -= TEMPDIR(BED) * (OVERSAMPLENR);
#endif
#endif // HAS_HEATED_BED
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
#ifdef CHAMBER_MINTEMP while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR);
while (analog_to_celsius_chamber(mintemp_raw_CHAMBER) < CHAMBER_MINTEMP) mintemp_raw_CHAMBER += TEMPDIR(CHAMBER) * (OVERSAMPLENR); while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR);
#endif
#ifdef CHAMBER_MAXTEMP
while (analog_to_celsius_chamber(maxtemp_raw_CHAMBER) > CHAMBER_MAXTEMP) maxtemp_raw_CHAMBER -= TEMPDIR(CHAMBER) * (OVERSAMPLENR);
#endif
#endif #endif
#if HAS_COOLER #if HAS_COOLER
#ifdef COOLER_MINTEMP while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR); while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
#endif
#ifdef COOLER_MAXTEMP
while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
#endif
#endif #endif
TERN_(PROBING_HEATERS_OFF, paused = false); TERN_(PROBING_HEATERS_OFF, paused = false);
@ -2345,7 +2321,7 @@ void Temperature::init() {
* *
* TODO: Embed the last 3 parameters during init, if not less optimal * TODO: Embed the last 3 parameters during init, if not less optimal
*/ */
void Temperature::tr_state_machine_t::run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) { void Temperature::tr_state_machine_t::run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
#if HEATER_IDLE_HANDLER #if HEATER_IDLE_HANDLER
// Convert the given heater_id_t to an idle array index // Convert the given heater_id_t to an idle array index
@ -2554,7 +2530,7 @@ void Temperature::disable_all_heaters() {
#if HAS_MULTI_MAX_TC #if HAS_MULTI_MAX_TC
// Needed to return the correct temp when this is called between readings // Needed to return the correct temp when this is called between readings
static uint16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; static celsius_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 };
#define THERMO_TEMP(I) max_tc_temp_previous[I] #define THERMO_TEMP(I) max_tc_temp_previous[I]
#define THERMO_SEL(A,B) (hindex ? (B) : (A)) #define THERMO_SEL(A,B) (hindex ? (B) : (A))
#define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0) #define MAX6675_WRITE(V) do{ switch (hindex) { case 1: WRITE(MAX6675_SS2_PIN, V); break; default: WRITE(MAX6675_SS_PIN, V); } }while(0)

View File

@ -179,7 +179,7 @@ enum ADCSensorState : char {
typedef struct TempInfo { typedef struct TempInfo {
uint16_t acc; uint16_t acc;
int16_t raw; int16_t raw;
float celsius; celsius_t celsius;
inline void reset() { acc = 0; } inline void reset() { acc = 0; }
inline void sample(const uint16_t s) { acc += s; } inline void sample(const uint16_t s) { acc += s; }
inline void update() { raw = acc; } inline void update() { raw = acc; }
@ -187,7 +187,7 @@ typedef struct TempInfo {
// A PWM heater with temperature sensor // A PWM heater with temperature sensor
typedef struct HeaterInfo : public TempInfo { typedef struct HeaterInfo : public TempInfo {
int16_t target; celsius_t target;
uint8_t soft_pwm_amount; uint8_t soft_pwm_amount;
} heater_info_t; } heater_info_t;
@ -228,14 +228,14 @@ struct PIDHeaterInfo : public HeaterInfo {
// Heater watch handling // Heater watch handling
template <int INCREASE, int HYSTERESIS, millis_t PERIOD> template <int INCREASE, int HYSTERESIS, millis_t PERIOD>
struct HeaterWatch { struct HeaterWatch {
uint16_t target; celsius_t target;
millis_t next_ms; millis_t next_ms;
inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); } inline bool elapsed(const millis_t &ms) { return next_ms && ELAPSED(ms, next_ms); }
inline bool elapsed() { return elapsed(millis()); } inline bool elapsed() { return elapsed(millis()); }
inline void restart(const int16_t curr, const int16_t tgt) { inline void restart(const celsius_t curr, const celsius_t tgt) {
if (tgt) { if (tgt) {
const int16_t newtarget = curr + INCREASE; const celsius_t newtarget = curr + INCREASE;
if (newtarget < tgt - HYSTERESIS - 1) { if (newtarget < tgt - HYSTERESIS - 1) {
target = newtarget; target = newtarget;
next_ms = millis() + SEC_TO_MS(PERIOD); next_ms = millis() + SEC_TO_MS(PERIOD);
@ -261,8 +261,8 @@ struct HeaterWatch {
// Temperature sensor read value ranges // Temperature sensor read value ranges
typedef struct { int16_t raw_min, raw_max; } raw_range_t; typedef struct { int16_t raw_min, raw_max; } raw_range_t;
typedef struct { int16_t mintemp, maxtemp; } celsius_range_t; typedef struct { celsius_t mintemp, maxtemp; } celsius_range_t;
typedef struct { int16_t raw_min, raw_max, mintemp, maxtemp; } temp_range_t; typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t;
#define THERMISTOR_ABS_ZERO_C -273.15f // bbbbrrrrr cold ! #define THERMISTOR_ABS_ZERO_C -273.15f // bbbbrrrrr cold !
#define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f // mmmmm comfortable #define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f // mmmmm comfortable
@ -323,8 +323,8 @@ class Temperature {
#if HAS_HOTEND #if HAS_HOTEND
#define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT))
static hotend_info_t temp_hotend[HOTEND_TEMPS]; static hotend_info_t temp_hotend[HOTEND_TEMPS];
static const uint16_t hotend_maxtemp[HOTENDS]; static const celsius_t hotend_maxtemp[HOTENDS];
FORCE_INLINE static uint16_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } FORCE_INLINE static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
#endif #endif
TERN_(HAS_HEATED_BED, static bed_info_t temp_bed); TERN_(HAS_HEATED_BED, static bed_info_t temp_bed);
TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe); TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe);
@ -342,8 +342,8 @@ class Temperature {
#if ENABLED(PREVENT_COLD_EXTRUSION) #if ENABLED(PREVENT_COLD_EXTRUSION)
static bool allow_cold_extrude; static bool allow_cold_extrude;
static int16_t extrude_min_temp; static celsius_t extrude_min_temp;
FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } FORCE_INLINE static bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); }
FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) { FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) {
return tooCold(degHotend(HOTEND_INDEX)); return tooCold(degHotend(HOTEND_INDEX));
} }
@ -359,7 +359,7 @@ class Temperature {
FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } FORCE_INLINE static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); }
#if ENABLED(SINGLENOZZLE_STANDBY_FAN) #if ENABLED(SINGLENOZZLE_STANDBY_FAN)
static uint16_t singlenozzle_temp[EXTRUDERS]; static celsius_t singlenozzle_temp[EXTRUDERS];
#if HAS_FAN #if HAS_FAN
static uint8_t singlenozzle_fan_speed[EXTRUDERS]; static uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif #endif
@ -411,7 +411,7 @@ class Temperature {
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static uint16_t redundant_temperature_raw; static uint16_t redundant_temperature_raw;
static float redundant_temperature; static celsius_t redundant_temperature;
#endif #endif
#if ENABLED(PID_EXTRUSION_SCALING) #if ENABLED(PID_EXTRUSION_SCALING)
@ -424,34 +424,19 @@ class Temperature {
#if HAS_HEATED_BED #if HAS_HEATED_BED
TERN_(WATCH_BED, static bed_watch_t watch_bed); TERN_(WATCH_BED, static bed_watch_t watch_bed);
IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms);
#ifdef BED_MINTEMP static int16_t mintemp_raw_BED, maxtemp_raw_BED;
static int16_t mintemp_raw_BED;
#endif
#ifdef BED_MAXTEMP
static int16_t maxtemp_raw_BED;
#endif
#endif #endif
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
TERN_(WATCH_CHAMBER, static chamber_watch_t watch_chamber); TERN_(WATCH_CHAMBER, static chamber_watch_t watch_chamber);
TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms);
#ifdef CHAMBER_MINTEMP static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER;
static int16_t mintemp_raw_CHAMBER;
#endif
#ifdef CHAMBER_MAXTEMP
static int16_t maxtemp_raw_CHAMBER;
#endif
#endif #endif
#if HAS_COOLER #if HAS_COOLER
TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler); TERN_(WATCH_COOLER, static cooler_watch_t watch_cooler);
static millis_t next_cooler_check_ms, cooler_fan_flush_ms; static millis_t next_cooler_check_ms, cooler_fan_flush_ms;
#ifdef COOLER_MINTEMP static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER;
static int16_t mintemp_raw_COOLER;
#endif
#ifdef COOLER_MAXTEMP
static int16_t maxtemp_raw_COOLER;
#endif
#endif #endif
#ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
@ -488,7 +473,7 @@ class Temperature {
static user_thermistor_t user_thermistor[USER_THERMISTORS]; static user_thermistor_t user_thermistor[USER_THERMISTORS];
static void log_user_thermistor(const uint8_t t_index, const bool eprom=false); static void log_user_thermistor(const uint8_t t_index, const bool eprom=false);
static void reset_user_thermistors(); static void reset_user_thermistors();
static float user_thermistor_to_deg_c(const uint8_t t_index, const int raw); static celsius_t user_thermistor_to_deg_c(const uint8_t t_index, const int raw);
static bool set_pull_up_res(int8_t t_index, float value) { static bool set_pull_up_res(int8_t t_index, float value) {
//if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false;
if (!WITHIN(value, 1, 1000000)) return false; if (!WITHIN(value, 1, 1000000)) return false;
@ -516,19 +501,19 @@ class Temperature {
#endif #endif
#if HAS_HOTEND #if HAS_HOTEND
static float analog_to_celsius_hotend(const int raw, const uint8_t e); static celsius_t analog_to_celsius_hotend(const int raw, const uint8_t e);
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
static float analog_to_celsius_bed(const int raw); static celsius_t analog_to_celsius_bed(const int raw);
#endif #endif
#if HAS_TEMP_PROBE #if HAS_TEMP_PROBE
static float analog_to_celsius_probe(const int raw); static celsius_t analog_to_celsius_probe(const int raw);
#endif #endif
#if HAS_TEMP_CHAMBER #if HAS_TEMP_CHAMBER
static float analog_to_celsius_chamber(const int raw); static celsius_t analog_to_celsius_chamber(const int raw);
#endif #endif
#if HAS_TEMP_COOLER #if HAS_TEMP_COOLER
static float analog_to_celsius_cooler(const int raw); static celsius_t analog_to_celsius_cooler(const int raw);
#endif #endif
#if HAS_FAN #if HAS_FAN
@ -620,7 +605,7 @@ class Temperature {
} }
#endif #endif
FORCE_INLINE static int16_t degTargetHotend(const uint8_t E_NAME) { FORCE_INLINE static celsius_t degTargetHotend(const uint8_t E_NAME) {
return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target); return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target);
} }
@ -632,7 +617,7 @@ class Temperature {
#if HAS_HOTEND #if HAS_HOTEND
static void setTargetHotend(const int16_t celsius, const uint8_t E_NAME) { static void setTargetHotend(const celsius_t celsius, const uint8_t E_NAME) {
const uint8_t ee = HOTEND_INDEX; const uint8_t ee = HOTEND_INDEX;
#ifdef MILLISECONDS_PREHEAT_TIME #ifdef MILLISECONDS_PREHEAT_TIME
if (celsius == 0) if (celsius == 0)
@ -678,12 +663,12 @@ class Temperature {
#if HAS_HEATED_BED #if HAS_HEATED_BED
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; } FORCE_INLINE static int16_t rawBedTemp() { return temp_bed.raw; }
#endif #endif
FORCE_INLINE static float degBed() { return temp_bed.celsius; } FORCE_INLINE static celsius_t degBed() { return temp_bed.celsius; }
FORCE_INLINE static int16_t degTargetBed() { return temp_bed.target; } FORCE_INLINE static celsius_t degTargetBed() { return temp_bed.target; }
FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } FORCE_INLINE static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; }
FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } FORCE_INLINE static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; }
#if WATCH_BED #if WATCH_BED
static void start_watching_bed(); static void start_watching_bed();
@ -691,15 +676,9 @@ class Temperature {
static inline void start_watching_bed() {} static inline void start_watching_bed() {}
#endif #endif
static void setTargetBed(const int16_t celsius) { static void setTargetBed(const celsius_t celsius) {
TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on()); TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on());
temp_bed.target = temp_bed.target = _MIN(celsius, BED_MAX_TARGET);
#ifdef BED_MAX_TARGET
_MIN(celsius, BED_MAX_TARGET)
#else
celsius
#endif
;
start_watching_bed(); start_watching_bed();
} }
@ -735,14 +714,13 @@ class Temperature {
#if HAS_TEMP_CHAMBER #if HAS_TEMP_CHAMBER
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; } FORCE_INLINE static int16_t rawChamberTemp() { return temp_chamber.raw; }
#endif #endif
FORCE_INLINE static float degChamber() { return temp_chamber.celsius; } FORCE_INLINE static float degChamber() { return temp_chamber.celsius; }
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
FORCE_INLINE static int16_t degTargetChamber() { return temp_chamber.target; } FORCE_INLINE static celsius_t degTargetChamber() { return temp_chamber.target; }
FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } FORCE_INLINE static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; }
FORCE_INLINE static bool isCoolingChamber() { 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); static bool wait_for_chamber(const bool no_wait_for_cooling=true);
#endif #endif
#endif #endif
@ -754,27 +732,21 @@ class Temperature {
#endif #endif
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
static void setTargetChamber(const int16_t celsius) { static void setTargetChamber(const celsius_t celsius) {
temp_chamber.target = temp_chamber.target = _MIN(celsius, CHAMBER_MAX_TARGET);
#ifdef CHAMBER_MAXTEMP
_MIN(celsius, CHAMBER_MAXTEMP - 10)
#else
celsius
#endif
;
start_watching_chamber(); start_watching_chamber();
} }
#endif #endif
#if HAS_TEMP_COOLER #if HAS_TEMP_COOLER
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; } FORCE_INLINE static int16_t rawCoolerTemp() { return temp_cooler.raw; }
#endif #endif
FORCE_INLINE static float degCooler() { return temp_cooler.celsius; } FORCE_INLINE static float degCooler() { return temp_cooler.celsius; }
#if HAS_COOLER #if HAS_COOLER
FORCE_INLINE static int16_t degTargetCooler() { return temp_cooler.target; } FORCE_INLINE static celsius_t degTargetCooler() { return temp_cooler.target; }
FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } FORCE_INLINE static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; }
FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } FORCE_INLINE static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; }
static bool wait_for_cooler(const bool no_wait_for_cooling=true); static bool wait_for_cooler(const bool no_wait_for_cooling=true);
#endif #endif
#endif #endif
@ -786,7 +758,7 @@ class Temperature {
#endif #endif
#if HAS_COOLER #if HAS_COOLER
static void setTargetCooler(const int16_t celsius) { static void setTargetCooler(const celsius_t celsius) {
temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
start_watching_cooler(); start_watching_cooler();
} }
@ -945,7 +917,7 @@ class Temperature {
millis_t timer = 0; millis_t timer = 0;
TRState state = TRInactive; TRState state = TRInactive;
float running_temp; float running_temp;
void run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc); void run(const float &current, const float &target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc);
} tr_state_machine_t; } tr_state_machine_t;
static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY]; static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY];

View File

@ -44,7 +44,7 @@
#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n) #define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n)
typedef struct { int16_t value, celsius; } temp_entry_t; typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
// Pt1000 and Pt100 handling // Pt1000 and Pt100 handling
// //