Reduced string storage using tokens (#15593)

This commit is contained in:
Scott Lahteine
2019-11-14 20:30:30 -06:00
committed by GitHub
parent d1d143781e
commit 27cb4db80e
48 changed files with 1041 additions and 3434 deletions

View File

@@ -107,155 +107,86 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
// Change filament
#if E_STEPPERS == 1
PGM_P const msg0 = GET_TEXT(MSG_FILAMENTCHANGE);
PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE);
if (thermalManager.targetTooColdToExtrude(active_extruder))
SUBMENU_P(msg0, []{ _menu_temp_filament_op(PauseMode(editable.int8), 0); });
SUBMENU_P(msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); });
else
GCODES_ITEM_P(msg0, PSTR("M600 B0"));
GCODES_ITEM_P(msg, PSTR("M600 B0"));
#else
PGM_P const msg0 = GET_TEXT(MSG_FILAMENTCHANGE_E0);
PGM_P const msg1 = GET_TEXT(MSG_FILAMENTCHANGE_E1);
if (thermalManager.targetTooColdToExtrude(0))
SUBMENU_P(msg0, []{ _menu_temp_filament_op(PauseMode(editable.int8), 0); });
else
GCODES_ITEM_P(msg0, PSTR("M600 B0 T0"));
if (thermalManager.targetTooColdToExtrude(1))
SUBMENU_P(msg1, []{ _menu_temp_filament_op(PauseMode(editable.int8), 1); });
else
GCODES_ITEM_P(msg1, PSTR("M600 B0 T1"));
#if E_STEPPERS > 2
PGM_P const msg2 = GET_TEXT(MSG_FILAMENTCHANGE_E2);
if (thermalManager.targetTooColdToExtrude(2))
SUBMENU_P(msg2, []{ _menu_temp_filament_op(PauseMode(editable.int8), 2); });
else
GCODES_ITEM_P(msg2, PSTR("M600 B0 T2"));
#if E_STEPPERS > 3
PGM_P const msg3 = GET_TEXT(MSG_FILAMENTCHANGE_E3);
if (thermalManager.targetTooColdToExtrude(3))
SUBMENU_P(msg3, []{ _menu_temp_filament_op(PauseMode(editable.int8), 3); });
else
GCODES_ITEM_P(msg3, PSTR("M600 B0 T3"));
#if E_STEPPERS > 4
PGM_P const msg4 = GET_TEXT(MSG_FILAMENTCHANGE_E4);
if (thermalManager.targetTooColdToExtrude(4))
SUBMENU_P(msg4, []{ _menu_temp_filament_op(PauseMode(editable.int8), 4); });
else
GCODES_ITEM_P(msg4, PSTR("M600 B0 T4"));
#if E_STEPPERS > 5
PGM_P const msg5 = GET_TEXT(MSG_FILAMENTCHANGE_E5);
if (thermalManager.targetTooColdToExtrude(5))
SUBMENU_P(msg5, []{ _menu_temp_filament_op(PauseMode(editable.int8), 5); });
else
GCODES_ITEM_P(msg5, PSTR("M600 B0 T5"));
#endif // E_STEPPERS > 5
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS == 1
PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE_E);
for (uint8_t s = 0; s < E_STEPPERS; s++) {
if (thermalManager.targetTooColdToExtrude(s))
SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); });
else {
ACTION_ITEM_N_P(s, msg, []{
char cmd[12];
sprintf_P(cmd, PSTR("M600 B0 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
});
}
}
#endif
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
if (!printer_busy()) {
// Load filament
#if E_STEPPERS == 1
PGM_P const msg0 = GET_TEXT(MSG_FILAMENTLOAD);
PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD);
if (thermalManager.targetTooColdToExtrude(active_extruder))
SUBMENU_P(msg0, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 0); });
SUBMENU_P(msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 0); });
else
GCODES_ITEM_P(msg0, PSTR("M701"));
GCODES_ITEM_P(msg_load, PSTR("M701"));
#else
PGM_P const msg0 = GET_TEXT(MSG_FILAMENTLOAD_E0);
PGM_P const msg1 = GET_TEXT(MSG_FILAMENTLOAD_E1);
if (thermalManager.targetTooColdToExtrude(0))
SUBMENU_P(msg0, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 0); });
else
GCODES_ITEM_P(msg0, PSTR("M701 T0"));
if (thermalManager.targetTooColdToExtrude(1))
SUBMENU_P(msg1, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 1); });
else
GCODES_ITEM_P(msg1, PSTR("M701 T1"));
#if E_STEPPERS > 2
PGM_P const msg2 = GET_TEXT(MSG_FILAMENTLOAD_E2);
if (thermalManager.targetTooColdToExtrude(2))
SUBMENU_P(msg2, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 2); });
else
GCODES_ITEM_P(msg2, PSTR("M701 T2"));
#if E_STEPPERS > 3
PGM_P const msg3 = GET_TEXT(MSG_FILAMENTLOAD_E3);
if (thermalManager.targetTooColdToExtrude(3))
SUBMENU_P(msg3, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 3); });
else
GCODES_ITEM_P(msg3, PSTR("M701 T3"));
#if E_STEPPERS > 4
PGM_P const msg4 = GET_TEXT(MSG_FILAMENTLOAD_E4);
if (thermalManager.targetTooColdToExtrude(4))
SUBMENU_P(msg4, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 4); });
else
GCODES_ITEM_P(msg4, PSTR("M701 T4"));
#if E_STEPPERS > 5
PGM_P const msg5 = GET_TEXT(MSG_FILAMENTLOAD_E5);
if (thermalManager.targetTooColdToExtrude(5))
SUBMENU_P(msg5, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 5); });
else
GCODES_ITEM_P(msg5, PSTR("M701 T5"));
#endif // E_STEPPERS > 5
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS == 1
PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD_E);
for (uint8_t s = 0; s < E_STEPPERS; s++) {
if (thermalManager.targetTooColdToExtrude(s))
SUBMENU_N_P(s, msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, MenuItemBase::itemIndex); });
else {
ACTION_ITEM_N_P(s, msg_load, []{
char cmd[12];
sprintf_P(cmd, PSTR("M701 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
});
}
}
#endif
// Unload filament
#if E_STEPPERS == 1
if (thermalManager.targetHotEnoughToExtrude(active_extruder))
GCODES_ITEM(MSG_FILAMENTUNLOAD, PSTR("M702"));
PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD);
if (thermalManager.targetTooColdToExtrude(active_extruder))
SUBMENU_P(msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 0); });
else
SUBMENU(MSG_FILAMENTUNLOAD, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 0); });
GCODES_ITEM_P(msg_unload, PSTR("M702"));
#else
#if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
if (JOIN_N(E_STEPPERS, &&,
thermalManager.targetHotEnoughToExtrude(0),
thermalManager.targetHotEnoughToExtrude(1),
thermalManager.targetHotEnoughToExtrude(2),
thermalManager.targetHotEnoughToExtrude(3),
thermalManager.targetHotEnoughToExtrude(4),
thermalManager.targetHotEnoughToExtrude(5))
) GCODES_ITEM(MSG_FILAMENTUNLOAD_ALL, PSTR("M702"));
else
SUBMENU(MSG_FILAMENTUNLOAD_ALL, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, -1); });
#endif
if (thermalManager.targetHotEnoughToExtrude(0))
GCODES_ITEM(MSG_FILAMENTUNLOAD_E0, PSTR("M702 T0"));
else
SUBMENU(MSG_FILAMENTUNLOAD_E0, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 0); });
if (thermalManager.targetHotEnoughToExtrude(1))
GCODES_ITEM(MSG_FILAMENTUNLOAD_E1, PSTR("M702 T1"));
else
SUBMENU(MSG_FILAMENTUNLOAD_E1, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 1); });
#if E_STEPPERS > 2
if (thermalManager.targetHotEnoughToExtrude(2))
GCODES_ITEM(MSG_FILAMENTUNLOAD_E2, PSTR("M702 T2"));
{
bool too_cold = false;
for (uint8_t s = 0; s < E_STEPPERS; s++) {
if (thermalManager.targetTooColdToExtrude(s)) {
too_cold = true; break;
}
}
if (!too_cold)
GCODES_ITEM(MSG_FILAMENTUNLOAD_ALL, PSTR("M702"));
else
SUBMENU(MSG_FILAMENTUNLOAD_E2, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 2); });
#if E_STEPPERS > 3
if (thermalManager.targetHotEnoughToExtrude(3))
GCODES_ITEM(MSG_FILAMENTUNLOAD_E3, PSTR("M702 T3"));
else
SUBMENU(MSG_FILAMENTUNLOAD_E3, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 3); });
#if E_STEPPERS > 4
if (thermalManager.targetHotEnoughToExtrude(4))
GCODES_ITEM(MSG_FILAMENTUNLOAD_E4, PSTR("M702 T4"));
else
SUBMENU(MSG_FILAMENTUNLOAD_E4, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 4); });
#if E_STEPPERS > 5
if (thermalManager.targetHotEnoughToExtrude(5))
GCODES_ITEM(MSG_FILAMENTUNLOAD_E5, PSTR("M702 T5"));
else
SUBMENU(MSG_FILAMENTUNLOAD_E5, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 5); });
#endif // E_STEPPERS > 5
#endif // E_STEPPERS > 4
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS == 1
}
SUBMENU(MSG_FILAMENTUNLOAD_ALL, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, -1); });
}
#endif
PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD_E);
for (uint8_t s = 0; s < E_STEPPERS; s++) {
if (thermalManager.targetTooColdToExtrude(s))
SUBMENU_N_P(s, msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, MenuItemBase::itemIndex); });
else {
ACTION_ITEM_N_P(s, msg_unload, []{
char cmd[12];
sprintf_P(cmd, PSTR("M702 T%i"), int(MenuItemBase::itemIndex));
lcd_enqueue_one_now(cmd);
});
}
}
#endif
} // !printer_busy
#endif
END_MENU();