Skip to content

Commit

Permalink
🐛 Avoid lambda for menu items (MarlinFirmware#25169)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-the-compiler authored and Andy-Big committed Jul 2, 2023
1 parent 8437d7a commit bff8d6a
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions Marlin/src/lcd/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,8 @@ void menu_main() {
START_MENU();
// BACK_ITEM(MSG_INFO_SCREEN);

#if ENABLED(SDSUPPORT)

#if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
#define MEDIA_MENU_AT_TOP
#endif

#if ENABLED(SDSUPPORT) && !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
#define MEDIA_MENU_AT_TOP
#endif

if (busy) {
Expand Down Expand Up @@ -278,9 +274,37 @@ void menu_main() {
#endif
}
else {

#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

// if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused()))
Expand Down

0 comments on commit bff8d6a

Please sign in to comment.