mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-01-19 08:08:25 +00:00
⚡️ Misc. optimizations
This commit is contained in:
parent
283d093a4c
commit
e6ac9ff204
6 changed files with 30 additions and 25 deletions
|
@ -520,8 +520,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
|||
if (ELAPSED(ms, next_cub_ms_##N)) { \
|
||||
next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \
|
||||
CODE; \
|
||||
queue.inject(F(BUTTON##N##_GCODE)); \
|
||||
TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \
|
||||
queue.inject(F(BUTTON##N##_GCODE)); \
|
||||
TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \
|
||||
} \
|
||||
} \
|
||||
}while(0)
|
||||
|
|
|
@ -85,11 +85,6 @@ void serial_offset(const_float_t v, const uint8_t sp/*=0*/) {
|
|||
SERIAL_DECIMAL(v);
|
||||
}
|
||||
|
||||
void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) {
|
||||
if (pre) serial_print(pre);
|
||||
serial_print(onoff ? on : off);
|
||||
if (post) serial_print(post);
|
||||
}
|
||||
void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); }
|
||||
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
|
||||
void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); }
|
||||
|
|
|
@ -327,7 +327,12 @@ inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP
|
|||
|
||||
void serial_echo_start();
|
||||
void serial_error_start();
|
||||
void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr);
|
||||
inline void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr) {
|
||||
if (pre) serial_print(pre);
|
||||
if (onoff && on) serial_print(on);
|
||||
if (!onoff && off) serial_print(off);
|
||||
if (post) serial_print(post);
|
||||
}
|
||||
void serialprint_onoff(const bool onoff);
|
||||
void serialprintln_onoff(const bool onoff);
|
||||
void serialprint_truefalse(const bool tf);
|
||||
|
|
|
@ -59,7 +59,7 @@ void unified_bed_leveling::report_current_mesh() {
|
|||
|
||||
void unified_bed_leveling::report_state() {
|
||||
echo_name();
|
||||
SERIAL_ECHO_TERNARY(planner.leveling_active, " System v" UBL_VERSION " ", "", "in", "active\n");
|
||||
serial_ternary(planner.leveling_active, " System v" UBL_VERSION " ", nullptr, "in", "active\n");
|
||||
serial_delay(50);
|
||||
}
|
||||
|
||||
|
|
|
@ -2890,7 +2890,7 @@ void Temperature::init() {
|
|||
*
|
||||
* TODO: Embed the last 3 parameters during init, if not less optimal
|
||||
*/
|
||||
void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) {
|
||||
void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_float_t hysteresis_degc) {
|
||||
|
||||
#if HEATER_IDLE_HANDLER
|
||||
// Convert the given heater_id_t to an idle array index
|
||||
|
@ -2959,21 +2959,26 @@ void Temperature::init() {
|
|||
// While the temperature is stable watch for a bad temperature
|
||||
case TRStable: {
|
||||
|
||||
const celsius_float_t rdiff = running_temp - current;
|
||||
|
||||
#if ENABLED(ADAPTIVE_FAN_SLOWING)
|
||||
if (adaptive_fan_slowing && heater_id >= 0) {
|
||||
const int fan_index = _MIN(heater_id, FAN_COUNT - 1);
|
||||
if (fan_speed[fan_index] == 0 || current >= running_temp - (hysteresis_degc * 0.25f))
|
||||
fan_speed_scaler[fan_index] = 128;
|
||||
else if (current >= running_temp - (hysteresis_degc * 0.3335f))
|
||||
fan_speed_scaler[fan_index] = 96;
|
||||
else if (current >= running_temp - (hysteresis_degc * 0.5f))
|
||||
fan_speed_scaler[fan_index] = 64;
|
||||
else if (current >= running_temp - (hysteresis_degc * 0.8f))
|
||||
fan_speed_scaler[fan_index] = 32;
|
||||
const int_fast8_t fan_index = _MIN(heater_id, FAN_COUNT - 1);
|
||||
uint8_t scale;
|
||||
if (fan_speed[fan_index] == 0 || rdiff <= hysteresis_degc * 0.25f)
|
||||
scale = 128;
|
||||
else if (rdiff <= hysteresis_degc * 0.3335f)
|
||||
scale = 96;
|
||||
else if (rdiff <= hysteresis_degc * 0.5f)
|
||||
scale = 64;
|
||||
else if (rdiff <= hysteresis_degc * 0.8f)
|
||||
scale = 32;
|
||||
else
|
||||
fan_speed_scaler[fan_index] = 0;
|
||||
scale = 0;
|
||||
|
||||
fan_speed_scaler[fan_index] = scale;
|
||||
}
|
||||
#endif
|
||||
#endif // ADAPTIVE_FAN_SLOWING
|
||||
|
||||
const millis_t now = millis();
|
||||
|
||||
|
@ -2993,7 +2998,7 @@ void Temperature::init() {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (current >= running_temp - hysteresis_degc) {
|
||||
if (rdiff <= hysteresis_degc) {
|
||||
timer = now + SEC_TO_MS(period_seconds);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#define E_NAME TERN_(HAS_MULTI_HOTEND, e)
|
||||
|
||||
// Element identifiers. Positive values are hotends. Negative values are other heaters or coolers.
|
||||
typedef enum : int8_t {
|
||||
typedef enum : int_fast8_t {
|
||||
H_REDUNDANT = HID_REDUNDANT,
|
||||
H_COOLER = HID_COOLER,
|
||||
H_PROBE = HID_PROBE,
|
||||
|
@ -1319,12 +1319,12 @@ class Temperature {
|
|||
typedef struct {
|
||||
millis_t timer = 0;
|
||||
TRState state = TRInactive;
|
||||
float running_temp;
|
||||
celsius_float_t running_temp;
|
||||
#if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR)
|
||||
millis_t variance_timer = 0;
|
||||
celsius_float_t last_temp = 0.0, variance = 0.0;
|
||||
#endif
|
||||
void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc);
|
||||
void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_float_t hysteresis_degc);
|
||||
} tr_state_machine_t;
|
||||
|
||||
static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY];
|
||||
|
|
Loading…
Reference in a new issue