Skip to content

Commit 2ab1df4

Browse files
bryan065LCh-77
authored andcommitted
🚸 Custom Menu Items for JyersUI (MarlinFirmware#24270)
1 parent 60832a7 commit 2ab1df4

File tree

2 files changed

+167
-3
lines changed

2 files changed

+167
-3
lines changed

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

+165-2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@
142142
#define MIN_BED_TEMP 0
143143
#endif
144144

145+
/**
146+
* Custom menu items with jyersLCD
147+
*/
148+
#if ENABLED(CUSTOM_MENU_CONFIG)
149+
#ifdef CONFIG_MENU_ITEM_5_DESC
150+
#define CUSTOM_MENU_COUNT 5
151+
#elif defined(CONFIG_MENU_ITEM_4_DESC)
152+
#define CUSTOM_MENU_COUNT 4
153+
#elif defined(CONFIG_MENU_ITEM_3_DESC)
154+
#define CUSTOM_MENU_COUNT 3
155+
#elif defined(CONFIG_MENU_ITEM_2_DESC)
156+
#define CUSTOM_MENU_COUNT 2
157+
#elif defined(CONFIG_MENU_ITEM_1_DESC)
158+
#define CUSTOM_MENU_COUNT 1
159+
#endif
160+
#if CUSTOM_MENU_COUNT
161+
#define HAS_CUSTOM_MENU 1
162+
#endif
163+
#endif
164+
145165
constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
146166
constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
147167
constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT;
@@ -1170,8 +1190,6 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
11701190
}
11711191
#endif
11721192

1173-
1174-
11751193
/* Menu Item Config */
11761194

11771195
void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) {
@@ -1244,6 +1262,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
12441262
#define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED))
12451263
#define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE))
12461264
#define PREPARE_ACTIONCOMMANDS (PREPARE_CHANGEFIL + (ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)))
1265+
#define PREPARE_CUSTOM_MENU (PREPARE_ACTIONCOMMANDS + ENABLED(HAS_CUSTOM_MENU))
12471266
#define PREPARE_TOTAL PREPARE_ACTIONCOMMANDS
12481267

12491268
switch (item) {
@@ -1330,6 +1349,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
13301349
break;
13311350
#endif
13321351

1352+
#if HAS_CUSTOM_MENU
1353+
case PREPARE_CUSTOM_MENU:
1354+
#ifndef CUSTOM_MENU_CONFIG_TITLE
1355+
#define CUSTOM_MENU_CONFIG_TITLE "Custom Commands"
1356+
#endif
1357+
if (draw)
1358+
Draw_Menu_Item(row, ICON_Version, F(CUSTOM_MENU_CONFIG_TITLE));
1359+
else
1360+
Draw_Menu(MenuCustom);
1361+
break;
1362+
#endif
1363+
13331364
#if ENABLED(ADVANCED_PAUSE_FEATURE)
13341365
case PREPARE_CHANGEFIL:
13351366
if (draw) {
@@ -1985,6 +2016,126 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
19852016
break;
19862017
#endif
19872018

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

19902141
#define CONTROL_BACK 0
@@ -4885,6 +5036,14 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
48855036
#if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
48865037
case HostActions: return F("Host Actions");
48875038
#endif
5039+
#if HAS_CUSTOM_MENU
5040+
case MenuCustom:
5041+
#ifdef CUSTOM_MENU_CONFIG_TITLE
5042+
return F(CUSTOM_MENU_CONFIG_TITLE);
5043+
#else
5044+
return F("Custom Commands");
5045+
#endif
5046+
#endif
48885047
case Control: return GET_TEXT_F(MSG_CONTROL);
48895048
case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE);
48905049
#if HAS_HOTEND || HAS_HEATED_BED
@@ -4988,6 +5147,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
49885147
#if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
49895148
case HostActions: return HOSTACTIONS_TOTAL;
49905149
#endif
5150+
#if HAS_CUSTOM_MENU
5151+
case MenuCustom: return CUSTOM_MENU_TOTAL;
5152+
#endif
49915153
case Control: return CONTROL_TOTAL;
49925154
case TempMenu: return TEMP_TOTAL;
49935155
#if HAS_HOTEND || HAS_HEATED_BED
@@ -5101,6 +5263,7 @@ void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) {
51015263
case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break;
51025264
case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), GET_TEXT_F(MSG_PLEASE_WAIT), Wait, ICON_BLTouch); break;
51035265
case Resuming: Draw_Popup(F("Resuming Print"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break;
5266+
case Custom: Draw_Popup(F("Running Custom GCode"), GET_TEXT_F(MSG_PLEASE_WAIT), F(""), Wait, ICON_BLTouch); break;
51045267
default: break;
51055268
}
51065269
}

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)