Browse Source

Merge pull request #6682 from thinkyhead/bf_M80_s_arg

"M80 S" to report the state of the PSU pin
Scott Lahteine 8 years ago
parent
commit
9a688d1456
2 changed files with 22 additions and 12 deletions
  1. 20
    10
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/ultralcd.cpp

+ 20
- 10
Marlin/Marlin_main.cpp View File

@@ -559,8 +559,8 @@ static uint8_t target_extruder;
559 559
 
560 560
 #endif // FWRETRACT
561 561
 
562
-#if ENABLED(ULTIPANEL) && HAS_POWER_SWITCH
563
-  bool powersupply =
562
+#if HAS_POWER_SWITCH
563
+  bool powersupply_on =
564 564
     #if ENABLED(PS_DEFAULT_OFF)
565 565
       false
566 566
     #else
@@ -7093,10 +7093,18 @@ inline void gcode_M140() {
7093 7093
 #if HAS_POWER_SWITCH
7094 7094
 
7095 7095
   /**
7096
-   * M80: Turn on Power Supply
7096
+   * M80   : Turn on the Power Supply
7097
+   * M80 S : Report the current state and exit
7097 7098
    */
7098 7099
   inline void gcode_M80() {
7099
-    OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); //GND
7100
+
7101
+    // S: Report the current power supply state and exit
7102
+    if (code_seen('S')) {
7103
+      serialprintPGM(powersupply_on ? PSTR("PS:1\n") : PSTR("PS:0\n"));
7104
+      return;
7105
+    }
7106
+
7107
+    OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND
7100 7108
 
7101 7109
     /**
7102 7110
      * If you have a switch on suicide pin, this is useful
@@ -7112,8 +7120,9 @@ inline void gcode_M140() {
7112 7120
       tmc2130_init(); // Settings only stick when the driver has power
7113 7121
     #endif
7114 7122
 
7123
+    powersupply_on = true;
7124
+
7115 7125
     #if ENABLED(ULTIPANEL)
7116
-      powersupply = true;
7117 7126
       LCD_MESSAGEPGM(WELCOME_MSG);
7118 7127
     #endif
7119 7128
   }
@@ -7128,25 +7137,26 @@ inline void gcode_M140() {
7128 7137
 inline void gcode_M81() {
7129 7138
   thermalManager.disable_all_heaters();
7130 7139
   stepper.finish_and_disable();
7140
+
7131 7141
   #if FAN_COUNT > 0
7132 7142
     for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
7133
-
7134 7143
     #if ENABLED(PROBING_FANS_OFF)
7135 7144
       fans_paused = false;
7136 7145
       ZERO(paused_fanSpeeds);
7137 7146
     #endif
7138 7147
   #endif
7148
+
7139 7149
   safe_delay(1000); // Wait 1 second before switching off
7150
+
7140 7151
   #if HAS_SUICIDE
7141 7152
     stepper.synchronize();
7142 7153
     suicide();
7143 7154
   #elif HAS_POWER_SWITCH
7144 7155
     OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
7156
+    powersupply_on = false;
7145 7157
   #endif
7158
+
7146 7159
   #if ENABLED(ULTIPANEL)
7147
-    #if HAS_POWER_SWITCH
7148
-      powersupply = false;
7149
-    #endif
7150 7160
     LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF ".");
7151 7161
   #endif
7152 7162
 }
@@ -10133,7 +10143,7 @@ void process_next_command() {
10133 10143
         gcode_M81();
10134 10144
         break;
10135 10145
 
10136
-      case 82: // M83: Set E axis normal mode (same as other axes)
10146
+      case 82: // M82: Set E axis normal mode (same as other axes)
10137 10147
         gcode_M82();
10138 10148
         break;
10139 10149
       case 83: // M83: Set E axis relative mode

+ 2
- 2
Marlin/ultralcd.cpp View File

@@ -98,7 +98,7 @@ uint16_t max_display_update_time = 0;
98 98
   typedef void (*screenFunc_t)();
99 99
 
100 100
   #if HAS_POWER_SWITCH
101
-    extern bool powersupply;
101
+    extern bool powersupply_on;
102 102
   #endif
103 103
 
104 104
   #if ENABLED(AUTO_BED_LEVELING_UBL)
@@ -2129,7 +2129,7 @@ void kill_screen(const char* lcd_msg) {
2129 2129
     // Switch power on/off
2130 2130
     //
2131 2131
     #if HAS_POWER_SWITCH
2132
-      if (powersupply)
2132
+      if (powersupply_on)
2133 2133
         MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
2134 2134
       else
2135 2135
         MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));

Loading…
Cancel
Save