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

add power off confirm and beep feature #22191

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@
//#define PSU_NAME "Power Supply"

#if ENABLED(PSU_CONTROL)
//#define PS_OFF_CONFIRM // Confirm dialog when power off
//#define PS_OFF_SOUND // Beep 1s when power off
#define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box

//#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/control/M80_M81.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ void GcodeSuite::M81() {
#endif
#endif

#if ENABLED(PS_OFF_SOUND)
BUZZ(1000, 659);
#endif

safe_delay(1000); // Wait 1 second before switching off

#if HAS_SUICIDE
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,13 @@ void MarlinUI::update() {
TERN_(HAS_LCD_MENU, return_to_status());
}

#if BOTH(PSU_CONTROL, PS_OFF_CONFIRM)
void MarlinUI::poweroff() {
queue.inject_P(PSTR("M81"));
goto_previous_screen();
}
#endif

void MarlinUI::flow_fault() {
LCD_ALERTMESSAGEPGM(MSG_FLOWMETER_FAULT);
TERN_(HAS_BUZZER, buzz(1000, 440));
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ class MarlinUI {
static void resume_print();
static void flow_fault();

#if BOTH(PSU_CONTROL, PS_OFF_CONFIRM)
static void poweroff();
#endif

#if HAS_WIRED_LCD

static millis_t next_button_update_ms;
Expand Down
10 changes: 9 additions & 1 deletion Marlin/src/lcd/menu/menu_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,15 @@ void menu_main() {
//
#if ENABLED(PSU_CONTROL)
if (powersupply_on)
GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81"));
#if ENABLED(PS_OFF_CONFIRM)
CONFIRM_ITEM(MSG_SWITCH_PS_OFF,
MSG_YES, MSG_NO,
ui.poweroff, ui.goto_previous_screen,
GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?")
);
#else
GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81"));
#endif
else
GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80"));
#endif
Expand Down
3 changes: 2 additions & 1 deletion buildroot/tests/rambo
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \
BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \
FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \
PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND AUTO_POWER_CONTROL \
POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \
SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL
opt_add DEBUG_POWER_LOSS_RECOVERY
Expand Down