|
142 | 142 | #define MIN_BED_TEMP 0
|
143 | 143 | #endif
|
144 | 144 |
|
| 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 | + |
145 | 165 | constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
|
146 | 166 | constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
|
147 | 167 | constexpr float default_steps[] = DEFAULT_AXIS_STEPS_PER_UNIT;
|
@@ -1170,8 +1190,6 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
|
1170 | 1190 | }
|
1171 | 1191 | #endif
|
1172 | 1192 |
|
1173 |
| - |
1174 |
| - |
1175 | 1193 | /* Menu Item Config */
|
1176 | 1194 |
|
1177 | 1195 | 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/
|
1244 | 1262 | #define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED))
|
1245 | 1263 | #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE))
|
1246 | 1264 | #define PREPARE_ACTIONCOMMANDS (PREPARE_CHANGEFIL + (ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)))
|
| 1265 | + #define PREPARE_CUSTOM_MENU (PREPARE_ACTIONCOMMANDS + ENABLED(HAS_CUSTOM_MENU)) |
1247 | 1266 | #define PREPARE_TOTAL PREPARE_ACTIONCOMMANDS
|
1248 | 1267 |
|
1249 | 1268 | switch (item) {
|
@@ -1330,6 +1349,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
1330 | 1349 | break;
|
1331 | 1350 | #endif
|
1332 | 1351 |
|
| 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 | + |
1333 | 1364 | #if ENABLED(ADVANCED_PAUSE_FEATURE)
|
1334 | 1365 | case PREPARE_CHANGEFIL:
|
1335 | 1366 | if (draw) {
|
@@ -1985,6 +2016,126 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
1985 | 2016 | break;
|
1986 | 2017 | #endif
|
1987 | 2018 |
|
| 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 | + |
1988 | 2139 | case Control:
|
1989 | 2140 |
|
1990 | 2141 | #define CONTROL_BACK 0
|
@@ -4885,6 +5036,14 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) {
|
4885 | 5036 | #if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
|
4886 | 5037 | case HostActions: return F("Host Actions");
|
4887 | 5038 | #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 |
4888 | 5047 | case Control: return GET_TEXT_F(MSG_CONTROL);
|
4889 | 5048 | case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE);
|
4890 | 5049 | #if HAS_HOTEND || HAS_HEATED_BED
|
@@ -4988,6 +5147,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) {
|
4988 | 5147 | #if ENABLED(HOST_ACTION_COMMANDS, HAS_HOSTACTION_MENUS)
|
4989 | 5148 | case HostActions: return HOSTACTIONS_TOTAL;
|
4990 | 5149 | #endif
|
| 5150 | + #if HAS_CUSTOM_MENU |
| 5151 | + case MenuCustom: return CUSTOM_MENU_TOTAL; |
| 5152 | + #endif |
4991 | 5153 | case Control: return CONTROL_TOTAL;
|
4992 | 5154 | case TempMenu: return TEMP_TOTAL;
|
4993 | 5155 | #if HAS_HOTEND || HAS_HEATED_BED
|
@@ -5101,6 +5263,7 @@ void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) {
|
5101 | 5263 | case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break;
|
5102 | 5264 | case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), GET_TEXT_F(MSG_PLEASE_WAIT), Wait, ICON_BLTouch); break;
|
5103 | 5265 | 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; |
5104 | 5267 | default: break;
|
5105 | 5268 | }
|
5106 | 5269 | }
|
|
0 commit comments