Fix Spindle/Laser Control menu (#20347)

This commit is contained in:
Mike La Spina
2020-12-09 04:29:33 -06:00
committed by Scott Lahteine
parent edb2a83e71
commit 3e68e4b418
7 changed files with 33 additions and 23 deletions

View File

@@ -33,8 +33,10 @@
#include "../../feature/spindle_laser.h"
void menu_spindle_laser() {
const bool is_enabled = cutter.enabled() && cutter.isReady;
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);
@@ -46,18 +48,20 @@
cutter.mpower_min(), cutter.mpower_max(), cutter.update_from_mpower);
#endif
if (is_enabled)
ACTION_ITEM(MSG_CUTTER(OFF), cutter.disable);
else {
ACTION_ITEM(MSG_CUTTER(ON), cutter.enable_forward);
#if ENABLED(SPINDLE_CHANGE_DIR)
ACTION_ITEM(MSG_SPINDLE_REVERSE, cutter.enable_reverse);
#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); });
}
#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);
#endif
END_MENU();
}