MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.28k stars 19.24k forks source link

[FR] Add Input Shaping on JyersUI #25534

Open Sherman-c opened 1 year ago

Sherman-c commented 1 year ago

Is your feature request related to a problem? Please describe.

There was not Input Shaping Menu on bugfix-2.1.x with JyersUI

Are you looking for hardware support?

No response

Describe the feature you want

Add Input Shaping Menu on bugfix-2.1.x with JyersUI. I love JyersUI personally, it simple and easy to use, and it is sad if JyersUI get phased out, I added the following code to show Input Shaping Menu on JyersUI, Unfortunately I do not know to do pull-request properly. Under lcd/e3v2/jyersui/dwin.h

@@ -33,8 +33,14 @@
 #include "../../../libs/BL24CXX.h"

 #include "../../../inc/MarlinConfigPre.h"
+#if ENABLED(SHAPING_MENU)
+       #define _MIN_INPUTSHAP_FREQ     1.0f
+       #define _MAX_INPUTSHAP_FREQ     200.0f
+       #define _MIN_INPUTSHAP_ZETA     0
+       #define _MAX_INPUTSHAP_ZETA     1
+#endif

-//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
+#define DWIN_CREALITY_LCD_CUSTOM_ICONS

 enum processID : uint8_t {

@@ -75,6 +81,9 @@
         ColorSettings,
       Advanced,
         ProbeMenu,
+                       #if ENABLED(SHAPING_MENU)
+                               InputShapingMenu,
+                       #endif
       #if HAS_TRINAMIC_CONFIG
         TMCMenu,
       #endif

 lcd/e3v2/jyersui/dwin.cpp
@@ -80,6 +80,10 @@
   #include "../../../feature/powerloss.h"
 #endif

+#if ENABLED(SHAPING_MENU)
+       #include "../../../module/stepper.h"
+#endif
+
 #if HAS_TRINAMIC_CONFIG
   #include "../../../module/stepper/trinamic.h"

@@ -2727,7 +2731,8 @@
       #define ADVANCED_BACK 0
       #define ADVANCED_BEEPER (ADVANCED_BACK + ENABLED(SOUND_MENU_ITEM))
       #define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE))
-      #define ADVANCED_TMC (ADVANCED_PROBE + ENABLED(HAS_TRINAMIC_CONFIG))
+                       #define ADVANCED_INPUTSHAPING (ADVANCED_PROBE + ENABLED(SHAPING_MENU))
+      #define ADVANCED_TMC (ADVANCED_INPUTSHAPING + ENABLED(HAS_TRINAMIC_CONFIG))
       #define ADVANCED_CORNER (ADVANCED_TMC + 1)
       #define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE))
       #define ADVANCED_LOAD (ADVANCED_LA + ENABLED(ADVANCED_PAUSE_FEATURE))
@@ -2768,6 +2773,15 @@
             break;
         #endif

+                               #if ENABLED(SHAPING_MENU)
+                                       case ADVANCED_INPUTSHAPING:
+                                               if (draw)
+                                                       Draw_Menu_Item(row, ICON_StepX, GET_TEXT_F(MSG_INPUT_SHAPING), nullptr, true);
+                                               else
+                                                       Draw_Menu(InputShapingMenu);
+                                               break;
+                               #endif
+
         #if HAS_TRINAMIC_CONFIG
           case ADVANCED_TMC:
             if (draw)
@@ -2924,6 +2938,74 @@
         break;
     #endif  // HAS_PROBE_MENU

+               #if ENABLED(SHAPING_MENU)
+                       case InputShapingMenu:
+
+                               #define INPUTSHAPING_BACK 0
+                               #define INPUTSHAPING_X_FREQ             (INPUTSHAPING_BACK + 1)
+                               #define INPUTSHAPING_X_DAMP             (INPUTSHAPING_X_FREQ + 1)
+                               #define INPUTSHAPING_Y_FREQ             (INPUTSHAPING_X_DAMP + 1)
+                               #define INPUTSHAPING_Y_DAMP             (INPUTSHAPING_Y_FREQ + 1)
+                               #define INPUTSHAPING_TOTAL              INPUTSHAPING_Y_DAMP
+
+                               static float current_value = 0.0;
+
+                               switch (item) {
+
+                                       case INPUTSHAPING_BACK:
+                                               if (draw)
+                                                       Draw_Menu_Item(row, ICON_Back, F("Back"));
+                                               else
+                                                       Draw_Menu(Advanced, ADVANCED_INPUTSHAPING);
+                                               break;
+
+                                       case INPUTSHAPING_X_FREQ:
+                                               current_value = stepper.get_shaping_frequency(X_AXIS);
+                                               if (draw) {
+                                                       Draw_Menu_Item(row, ICON_StepX, F("X Freq"));
+                                                       Draw_Float(current_value, row, false, 100);
+                                               }
+                                               else {
+                                                       Modify_Value(current_value, _MIN_INPUTSHAP_FREQ, _MAX_INPUTSHAP_FREQ, 100, []{stepper.set_shaping_frequency(X_AXIS, current_value);});
+                                               }
+                                               break;
+
+                                       case INPUTSHAPING_X_DAMP:
+                                               current_value = stepper.get_shaping_damping_ratio(X_AXIS);
+                                               if (draw) {
+                                                       Draw_Menu_Item(row, ICON_StepX, F("X Damping"));
+                                                       Draw_Float(current_value, row, false, 100);
+                                               }
+                                               else {
+                                                       Modify_Value(current_value, _MIN_INPUTSHAP_ZETA, _MAX_INPUTSHAP_ZETA, 100, []{stepper.set_shaping_damping_ratio(X_AXIS, current_value);});
+                                               }
+                                               break;
+
+                                       case INPUTSHAPING_Y_FREQ:
+                                               current_value = stepper.get_shaping_frequency(Y_AXIS);
+                                               if (draw) {
+                                                       Draw_Menu_Item(row, ICON_StepY, F("Y Freq"));
+                                                       Draw_Float(current_value, row, false, 100);
+                                               }
+                                               else {
+                                                       Modify_Value(current_value, _MIN_INPUTSHAP_FREQ, _MAX_INPUTSHAP_FREQ, 100, []{stepper.set_shaping_frequency(Y_AXIS, current_value);});
+                                               }
+                                               break;
+
+                                       case INPUTSHAPING_Y_DAMP:
+                                               current_value = stepper.get_shaping_damping_ratio(Y_AXIS);
+                                               if (draw) {
+                                                       Draw_Menu_Item(row, ICON_StepY, F("Y Damping"));
+                                                       Draw_Float(current_value, row, false, 100);
+                                               }
+                                               else {
+                                                       Modify_Value(current_value, _MIN_INPUTSHAP_ZETA, _MAX_INPUTSHAP_ZETA, 100, []{stepper.set_shaping_damping_ratio(Y_AXIS, current_value);});
+                                               }
+                                               break;
+                               }
+                       break;
+               #endif
+
     #if HAS_TRINAMIC_CONFIG
       case TMCMenu:

@@ -3984,6 +4066,9 @@
     #if HAS_BED_PROBE
       case ProbeMenu:       return F("Bed Probe");
     #endif
+               #if ENABLED(SHAPING_MENU)
+                       case InputShapingMenu:  return GET_TEXT_F(MSG_INPUT_SHAPING);
+               #endif
     #if HAS_TRINAMIC_CONFIG
       case TMCMenu:         return F("TMC Drivers");
     #endif
@@ -4055,6 +4140,9 @@
     #if HAS_BED_PROBE
       case ProbeMenu:       return PROBE_TOTAL;
     #endif
+               #if ENABLED(SHAPING_MENU)
+                       case InputShapingMenu:  return INPUTSHAPING_TOTAL;
+               #endif
     #if HAS_TRINAMIC_CONFIG
       case TMCMenu:         return TMC_TOTAL;
     #endif

Additional context

No response

ellensp commented 1 year ago

Pull requests 101: 1) Fork Marlin into you own githug repository https://github.com/MarlinFirmware/Marlin/fork 2) Create a branch from bugfix 2.1.x branch (many way to do this, I use cmd line and platformio) git clone https://github.com/Sherman-c/Marlin.git this downloads your fork of marlin to your machine git checkout bugfix2.1.x or select branch in platformio (bottom left, shows branch name) git branch new-branch-name or click or select branch in platformio and use menu to create new branch 3) edit what you want to edit 4) commit the changes I use platformio, click on source control icon on left, enter a comment for the commit. click commit. 5) push the commit back to github. Ie upload them to your repository

Now if you browse your repository or marlin, github will ask you do you want to create a pull request