mriscoc / Ender3V2S1

This is optimized firmware for Ender3 V2/S1 3D printers.
Other
2.65k stars 360 forks source link

[FR] Added the Input Shaping Menu #475

Closed classicrocker883 closed 1 year ago

classicrocker883 commented 2 years ago

Input Shaping Menu

for editing the values through the LCD.

in file --> lcd/e3v3/proui/dwin.cpp

under void Draw_Prepare_Menu() add

if ENABLED(SHAPING_MENU)

MENU_ITEM(ICON_Language, MSG_INPUT_SHAPING, onDrawSubMenu, Draw_InputShaping_Menu);

endif

this following was below #endif // HAS_TOOLBAR added above // Special Menuitem Drawing functions ===========

// M593 - Acceleration items (Input Shaping)

#if ENABLED(SHAPING_MENU)

void ApplyFreq() { stepper.set_shaping_frequency(HMI_value.axis, *MenuData.P_Float ); }
void ApplyZeta() { stepper.set_shaping_damping_ratio(HMI_value.axis, *MenuData.P_Float ); }

void SetXFreq() { HMI_value.axis = X_AXIS, SetPFloatOnClick(1.0f, 200.0f, 2, ApplyFreq); }

void SetYFreq() { HMI_value.axis = Y_AXIS, SetPFloatOnClick(1.0f, 200.0f, 2, ApplyFreq); }

void SetXZeta() { HMI_value.axis = X_AXIS, SetPFloatOnClick(0.0f, 1.0f, 2, ApplyZeta); }

void SetYZeta() { HMI_value.axis = Y_AXIS, SetPFloatOnClick(0.0f, 1.0f, 2, ApplyZeta); }

  void Draw_InputShaping_Menu() {
    checkkey = Menu;
    if (SET_MENU(InputShapingMenu, MSG_INPUT_SHAPING, 8)) {
      BACK_ITEM(Draw_Prepare_Menu);
    // M593 F Frequency
    #if HAS_SHAPING_X
      static float xfreq = stepper.get_shaping_frequency(X_AXIS);
      EDIT_ITEM(ICON_MoveX, MSG_SHAPING_X_FREQ, onDrawPFloat2Menu, SetXFreq, &xfreq);

    #endif
    #if HAS_SHAPING_Y
      static float yfreq = stepper.get_shaping_frequency(Y_AXIS);
      EDIT_ITEM(ICON_MoveY, MSG_SHAPING_Y_FREQ, onDrawPFloat2Menu, SetYFreq, &yfreq);
    #endif
    // M593 D Damping ratio
    #if HAS_SHAPING_X
      static float xzeta = stepper.get_shaping_damping_ratio(X_AXIS);
      EDIT_ITEM(ICON_MoveX, MSG_SHAPING_X_ZETA, onDrawPFloat2Menu, SetXZeta, &xzeta);

    #endif
    #if HAS_SHAPING_Y
      static float yzeta = stepper.get_shaping_damping_ratio(Y_AXIS);
      EDIT_ITEM(ICON_MoveY, MSG_SHAPING_Y_ZETA, onDrawPFloat2Menu, SetYZeta, &yzeta);
    #endif
    }
  UpdateMenu(InputShapingMenu);
  }
#endif
mriscoc commented 1 year ago

A new Input shaping menu is on work for the next experimental, but "IS" is not confirmed to work in stock Creality boards. It is better to get the parameters values inside of an onDraw function that ensures the correct redrawing of the menu.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.