1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

🐛 Avoid lambda for menu items (#25169)

This commit is contained in:
Vlad Popescu 2022-12-31 04:53:45 +02:00 committed by Scott Lahteine
parent d71a60a14b
commit da43218d76

View File

@ -243,45 +243,10 @@ void menu_main() {
START_MENU(); START_MENU();
BACK_ITEM(MSG_INFO_SCREEN); BACK_ITEM(MSG_INFO_SCREEN);
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT) && !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
#if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
#define MEDIA_MENU_AT_TOP #define MEDIA_MENU_AT_TOP
#endif #endif
auto sdcard_menu_items = [&]{
#if ENABLED(MENU_ADDAUTOSTART)
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
#endif
if (card_detected) {
if (!card_open) {
#if HAS_SD_DETECT
GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media
#else // - or -
ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media
queue.inject(F("M22"));
#if ENABLED(TFT_COLOR_UI)
// Menu display issue on item removal with multi language selection menu
if (encoderTopLine > 0) encoderTopLine--;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
#endif
});
#endif
SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First)
}
}
else {
#if HAS_SD_DETECT
ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
#else
GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media
#endif
}
};
#endif
if (busy) { if (busy) {
#if MACHINE_CAN_PAUSE #if MACHINE_CAN_PAUSE
ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print); ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
@ -308,9 +273,37 @@ void menu_main() {
#endif #endif
} }
else { else {
#if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP) #if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP)
sdcard_menu_items(); // BEGIN MEDIA MENU
#if ENABLED(MENU_ADDAUTOSTART)
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
#endif
if (card_detected) {
if (!card_open) {
#if HAS_SD_DETECT
GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media
#else // - or -
ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media
queue.inject(F("M22"));
#if ENABLED(TFT_COLOR_UI)
// Menu display issue on item removal with multi language selection menu
if (encoderTopLine > 0) encoderTopLine--;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
#endif
});
#endif
SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First)
}
}
else {
#if HAS_SD_DETECT
ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
#else
GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media
#endif
}
// END MEDIA MENU
#endif #endif
if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused()))
@ -390,7 +383,36 @@ void menu_main() {
#endif #endif
#if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP) #if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP)
sdcard_menu_items(); // BEGIN MEDIA MENU
#if ENABLED(MENU_ADDAUTOSTART)
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
#endif
if (card_detected) {
if (!card_open) {
#if HAS_SD_DETECT
GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media
#else // - or -
ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media
queue.inject(F("M22"));
#if ENABLED(TFT_COLOR_UI)
// Menu display issue on item removal with multi language selection menu
if (encoderTopLine > 0) encoderTopLine--;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
#endif
});
#endif
SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First)
}
}
else {
#if HAS_SD_DETECT
ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
#else
GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media
#endif
}
// END MEDIA MENU
#endif #endif
#if HAS_SERVICE_INTERVALS #if HAS_SERVICE_INTERVALS