|
144 | 144 | #define MIN_BED_TEMP 0
|
145 | 145 | #endif
|
146 | 146 |
|
| 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 | + |
147 | 167 | constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
|
148 | 168 | constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
|
149 | 169 | 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/
|
1246 | 1266 | #define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED))
|
1247 | 1267 | #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE))
|
1248 | 1268 | #define PREPARE_ACTIONCOMMANDS (PREPARE_CHANGEFIL + (ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)))
|
| 1269 | + #define PREPARE_CUSTOM_MENU (PREPARE_ACTIONCOMMANDS + ENABLED(HAS_CUSTOM_MENU)) |
1249 | 1270 | #define PREPARE_TOTAL PREPARE_ACTIONCOMMANDS
|
1250 | 1271 |
|
1251 | 1272 | switch (item) {
|
@@ -1332,6 +1353,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
1332 | 1353 | break;
|
1333 | 1354 | #endif
|
1334 | 1355 |
|
| 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 | + |
1335 | 1368 | #if ENABLED(ADVANCED_PAUSE_FEATURE)
|
1336 | 1369 | case PREPARE_CHANGEFIL:
|
1337 | 1370 | if (draw) {
|
@@ -1974,6 +2007,126 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
1974 | 2007 | break;
|
1975 | 2008 | #endif
|
1976 | 2009 |
|
| 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 | + |
1977 | 2130 | case Control:
|
1978 | 2131 |
|
1979 | 2132 | #define CONTROL_BACK 0
|
@@ -4547,6 +4700,14 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
|
4547 | 4700 | #if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
|
4548 | 4701 | case HostActions: return F("Host Actions");
|
4549 | 4702 | #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 |
4550 | 4711 | case Control: return GET_TEXT_F(MSG_CONTROL);
|
4551 | 4712 | case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE);
|
4552 | 4713 | #if HAS_HOTEND || HAS_HEATED_BED
|
@@ -4641,6 +4802,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
|
4641 | 4802 | #if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
|
4642 | 4803 | case HostActions: return HOSTACTIONS_TOTAL;
|
4643 | 4804 | #endif
|
| 4805 | + #if HAS_CUSTOM_MENU |
| 4806 | + case MenuCustom: return CUSTOM_MENU_TOTAL; |
| 4807 | + #endif |
4644 | 4808 | case Control: return CONTROL_TOTAL;
|
4645 | 4809 | case TempMenu: return TEMP_TOTAL;
|
4646 | 4810 | #if HAS_HOTEND || HAS_HEATED_BED
|
@@ -4745,6 +4909,7 @@ void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) {
|
4745 | 4909 | case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break;
|
4746 | 4910 | case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), GET_TEXT_F(MSG_PLEASE_WAIT), Wait, ICON_BLTouch); break;
|
4747 | 4911 | 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; |
4748 | 4913 | default: break;
|
4749 | 4914 | }
|
4750 | 4915 | }
|
|
0 commit comments