Improvements for Laser / Spindle (#17661)

This commit is contained in:
Luu Lac
2020-06-08 00:47:31 -05:00
committed by GitHub
parent 5ac66b0f95
commit eda2fd8dbe
16 changed files with 448 additions and 268 deletions

View File

@ -541,12 +541,15 @@ void MarlinUI::draw_status_screen() {
// Laser / Spindle
#if DO_DRAW_CUTTER
if (cutter.power && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.power));
#if CUTTER_DISPLAY_IS(PERCENT)
if (cutter.isReady && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
#if CUTTER_UNIT_IS(PERCENT)
lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
lcd_put_wchar('%');
#elif CUTTER_DISPLAY_IS(RPM)
#elif CUTTER_UNIT_IS(RPM)
lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr51rj(float(cutter.unitPower) / 1000));
lcd_put_wchar('K');
#else
lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
#endif
}
#endif

View File

@ -73,7 +73,6 @@ void menu_configuration();
#endif
#if HAS_CUTTER
#include "../../feature/spindle_laser.h"
void menu_spindle_laser();
#endif

View File

@ -34,19 +34,19 @@
void menu_spindle_laser() {
const bool can_disable = cutter.enabled() && cutter.isOn;
const bool is_enabled = cutter.enabled() && cutter.isReady;
START_MENU();
BACK_ITEM(MSG_MAIN);
#if ENABLED(SPINDLE_LASER_PWM)
EDIT_ITEM_FAST( CUTTER_MENU_POWER_TYPE, MSG_CUTTER(POWER), &cutter.setPower
, cutter.interpret_power(SPEED_POWER_MIN), cutter.interpret_power(SPEED_POWER_MAX)
, []{ if (cutter.isOn) cutter.power = cutter.setPower; }
);
// Change the cutter's "current power" value without turning the cutter on or off
// Power is displayed and set in units and range according to CUTTER_POWER_UNIT
EDIT_ITEM_FAST(CUTTER_MENU_POWER_TYPE, MSG_CUTTER(POWER), &cutter.menuPower,
cutter.mpower_min(), cutter.mpower_max(), cutter.update_from_mpower);
#endif
if (can_disable)
if (is_enabled)
ACTION_ITEM(MSG_CUTTER(OFF), cutter.disable);
else {
ACTION_ITEM(MSG_CUTTER(ON), cutter.enable_forward);
@ -57,7 +57,7 @@
#if ENABLED(MARLIN_DEV_MODE)
#if ENABLED(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();});
EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 50000, cutter.refresh_frequency);
#endif
#endif
END_MENU();