Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Spindle/Laser Control menu #20347

Merged
merged 14 commits into from
Dec 9, 2020
1 change: 1 addition & 0 deletions Marlin/src/feature/spindle_laser.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class SpindleLaser {
}
FORCE_INLINE static void enable_forward() { enable_with_dir(false); }
FORCE_INLINE static void enable_reverse() { enable_with_dir(true); }
FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); }

#if ENABLED(SPINDLE_LASER_PWM)
static inline void update_from_mpower() {
Expand Down
22 changes: 12 additions & 10 deletions Marlin/src/lcd/menu/menu_spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

void menu_spindle_laser() {
bool is_enabled = cutter.enabled() && cutter.isReady;
#if ENABLED(SPINDLE_CHANGE_DIR)
bool is_rev = cutter.is_reverse();
#endif

START_MENU();
BACK_ITEM(MSG_MAIN);
Expand All @@ -45,16 +48,15 @@
cutter.mpower_min(), cutter.mpower_max(), cutter.update_from_mpower);
#endif

if (is_enabled)
EDIT_ITEM(bool, MSG_CUTTER(SWITCH), &is_enabled, cutter.disable);
else {
#if ENABLED(SPINDLE_CHANGE_DIR)
EDIT_ITEM(bool, MSG_CUTTER(FORWARD), &is_enabled, cutter.enable_forward);
EDIT_ITEM(bool, MSG_CUTTER(REVERSE), &is_enabled, cutter.enable_reverse);
#else
EDIT_ITEM(bool, MSG_CUTTER(SWITCH), &is_enabled, cutter.enable);
#endif
}
editable.state = is_enabled;
EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ if (editable.state) cutter.disable(); else cutter.enable_same_dir(); });

#if ENABLED(SPINDLE_CHANGE_DIR)
if (!is_enabled) {
editable.state = is_rev;
ACTION_ITEM_P(is_rev ? GET_TEXT(MSG_CUTTER_REVERSE) : GET_TEXT(MSG_CUTTER_FORWARD), []{ cutter.set_reverse(!editable.state); });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACTION_ITEM is still an issue, tested actual pin state, (P5) dir control output is correct

}
#endif

#if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 50000, cutter.refresh_frequency);
Expand Down