Skip to content

Commit f31d477

Browse files
bryan065LCh-77
authored andcommitted
🚸 Custom Menu Items for JyersUI (MarlinFirmware#24270)
1 parent 5214c4c commit f31d477

File tree

2 files changed

+167
-1
lines changed

2 files changed

+167
-1
lines changed

Marlin/src/lcd/e3v2/jyersui/dwin.cpp

+165
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@
144144
#define MIN_BED_TEMP 0
145145
#endif
146146

147+
/**
148+
* Custom menu items with jyersLCD
149+
*/
150+
#if ENABLED(CUSTOM_MENU_CONFIG)
151+
#ifdef CONFIG_MENU_ITEM_5_DESC
152+
#define CUSTOM_MENU_COUNT 5
153+
#elif defined(CONFIG_MENU_ITEM_4_DESC)
154+
#define CUSTOM_MENU_COUNT 4
155+
#elif defined(CONFIG_MENU_ITEM_3_DESC)
156+
#define CUSTOM_MENU_COUNT 3
157+
#elif defined(CONFIG_MENU_ITEM_2_DESC)
158+
#define CUSTOM_MENU_COUNT 2
159+
#elif defined(CONFIG_MENU_ITEM_1_DESC)
160+
#define CUSTOM_MENU_COUNT 1
161+
#endif
162+
#if CUSTOM_MENU_COUNT
163+
#define HAS_CUSTOM_MENU 1
164+
#endif
165+
#endif
166+
147167
constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
148168
constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
149169
constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT;
@@ -1246,6 +1266,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
12461266
#define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED))
12471267
#define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE))
12481268
#define PREPARE_ACTIONCOMMANDS (PREPARE_CHANGEFIL + (ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)))
1269+
#define PREPARE_CUSTOM_MENU (PREPARE_ACTIONCOMMANDS + ENABLED(HAS_CUSTOM_MENU))
12491270
#define PREPARE_TOTAL PREPARE_ACTIONCOMMANDS
12501271

12511272
switch (item) {
@@ -1332,6 +1353,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
13321353
break;
13331354
#endif
13341355

1356+
#if HAS_CUSTOM_MENU
1357+
case PREPARE_CUSTOM_MENU:
1358+
#ifndef CUSTOM_MENU_CONFIG_TITLE
1359+
#define CUSTOM_MENU_CONFIG_TITLE "Custom Commands"
1360+
#endif
1361+
if (draw)
1362+
Draw_Menu_Item(row, ICON_Version, F(CUSTOM_MENU_CONFIG_TITLE));
1363+
else
1364+
Draw_Menu(MenuCustom);
1365+
break;
1366+
#endif
1367+
13351368
#if ENABLED(ADVANCED_PAUSE_FEATURE)
13361369
case PREPARE_CHANGEFIL:
13371370
if (draw) {
@@ -1974,6 +2007,126 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
19742007
break;
19752008
#endif
19762009

2010+
#if HAS_CUSTOM_MENU
2011+
2012+
case MenuCustom:
2013+
2014+
#define CUSTOM_MENU_BACK 0
2015+
#define CUSTOM_MENU_1 1
2016+
#define CUSTOM_MENU_2 2
2017+
#define CUSTOM_MENU_3 3
2018+
#define CUSTOM_MENU_4 4
2019+
#define CUSTOM_MENU_5 5
2020+
#define CUSTOM_MENU_TOTAL CUSTOM_MENU_COUNT
2021+
2022+
switch (item) {
2023+
case CUSTOM_MENU_BACK:
2024+
if (draw)
2025+
Draw_Menu_Item(row, ICON_Back, F("Back"));
2026+
else
2027+
Draw_Menu(Prepare, PREPARE_CUSTOM_MENU);
2028+
break;
2029+
2030+
#if CUSTOM_MENU_COUNT >= 1
2031+
case CUSTOM_MENU_1:
2032+
if (draw)
2033+
Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_1_DESC));
2034+
else {
2035+
Popup_Handler(Custom);
2036+
//queue.inject(F(CONFIG_MENU_ITEM_1_GCODE)); // Old code
2037+
gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_1_GCODE));
2038+
planner.synchronize();
2039+
Redraw_Menu();
2040+
#if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK)
2041+
AudioFeedback();
2042+
#endif
2043+
#ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN
2044+
queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE));
2045+
#endif
2046+
}
2047+
break;
2048+
#endif
2049+
2050+
#if CUSTOM_MENU_COUNT >= 2
2051+
case CUSTOM_MENU_2:
2052+
if (draw)
2053+
Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_2_DESC));
2054+
else {
2055+
Popup_Handler(Custom);
2056+
gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_2_GCODE));
2057+
planner.synchronize();
2058+
Redraw_Menu();
2059+
#if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK)
2060+
AudioFeedback();
2061+
#endif
2062+
#ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN
2063+
queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE));
2064+
#endif
2065+
}
2066+
break;
2067+
#endif
2068+
2069+
#if CUSTOM_MENU_COUNT >= 3
2070+
case CUSTOM_MENU_3:
2071+
if (draw)
2072+
Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_3_DESC));
2073+
else {
2074+
Popup_Handler(Custom);
2075+
gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_3_GCODE));
2076+
planner.synchronize();
2077+
Redraw_Menu();
2078+
#if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK)
2079+
AudioFeedback();
2080+
#endif
2081+
#ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN
2082+
queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE));
2083+
#endif
2084+
}
2085+
break;
2086+
#endif
2087+
2088+
#if CUSTOM_MENU_COUNT >= 4
2089+
case CUSTOM_MENU_4:
2090+
if (draw)
2091+
Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_4_DESC));
2092+
else {
2093+
Popup_Handler(Custom);
2094+
gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_4_GCODE));
2095+
planner.synchronize();
2096+
Redraw_Menu();
2097+
#if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK)
2098+
AudioFeedback();
2099+
#endif
2100+
#ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN
2101+
queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE));
2102+
#endif
2103+
}
2104+
break;
2105+
#endif
2106+
2107+
#if CUSTOM_MENU_COUNT >= 5
2108+
case CUSTOM_MENU_5:
2109+
if (draw)
2110+
Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_5_DESC));
2111+
else {
2112+
Popup_Handler(Custom);
2113+
gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_5_GCODE));
2114+
planner.synchronize();
2115+
Redraw_Menu();
2116+
#if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK)
2117+
AudioFeedback();
2118+
#endif
2119+
#ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN
2120+
queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE));
2121+
#endif
2122+
}
2123+
break;
2124+
#endif // Custom Menu
2125+
}
2126+
break;
2127+
2128+
#endif // HAS_CUSTOM_MENU
2129+
19772130
case Control:
19782131

