Skip to content

Commit da43218

Browse files
vlad-the-compilerthinkyhead
authored andcommitted
🐛 Avoid lambda for menu items (#25169)
1 parent d71a60a commit da43218

File tree

1 file changed

+60
-38
lines changed

1 file changed

+60
-38
lines changed

Marlin/src/lcd/menu/menu_main.cpp

+60-38
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,38 @@ void menu_main() {
243243
START_MENU();
244244
BACK_ITEM(MSG_INFO_SCREEN);
245245

246-
#if ENABLED(SDSUPPORT)
246+
#if ENABLED(SDSUPPORT) && !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
247+
#define MEDIA_MENU_AT_TOP
248+
#endif
247249

248-
#if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
249-
#define MEDIA_MENU_AT_TOP
250+
if (busy) {
251+
#if MACHINE_CAN_PAUSE
252+
ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
253+
#endif
254+
#if MACHINE_CAN_STOP
255+
SUBMENU(MSG_STOP_PRINT, []{
256+
MenuItem_confirm::select_screen(
257+
GET_TEXT_F(MSG_BUTTON_STOP), GET_TEXT_F(MSG_BACK),
258+
ui.abort_print, nullptr,
259+
GET_TEXT_F(MSG_STOP_PRINT), (const char *)nullptr, F("?")
260+
);
261+
});
262+
#endif
263+
264+
#if ENABLED(GCODE_REPEAT_MARKERS)
265+
if (repeat.is_active())
266+
ACTION_ITEM(MSG_END_LOOPS, repeat.cancel);
250267
#endif
251268

252-
auto sdcard_menu_items = [&]{
269+
SUBMENU(MSG_TUNE, menu_tune);
270+
271+
#if ENABLED(CANCEL_OBJECTS) && DISABLED(SLIM_LCD_MENUS)
272+
SUBMENU(MSG_CANCEL_OBJECT, []{ editable.int8 = -1; ui.goto_screen(menu_cancelobject); });
273+
#endif
274+
}
275+
else {
276+
#if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP)
277+
// BEGIN MEDIA MENU
253278
#if ENABLED(MENU_ADDAUTOSTART)
254279
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
255280
#endif
@@ -278,39 +303,7 @@ void menu_main() {
278303
GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media
279304
#endif
280305
}
281-
};
282-
283-
#endif
284-
285-
if (busy) {
286-
#if MACHINE_CAN_PAUSE
287-
ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
288-
#endif
289-
#if MACHINE_CAN_STOP
290-
SUBMENU(MSG_STOP_PRINT, []{
291-
MenuItem_confirm::select_screen(
292-
GET_TEXT_F(MSG_BUTTON_STOP), GET_TEXT_F(MSG_BACK),
293-
ui.abort_print, nullptr,
294-
GET_TEXT_F(MSG_STOP_PRINT), (const char *)nullptr, F("?")
295-
);
296-
});
297-
#endif
298-
299-
#if ENABLED(GCODE_REPEAT_MARKERS)
300-
if (repeat.is_active())
301-
ACTION_ITEM(MSG_END_LOOPS, repeat.cancel);
302-
#endif
303-
304-
SUBMENU(MSG_TUNE, menu_tune);
305-
306-
#if ENABLED(CANCEL_OBJECTS) && DISABLED(SLIM_LCD_MENUS)
307-
SUBMENU(MSG_CANCEL_OBJECT, []{ editable.int8 = -1; ui.goto_screen(menu_cancelobject); });
308-
#endif
309-
}
310-
else {
311-
312-
#if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP)
313-
sdcard_menu_items();
306+
// END MEDIA MENU
314307
#endif
315308

316309
if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused()))
@@ -390,7 +383,36 @@ void menu_main() {
390383
#endif
391384

392385
#if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP)
393-
sdcard_menu_items();
386+
// BEGIN MEDIA MENU
387+
#if ENABLED(MENU_ADDAUTOSTART)
388+
ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
389+
#endif
390+
391+
if (card_detected) {
392+
if (!card_open) {
393+
#if HAS_SD_DETECT
394+
GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media
395+
#else // - or -
396+
ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media
397+
queue.inject(F("M22"));
398+
#if ENABLED(TFT_COLOR_UI)
399+
// Menu display issue on item removal with multi language selection menu
400+
if (encoderTopLine > 0) encoderTopLine--;
401+
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
402+
#endif
403+
});
404+
#endif
405+
SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First)
406+
}
407+
}
408+
else {
409+
#if HAS_SD_DETECT
410+
ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
411+
#else
412+
GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media
413+
#endif
414+
}
415+
// END MEDIA MENU
394416
#endif
395417

396418
#if HAS_SERVICE_INTERVALS

0 commit comments

Comments
 (0)