Generate menu item texts Load filament <nr.> and Eject filament <nr.> during runtime to conserve flash.

This commit is contained in:
Marek Bel 2019-05-14 15:47:25 +02:00
parent dddc1b84e6
commit 7c4f66181f
13 changed files with 62 additions and 298 deletions

View File

@ -168,11 +168,19 @@ int menu_draw_item_printf_P(char type_char, const char* format, ...)
}
*/
static int menu_draw_item_puts_P(char type_char, const char* str)
static void menu_draw_item_puts_P(char type_char, const char* str)
{
lcd_set_cursor(0, menu_row);
int cnt = lcd_printf_P(PSTR("%c%-18.18S%c"), (lcd_encoder == menu_item)?'>':' ', str, type_char);
return cnt;
lcd_printf_P(PSTR("%c%-18.18S%c"), (lcd_encoder == menu_item)?'>':' ', str, type_char);
}
static int menu_draw_item_puts_P(char type_char, const char* str, char num)
{
lcd_set_cursor(0, menu_row);
lcd_printf_P(PSTR("%c%-.16S "), (lcd_encoder == menu_item)?'>':' ', str);
lcd_putc(num);
lcd_set_cursor(19, menu_row);
lcd_putc(type_char);
}
/*
@ -250,6 +258,34 @@ uint8_t menu_item_function_P(const char* str, menu_func_t func)
return 0;
}
//! @brief Menu item function taking single parameter
//!
//! Ideal for numbered lists calling functions with number parameter.
//! @param str Item caption
//! @param number aditional character to be added after str, e.g. number
//! @param func pointer to function taking uint8_t with no return value
//! @param fn_par value to be passed to function
//! @retval 0
//! @retval 1 Item was clicked
uint8_t menu_item_function_P(const char* str, char number, void (*func)(uint8_t), uint8_t fn_par)
{
if (menu_item == menu_line)
{
if (lcd_draw_update) menu_draw_item_puts_P(' ', str, number);
if (menu_clicked && (lcd_encoder == menu_item))
{
menu_clicked = false;
lcd_consume_click();
lcd_update_enabled = 0;
if (func) func(fn_par);
lcd_update_enabled = 1;
return menu_item_ret();
}
}
menu_item++;
return 0;
}
uint8_t menu_item_gcode_P(const char* str, const char* str_gcode)
{
if (menu_item == menu_line)

View File

@ -87,6 +87,9 @@ extern uint8_t menu_item_back_P(const char* str);
#define MENU_ITEM_FUNCTION_P(str, func) do { if (menu_item_function_P(str, func)) return; } while (0)
extern uint8_t menu_item_function_P(const char* str, menu_func_t func);
#define MENU_ITEM_FUNCTION_NR_P(str, number, func, fn_par) do { if (menu_item_function_P(str, number, func, fn_par)) return; } while (0)
extern uint8_t menu_item_function_P(const char* str, char number, void (*func)(uint8_t), uint8_t fn_par);
#define MENU_ITEM_GCODE_P(str, str_gcode) do { if (menu_item_gcode_P(str, str_gcode)) return; } while (0)
extern uint8_t menu_item_gcode_P(const char* str, const char* str_gcode);

View File

@ -48,8 +48,9 @@ const char MSG_HEATING_COMPLETE[] PROGMEM_I1 = ISTR("Heating done."); ////c=20
const char MSG_HOMEYZ[] PROGMEM_I1 = ISTR("Calibrate Z"); ////
const char MSG_CHOOSE_EXTRUDER[] PROGMEM_I1 = ISTR("Choose extruder:"); ////c=20 r=1
const char MSG_CHOOSE_FILAMENT[] PROGMEM_I1 = ISTR("Choose filament:"); ////c=20 r=1
const char MSG_LOAD_FILAMENT[] PROGMEM_I1 = ISTR("Load filament"); ////c=17
const char MSG_LOAD_FILAMENT[] PROGMEM_I1 = ISTR("Load filament"); //// Number 1 to 5 is added behind text e.g. "Load filament 1" c=16
const char MSG_LOADING_FILAMENT[] PROGMEM_I1 = ISTR("Loading filament"); ////c=20
const char MSG_EJECT_FILAMENT[] PROGMEM_I1 = ISTR("Eject filament"); //// Number 1 to 5 is added behind text e.g. "Eject filament 1" c=16
const char MSG_M117_V2_CALIBRATION[] PROGMEM_I1 = ISTR("M117 First layer cal."); ////c=25 r=1
const char MSG_MAIN[] PROGMEM_I1 = ISTR("Main"); ////
const char MSG_BACK[] PROGMEM_I1 = ISTR("Back"); ////

View File

@ -125,6 +125,7 @@ extern const char MSG_ENDSTOP_OPEN[];
extern const char MSG_POWERUP[];
extern const char MSG_ERR_STOPPED[];
extern const char MSG_ENDSTOP_HIT[];
extern const char MSG_EJECT_FILAMENT[];
#if defined(__cplusplus)
}

View File

@ -1353,7 +1353,7 @@ void mmu_show_warning()
void lcd_mmu_load_to_nozzle(uint8_t filament_nr)
{
//-//
menu_back();
bFilamentAction=false; // NOT in "mmu_load_to_nozzle_menu()"
if (degHotend0() > EXTRUDE_MINTEMP)
{

View File

@ -5923,35 +5923,28 @@ static void fil_load_menu()
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_MAIN));
MENU_ITEM_FUNCTION_P(_i("Load all"), load_all);////MSG_LOAD_ALL c=17
MENU_ITEM_FUNCTION_P(_i("Load filament 1"), extr_adj_0);////MSG_LOAD_FILAMENT_1 c=17
MENU_ITEM_FUNCTION_P(_i("Load filament 2"), extr_adj_1);////MSG_LOAD_FILAMENT_2 c=17
MENU_ITEM_FUNCTION_P(_i("Load filament 3"), extr_adj_2);////MSG_LOAD_FILAMENT_3 c=17
MENU_ITEM_FUNCTION_P(_i("Load filament 4"), extr_adj_3);////MSG_LOAD_FILAMENT_4 c=17
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '1', extr_adj, 0);////MSG_LOAD_FILAMENT_1 c=16
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '2', extr_adj, 1);////MSG_LOAD_FILAMENT_2 c=17
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '3', extr_adj, 2);////MSG_LOAD_FILAMENT_3 c=17
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '4', extr_adj, 3);////MSG_LOAD_FILAMENT_4 c=17
if (mmu_enabled)
MENU_ITEM_FUNCTION_P(_i("Load filament 5"), extr_adj_4);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '5', extr_adj, 3);
MENU_END();
}
template <uint8_t filament>
static void mmu_load_to_nozzle()
{
menu_back();
lcd_mmu_load_to_nozzle(filament);
}
static void mmu_load_to_nozzle_menu()
{
if(bFilamentAction)
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_MAIN));
MENU_ITEM_FUNCTION_P(_i("Load filament 1"), mmu_load_to_nozzle<0>);
MENU_ITEM_FUNCTION_P(_i("Load filament 2"), mmu_load_to_nozzle<1>);
MENU_ITEM_FUNCTION_P(_i("Load filament 3"), mmu_load_to_nozzle<2>);
MENU_ITEM_FUNCTION_P(_i("Load filament 4"), mmu_load_to_nozzle<3>);
MENU_ITEM_FUNCTION_P(_i("Load filament 5"), mmu_load_to_nozzle<4>);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '1', lcd_mmu_load_to_nozzle, 0);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '2', lcd_mmu_load_to_nozzle, 1);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '3', lcd_mmu_load_to_nozzle, 2);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '4', lcd_mmu_load_to_nozzle, 3);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), '5', lcd_mmu_load_to_nozzle, 4);
MENU_END();
}
else {
@ -5966,8 +5959,7 @@ else {
}
}
template <uint8_t filament>
static void mmu_eject_filament()
static void mmu_eject_filament(uint8_t filament)
{
menu_back();
mmu_eject_filament(filament, true);
@ -5979,11 +5971,11 @@ static void mmu_fil_eject_menu()
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_MAIN));
MENU_ITEM_FUNCTION_P(_i("Eject filament 1"), mmu_eject_filament<0>);
MENU_ITEM_FUNCTION_P(_i("Eject filament 2"), mmu_eject_filament<1>);
MENU_ITEM_FUNCTION_P(_i("Eject filament 3"), mmu_eject_filament<2>);
MENU_ITEM_FUNCTION_P(_i("Eject filament 4"), mmu_eject_filament<3>);
MENU_ITEM_FUNCTION_P(_i("Eject filament 5"), mmu_eject_filament<4>);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_EJECT_FILAMENT), '1', mmu_eject_filament, 0);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_EJECT_FILAMENT), '2', mmu_eject_filament, 1);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_EJECT_FILAMENT), '3', mmu_eject_filament, 2);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_EJECT_FILAMENT), '4', mmu_eject_filament, 3);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_EJECT_FILAMENT), '5', mmu_eject_filament, 4);
MENU_END();
}
else

View File

@ -166,21 +166,6 @@
#MSG_EJECT_FILAMENT c=17 r=1
"Eject filament"
#MSG_EJECT_FILAMENT1 c=17 r=1
"Eject filament 1"
#MSG_EJECT_FILAMENT2 c=17 r=1
"Eject filament 2"
#MSG_EJECT_FILAMENT3 c=17 r=1
"Eject filament 3"
#MSG_EJECT_FILAMENT4 c=17 r=1
"Eject filament 4"
#MSG_EJECT_FILAMENT5 c=17 r=1
"Eject filament 5"
#
"Eject"
@ -928,35 +913,20 @@
#MSG_LOAD_ALL c=17
"Load all"
#MSG_LOAD_FILAMENT_1 c=17
"Load filament 1"
#
"XYZ calibration failed. Bed calibration point was not found."
#
"XYZ calibration failed. Front calibration points not reachable."
#MSG_LOAD_FILAMENT_2 c=17
"Load filament 2"
#
"XYZ calibration failed. Right front calibration point not reachable."
#MSG_LOAD_FILAMENT_3 c=17
"Load filament 3"
#
"Y distance from min"
#
"Y-correct"
#MSG_LOAD_FILAMENT_4 c=17
"Load filament 4"
#MSG_LOAD_FILAMENT_5 c=17
"Load filament 5"
#MSG_OFF
" [off]"

View File

@ -222,26 +222,6 @@
"Eject filament"
"Vysunout filament"
#MSG_EJECT_FILAMENT1 c=17 r=1
"Eject filament 1"
"Vysunout filament 1"
#MSG_EJECT_FILAMENT2 c=17 r=1
"Eject filament 2"
"Vysunout filament 2"
#MSG_EJECT_FILAMENT3 c=17 r=1
"Eject filament 3"
"Vysunout filament 3"
#MSG_EJECT_FILAMENT4 c=17 r=1
"Eject filament 4"
"Vysunout filament 4"
#MSG_EJECT_FILAMENT5 c=17 r=1
"Eject filament 5"
"Vysunout filament 5"
#
"Eject"
"Vysunout"
@ -1238,10 +1218,6 @@
"Load all"
"Zavest vse"
#MSG_LOAD_FILAMENT_1 c=17
"Load filament 1"
"Zavest filament 1"
#
"XYZ calibration failed. Bed calibration point was not found."
"Kalibrace XYZ selhala. Kalibracni bod podlozky nenalezen."
@ -1250,18 +1226,10 @@
"XYZ calibration failed. Front calibration points not reachable."
"Kalibrace XYZ selhala. Predni kalibracni body moc vpredu. Srovnejte tiskarnu."
#MSG_LOAD_FILAMENT_2 c=17
"Load filament 2"
"Zavest filament 2"
#
"XYZ calibration failed. Right front calibration point not reachable."
"Kalibrace XYZ selhala. Pravy predni bod moc vpredu. Srovnejte tiskarnu."
#MSG_LOAD_FILAMENT_3 c=17
"Load filament 3"
"Zavest filament 3"
#
"Y distance from min"
"Y vzdalenost od min"
@ -1270,14 +1238,6 @@
"Y-correct"
"Korekce Y"
#MSG_LOAD_FILAMENT_4 c=17
"Load filament 4"
"Zavest filament 4"
#MSG_LOAD_FILAMENT_5 c=17
"Load filament 5"
"Zavest filament 5"
#MSG_OFF
" [off]"
"\x00"

View File

@ -222,26 +222,6 @@
"Eject filament"
"Filamentauswurf"
#MSG_EJECT_FILAMENT1 c=17 r=1
"Eject filament 1"
"Filamentauswurf 1"
#MSG_EJECT_FILAMENT2 c=17 r=1
"Eject filament 2"
"Fil.2 auswerfen"
#MSG_EJECT_FILAMENT3 c=17 r=1
"Eject filament 3"
"Fil.3 auswerfen"
#MSG_EJECT_FILAMENT4 c=17 r=1
"Eject filament 4"
"Fil.4 auswerfen"
#MSG_EJECT_FILAMENT5 c=17 r=1
"Eject filament 5"
"Fil.5 auswerfen"
#
"Eject"
"Auswurf"
@ -1238,10 +1218,6 @@
"Load all"
"Alle laden"
#MSG_LOAD_FILAMENT_1 c=17
"Load filament 1"
"Filament 1 laden"
#
"XYZ calibration failed. Bed calibration point was not found."
"XYZ-Kalibrierung fehlgeschlagen. Bett-Kalibrierpunkt nicht gefunden."
@ -1250,17 +1226,10 @@
"XYZ calibration failed. Front calibration points not reachable."
"XYZ-Kalibrierung fehlgeschlagen. Vordere Kalibrierpunkte nicht erreichbar."
#MSG_LOAD_FILAMENT_2 c=17
"Load filament 2"
"Filament 2 laden"
#
"XYZ calibration failed. Right front calibration point not reachable."
"XYZ-Kalibrierung fehlgeschlagen. Rechter vorderer Kalibrierpunkt ist nicht erreichbar."
#MSG_LOAD_FILAMENT_3 c=17
"Load filament 3"
"Filament 3 laden"
#
"Y distance from min"
@ -1270,14 +1239,6 @@
"Y-correct"
"Y-Korrektur"
#MSG_LOAD_FILAMENT_4 c=17
"Load filament 4"
"Filament 4 laden"
#MSG_LOAD_FILAMENT_5 c=17
"Load filament 5"
"Filament 5 laden"
#MSG_OFF
" [off]"
"\x00"

View File

@ -222,26 +222,6 @@
"Eject filament"
"Expulsar filamento"
#MSG_EJECT_FILAMENT1 c=17 r=1
"Eject filament 1"
"Expulsar filamento 1"
#MSG_EJECT_FILAMENT2 c=17 r=1
"Eject filament 2"
"Expulsar filamento 2"
#MSG_EJECT_FILAMENT3 c=17 r=1
"Eject filament 3"
"Expulsar filamento 3"
#MSG_EJECT_FILAMENT4 c=17 r=1
"Eject filament 4"
"Expulsar filamento 4"
#MSG_EJECT_FILAMENT5 c=17 r=1
"Eject filament 5"
"Expulsar filamento 5"
#
"Eject"
"Expulsar"
@ -1238,10 +1218,6 @@
"Load all"
"Intr. todos fil."
#MSG_LOAD_FILAMENT_1 c=17
"Load filament 1"
"Introducir fil. 1"
#
"XYZ calibration failed. Bed calibration point was not found."
"Calibracion XYZ fallada. Puntos de calibracion en la base no encontrados."
@ -1250,18 +1226,10 @@
"XYZ calibration failed. Front calibration points not reachable."
"Calibracion XYZ fallada. Puntos frontales no alcanzables."
#MSG_LOAD_FILAMENT_2 c=17
"Load filament 2"
"Introducir fil. 2"
#
"XYZ calibration failed. Right front calibration point not reachable."
"Calibracion XYZ fallad. Punto frontal derecho no alcanzable."
#MSG_LOAD_FILAMENT_3 c=17
"Load filament 3"
"Introducir fil. 3"
#
"Y distance from min"
"Distancia en Y desde el min"
@ -1270,14 +1238,6 @@
"Y-correct"
"Y-correcion"
#MSG_LOAD_FILAMENT_4 c=17
"Load filament 4"
"Introducir fil. 4"
#MSG_LOAD_FILAMENT_5 c=17
"Load filament 5"
"Cargar filamento 5"
#MSG_OFF
" [off]"
"\x00"

View File

@ -222,26 +222,6 @@
"Eject filament"
"Ejecter le fil."
#MSG_EJECT_FILAMENT1 c=17 r=1
"Eject filament 1"
"Ejecter fil. 1"
#MSG_EJECT_FILAMENT2 c=17 r=1
"Eject filament 2"
"Ejecter fil. 2"
#MSG_EJECT_FILAMENT3 c=17 r=1
"Eject filament 3"
"Ejecter fil. 3"
#MSG_EJECT_FILAMENT4 c=17 r=1
"Eject filament 4"
"Ejecter fil. 4"
#MSG_EJECT_FILAMENT5 c=17 r=1
"Eject filament 5"
"Ejecter fil. 5"
#
"Eject"
"Ejecter"
@ -1238,10 +1218,6 @@
"Load all"
"Tout charger"
#MSG_LOAD_FILAMENT_1 c=17
"Load filament 1"
"Charger fil. 1"
#
"XYZ calibration failed. Bed calibration point was not found."
"Echec calibration XYZ. Le point de calibration du plateau n'a pas ete trouve."
@ -1250,18 +1226,10 @@
"XYZ calibration failed. Front calibration points not reachable."
"Echec calibration XYZ. Les points de calibration avant ne sont pas atteignables."
#MSG_LOAD_FILAMENT_2 c=17
"Load filament 2"
"Charger fil. 2"
#
"XYZ calibration failed. Right front calibration point not reachable."
"Echec calibration XYZ. Le point de calibration avant droit n'est pas atteignable."
#MSG_LOAD_FILAMENT_3 c=17
"Load filament 3"
"Charger fil. 3"
#
"Y distance from min"
"Distance Y du min"
@ -1270,14 +1238,6 @@
"Y-correct"
"Correction-Y"
#MSG_LOAD_FILAMENT_4 c=17
"Load filament 4"
"Charger fil. 4"
#MSG_LOAD_FILAMENT_5 c=17
"Load filament 5"
"Charger fil. 5"
#MSG_OFF
" [off]"
"\x00"

View File

@ -222,26 +222,6 @@
"Eject filament"
"Espelli filamento "
#MSG_EJECT_FILAMENT1 c=17 r=1
"Eject filament 1"
"Espelli filamento 1"
#MSG_EJECT_FILAMENT2 c=17 r=1
"Eject filament 2"
"Espellere filamento 2"
#MSG_EJECT_FILAMENT3 c=17 r=1
"Eject filament 3"
"Espelli filamento 3"
#MSG_EJECT_FILAMENT4 c=17 r=1
"Eject filament 4"
"Espellere filamento 4"
#MSG_EJECT_FILAMENT5 c=17 r=1
"Eject filament 5"
"Espelli filamento 5"
#
"Eject"
"Espellere"
@ -1238,10 +1218,6 @@
"Load all"
"Caricare tutti"
#MSG_LOAD_FILAMENT_1 c=17
"Load filament 1"
"Caricare fil. 1"
#
"XYZ calibration failed. Bed calibration point was not found."
"Calibrazione XYZ fallita. Il punto di calibrazione sul letto non e' stato trovato."
@ -1250,18 +1226,10 @@
"XYZ calibration failed. Front calibration points not reachable."
"Calibrazione XYZ fallita. Punti anteriori non raggiungibili."
#MSG_LOAD_FILAMENT_2 c=17
"Load filament 2"
"Caricare fil. 2"
#
"XYZ calibration failed. Right front calibration point not reachable."
"Calibrazione XYZ fallita. Punto anteriore destro non raggiungibile."
#MSG_LOAD_FILAMENT_3 c=17
"Load filament 3"
"Carica fil. 3"
#
"Y distance from min"
"Distanza Y dal min"
@ -1270,14 +1238,6 @@
"Y-correct"
"Correzione-Y"
#MSG_LOAD_FILAMENT_4 c=17
"Load filament 4"
"Caricare fil. 4"
#MSG_LOAD_FILAMENT_5 c=17
"Load filament 5"
"Caricare fil. 5"
#MSG_OFF
" [off]"
"\x00"

View File

@ -222,26 +222,6 @@
"Eject filament"
"Wysun filament"
#MSG_EJECT_FILAMENT1 c=17 r=1
"Eject filament 1"
"Wysun filament 1"
#MSG_EJECT_FILAMENT2 c=17 r=1
"Eject filament 2"
"Wysun filament 2"
#MSG_EJECT_FILAMENT3 c=17 r=1
"Eject filament 3"
"Wysun filament 3"
#MSG_EJECT_FILAMENT4 c=17 r=1
"Eject filament 4"
"Wysun filament 4"
#MSG_EJECT_FILAMENT5 c=17 r=1
"Eject filament 5"
"Wysun filament 5"
#
"Eject"
"Wysun"
@ -1238,10 +1218,6 @@
"Load all"
"Zalad. wszystkie"
#MSG_LOAD_FILAMENT_1 c=17
"Load filament 1"
"Zaladuj fil. 1"
#
"XYZ calibration failed. Bed calibration point was not found."
"Kalibracja XYZ nieudana. Nie znaleziono punktow kalibracyjnych."
@ -1250,18 +1226,10 @@
"XYZ calibration failed. Front calibration points not reachable."
"Kalibr. XYZ nieudana. Przednie punkty kalibr. nieosiagalne. Nalezy poprawic montaz drukarki."
#MSG_LOAD_FILAMENT_2 c=17
"Load filament 2"
"Zaladuj fil. 2"
#
"XYZ calibration failed. Right front calibration point not reachable."
"Kalibr. XYZ nieudana. Prawy przedni punkt nieosiagalny. Nalezy poprawic montaz drukarki."
#MSG_LOAD_FILAMENT_3 c=17
"Load filament 3"
"Zaladuj fil. 3"
#
"Y distance from min"
"Dystans od 0 w osi Y"
@ -1270,14 +1238,6 @@
"Y-correct"
"Korekcja Y"
#MSG_LOAD_FILAMENT_4 c=17
"Load filament 4"
"Zaladuj fil. 4"
#MSG_LOAD_FILAMENT_5 c=17
"Load filament 5"
"Laduj filament 5"
#MSG_OFF
" [off]"
"\x00"