Browse Source

"M80 S" to report the state of the PSU pin

pull/1/head
Pablo Ventura 8 years ago
committed by Scott Lahteine
parent
commit
539e0c2f31
  1. 28
      Marlin/Marlin_main.cpp
  2. 4
      Marlin/ultralcd.cpp

28
Marlin/Marlin_main.cpp

@ -559,8 +559,8 @@ static uint8_t target_extruder;
#endif // FWRETRACT #endif // FWRETRACT
#if ENABLED(ULTIPANEL) && HAS_POWER_SWITCH #if HAS_POWER_SWITCH
bool powersupply = bool powersupply_on =
#if ENABLED(PS_DEFAULT_OFF) #if ENABLED(PS_DEFAULT_OFF)
false false
#else #else
@ -7093,9 +7093,17 @@ inline void gcode_M140() {
#if HAS_POWER_SWITCH #if HAS_POWER_SWITCH
/** /**
* M80: Turn on Power Supply * M80 : Turn on the Power Supply
* M80 S : Report the current state and exit
*/ */
inline void gcode_M80() { inline void gcode_M80() {
// S: Report the current power supply state and exit
if (code_seen('S')) {
serialprintPGM(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
return;
}
OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
/** /**
@ -7112,8 +7120,9 @@ inline void gcode_M140() {
tmc2130_init(); // Settings only stick when the driver has power tmc2130_init(); // Settings only stick when the driver has power
#endif #endif
powersupply_on = true;
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
powersupply = true;
LCD_MESSAGEPGM(WELCOME_MSG); LCD_MESSAGEPGM(WELCOME_MSG);
#endif #endif
} }
@ -7128,25 +7137,26 @@ inline void gcode_M140() {
inline void gcode_M81() { inline void gcode_M81() {
thermalManager.disable_all_heaters(); thermalManager.disable_all_heaters();
stepper.finish_and_disable(); stepper.finish_and_disable();
#if FAN_COUNT > 0 #if FAN_COUNT > 0
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0; for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
#if ENABLED(PROBING_FANS_OFF) #if ENABLED(PROBING_FANS_OFF)
fans_paused = false; fans_paused = false;
ZERO(paused_fanSpeeds); ZERO(paused_fanSpeeds);
#endif #endif
#endif #endif
safe_delay(1000); // Wait 1 second before switching off safe_delay(1000); // Wait 1 second before switching off
#if HAS_SUICIDE #if HAS_SUICIDE
stepper.synchronize(); stepper.synchronize();
suicide(); suicide();
#elif HAS_POWER_SWITCH #elif HAS_POWER_SWITCH
OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
powersupply_on = false;
#endif #endif
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
#if HAS_POWER_SWITCH
powersupply = false;
#endif
LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF "."); LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF ".");
#endif #endif
} }
@ -10119,7 +10129,7 @@ void process_next_command() {
gcode_M81(); gcode_M81();
break; break;
case 82: // M83: Set E axis normal mode (same as other axes) case 82: // M82: Set E axis normal mode (same as other axes)
gcode_M82(); gcode_M82();
break; break;
case 83: // M83: Set E axis relative mode case 83: // M83: Set E axis relative mode

4
Marlin/ultralcd.cpp

@ -98,7 +98,7 @@ uint16_t max_display_update_time = 0;
typedef void (*screenFunc_t)(); typedef void (*screenFunc_t)();
#if HAS_POWER_SWITCH #if HAS_POWER_SWITCH
extern bool powersupply; extern bool powersupply_on;
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
@ -2129,7 +2129,7 @@ void kill_screen(const char* lcd_msg) {
// Switch power on/off // Switch power on/off
// //
#if HAS_POWER_SWITCH #if HAS_POWER_SWITCH
if (powersupply) if (powersupply_on)
MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81")); MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
else else
MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80")); MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));

Loading…
Cancel
Save