19792132
#define CONTROL_BACK 0
@@ -4547,6 +4700,14 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
45474700
#if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
45484701
case HostActions: return F("Host Actions");
45494702
#endif
4703+
#if HAS_CUSTOM_MENU
4704+
case MenuCustom:
4705+
#ifdef CUSTOM_MENU_CONFIG_TITLE
4706+
return F(CUSTOM_MENU_CONFIG_TITLE);
4707+
#else
4708+
return F("Custom Commands");
4709+
#endif
4710+
#endif
45504711
case Control: return GET_TEXT_F(MSG_CONTROL);
45514712
case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE);
45524713
#if HAS_HOTEND || HAS_HEATED_BED
@@ -4641,6 +4802,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
46414802
#if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
46424803
case HostActions: return HOSTACTIONS_TOTAL;
46434804
#endif
4805+
#if HAS_CUSTOM_MENU
4806+
case MenuCustom: return CUSTOM_MENU_TOTAL;
4807+
#endif
46444808
case Control: return CONTROL_TOTAL;
46454809
case TempMenu: return TEMP_TOTAL;
46464810
#if HAS_HOTEND || HAS_HEATED_BED
@@ -4745,6 +4909,7 @@ void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) {
47454909
case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break;
47464910
case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), GET_TEXT_F(MSG_PLEASE_WAIT), Wait, ICON_BLTouch); break;
47474911
case Resuming: Draw_Popup(F("Resuming Print"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break;
4912+
case Custom: Draw_Popup(F("Running Custom GCode"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break;
47484913
default: break;
47494914
}
47504915
}

Marlin/src/lcd/e3v2/jyersui/dwin.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum processID : uint8_t {
4141
enum PopupID : uint8_t {
4242
Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot,
4343
Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing,
44-
FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete,
44+
FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom,
4545
ESDiagPopup
4646
};
4747

@@ -55,6 +55,7 @@ enum menuID : uint8_t {
5555
Preheat,
5656
ChangeFilament,
5757
HostActions,
58+
MenuCustom,
5859
Control,
5960
TempMenu,
6061
PID,

0 commit comments

Comments
 (0)