浏览代码

Host parseble output for M109, M190 and M303

Make the output of M105 more similar to Repetier.
Make the text-print pert of M105 an extra function to make it reusable. `print_heaterstates()`
Use `print_heaterstates()` in M019, M190 and M303
AnHardt 9 年前
父节点
当前提交
57da1b8497
共有 3 个文件被更改,包括 87 次插入72 次删除
  1. 4
    0
      Marlin/Marlin.h
  2. 79
    59
      Marlin/Marlin_main.cpp
  3. 4
    13
      Marlin/temperature.cpp

+ 4
- 0
Marlin/Marlin.h 查看文件

@@ -351,6 +351,10 @@ extern uint8_t active_extruder;
351 351
   extern void digipot_i2c_init();
352 352
 #endif
353 353
 
354
+#if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
355
+  void print_heaterstates();
356
+#endif
357
+
354 358
 extern void calculate_volumetric_multipliers();
355 359
 
356 360
 #endif //MARLIN_H

+ 79
- 59
Marlin/Marlin_main.cpp 查看文件

@@ -3802,14 +3802,9 @@ inline void gcode_M104() {
3802 3802
   }
3803 3803
 }
3804 3804
 
3805
-/**
3806
- * M105: Read hot end and bed temperature
3807
- */
3808
-inline void gcode_M105() {
3809
-  if (setTargetedHotend(105)) return;
3805
+#if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
3810 3806
 
3811
-  #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
3812
-    SERIAL_PROTOCOLPGM(MSG_OK);
3807
+  void print_heaterstates() {
3813 3808
     #if HAS_TEMP_0 || ENABLED(HEATER_0_USES_MAX6675)
3814 3809
       SERIAL_PROTOCOLPGM(" T:");
3815 3810
       SERIAL_PROTOCOL_F(degHotend(target_extruder), 1);
@@ -3822,52 +3817,78 @@ inline void gcode_M105() {
3822 3817
       SERIAL_PROTOCOLPGM(" /");
3823 3818
       SERIAL_PROTOCOL_F(degTargetBed(), 1);
3824 3819
     #endif
3825
-    for (int8_t e = 0; e < EXTRUDERS; ++e) {
3826
-      SERIAL_PROTOCOLPGM(" T");
3827
-      SERIAL_PROTOCOL(e);
3828
-      SERIAL_PROTOCOLCHAR(':');
3829
-      SERIAL_PROTOCOL_F(degHotend(e), 1);
3830
-      SERIAL_PROTOCOLPGM(" /");
3831
-      SERIAL_PROTOCOL_F(degTargetHotend(e), 1);
3832
-    }
3820
+    #if EXTRUDERS > 1
3821
+      for (int8_t e = 0; e < EXTRUDERS; ++e) {
3822
+        SERIAL_PROTOCOLPGM(" T");
3823
+        SERIAL_PROTOCOL(e);
3824
+        SERIAL_PROTOCOLCHAR(':');
3825
+        SERIAL_PROTOCOL_F(degHotend(e), 1);
3826
+        SERIAL_PROTOCOLPGM(" /");
3827
+        SERIAL_PROTOCOL_F(degTargetHotend(e), 1);
3828
+      }
3829
+    #endif
3830
+    #if HAS_TEMP_BED
3831
+      SERIAL_PROTOCOLPGM(" B@:");
3832
+      #ifdef BED_WATTS
3833
+        SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1)) / 127);
3834
+        SERIAL_PROTOCOLCHAR('W');
3835
+      #else
3836
+        SERIAL_PROTOCOL(getHeaterPower(-1));
3837
+      #endif
3838
+    #endif
3839
+    SERIAL_PROTOCOLPGM(" @:");
3840
+    #ifdef EXTRUDER_WATTS
3841
+      SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(target_extruder)) / 127);
3842
+      SERIAL_PROTOCOLCHAR('W');
3843
+    #else
3844
+      SERIAL_PROTOCOL(getHeaterPower(target_extruder));
3845
+    #endif
3846
+    #if EXTRUDERS > 1
3847
+      for (int8_t e = 0; e < EXTRUDERS; ++e) {
3848
+        SERIAL_PROTOCOLPGM(" @");
3849
+        SERIAL_PROTOCOL(e);
3850
+        SERIAL_PROTOCOLCHAR(':');
3851
+        #ifdef EXTRUDER_WATTS
3852
+          SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(e)) / 127);
3853
+          SERIAL_PROTOCOLCHAR('W');
3854
+        #else
3855
+          SERIAL_PROTOCOL(getHeaterPower(e));
3856
+        #endif
3857
+      }
3858
+    #endif
3859
+    #if ENABLED(SHOW_TEMP_ADC_VALUES)
3860
+      #if HAS_TEMP_BED
3861
+        SERIAL_PROTOCOLPGM("    ADC B:");
3862
+        SERIAL_PROTOCOL_F(degBed(), 1);
3863
+        SERIAL_PROTOCOLPGM("C->");
3864
+        SERIAL_PROTOCOL_F(rawBedTemp() / OVERSAMPLENR, 0);
3865
+      #endif
3866
+      for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
3867
+        SERIAL_PROTOCOLPGM("  T");
3868
+        SERIAL_PROTOCOL(cur_extruder);
3869
+        SERIAL_PROTOCOLCHAR(':');
3870
+        SERIAL_PROTOCOL_F(degHotend(cur_extruder), 1);
3871
+        SERIAL_PROTOCOLPGM("C->");
3872
+        SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder) / OVERSAMPLENR, 0);
3873
+      }
3874
+    #endif
3875
+  }
3876
+#endif
3877
+
3878
+/**
3879
+ * M105: Read hot end and bed temperature
3880
+ */
3881
+inline void gcode_M105() {
3882
+  if (setTargetedHotend(105)) return;
3883
+
3884
+  #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
3885
+    SERIAL_PROTOCOLPGM(MSG_OK);
3886
+    print_heaterstates();
3833 3887
   #else // !HAS_TEMP_0 && !HAS_TEMP_BED
3834 3888
     SERIAL_ERROR_START;
3835 3889
     SERIAL_ERRORLNPGM(MSG_ERR_NO_THERMISTORS);
3836 3890
   #endif
3837 3891
 
3838
-  SERIAL_PROTOCOLPGM(" @:");
3839
-  #ifdef EXTRUDER_WATTS
3840
-    SERIAL_PROTOCOL((EXTRUDER_WATTS * getHeaterPower(target_extruder)) / 127);
3841
-    SERIAL_PROTOCOLCHAR('W');
3842
-  #else
3843
-    SERIAL_PROTOCOL(getHeaterPower(target_extruder));
3844
-  #endif
3845
-
3846
-  SERIAL_PROTOCOLPGM(" B@:");
3847
-  #ifdef BED_WATTS
3848
-    SERIAL_PROTOCOL((BED_WATTS * getHeaterPower(-1)) / 127);
3849
-    SERIAL_PROTOCOLCHAR('W');
3850
-  #else
3851
-    SERIAL_PROTOCOL(getHeaterPower(-1));
3852
-  #endif
3853
-
3854
-  #if ENABLED(SHOW_TEMP_ADC_VALUES)
3855
-    #if HAS_TEMP_BED
3856
-      SERIAL_PROTOCOLPGM("    ADC B:");
3857
-      SERIAL_PROTOCOL_F(degBed(), 1);
3858
-      SERIAL_PROTOCOLPGM("C->");
3859
-      SERIAL_PROTOCOL_F(rawBedTemp() / OVERSAMPLENR, 0);
3860
-    #endif
3861
-    for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
3862
-      SERIAL_PROTOCOLPGM("  T");
3863
-      SERIAL_PROTOCOL(cur_extruder);
3864
-      SERIAL_PROTOCOLCHAR(':');
3865
-      SERIAL_PROTOCOL_F(degHotend(cur_extruder), 1);
3866
-      SERIAL_PROTOCOLPGM("C->");
3867
-      SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder) / OVERSAMPLENR, 0);
3868
-    }
3869
-  #endif
3870
-
3871 3892
   SERIAL_EOL;
3872 3893
 }
3873 3894
 
@@ -3932,10 +3953,9 @@ inline void gcode_M109() {
3932 3953
 
3933 3954
   { // while loop
3934 3955
     if (millis() > temp_ms + 1000UL) { //Print temp & remaining time every 1s while waiting
3935
-      SERIAL_PROTOCOLPGM("T:");
3936
-      SERIAL_PROTOCOL_F(degHotend(target_extruder), 1);
3937
-      SERIAL_PROTOCOLPGM(" E:");
3938
-      SERIAL_PROTOCOL((int)target_extruder);
3956
+      #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
3957
+        print_heaterstates();
3958
+      #endif
3939 3959
       #ifdef TEMP_RESIDENCY_TIME
3940 3960
         SERIAL_PROTOCOLPGM(" W:");
3941 3961
         if (residency_start_ms > -1) {
@@ -3996,13 +4016,10 @@ inline void gcode_M109() {
3996 4016
       if (ms > temp_ms + 1000UL) { //Print Temp Reading every 1 second while heating up.
3997 4017
         temp_ms = ms;
3998 4018
         float tt = degHotend(active_extruder);
3999
-        SERIAL_PROTOCOLPGM("T:");
4000
-        SERIAL_PROTOCOL(tt);
4001
-        SERIAL_PROTOCOLPGM(" E:");
4002
-        SERIAL_PROTOCOL((int)active_extruder);
4003
-        SERIAL_PROTOCOLPGM(" B:");
4004
-        SERIAL_PROTOCOL_F(degBed(), 1);
4005
-        SERIAL_EOL;
4019
+        #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
4020
+          print_heaterstates();
4021
+          SERIAL_EOL;
4022
+        #endif
4006 4023
       }
4007 4024
       idle();
4008 4025
     }
@@ -4915,6 +4932,9 @@ inline void gcode_M303() {
4915 4932
   int e = code_seen('E') ? code_value_short() : 0;
4916 4933
   int c = code_seen('C') ? code_value_short() : 5;
4917 4934
   float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0);
4935
+
4936
+  if (e >=0 && e < EXTRUDERS)
4937
+    target_extruder = e;
4918 4938
   PID_autotune(temp, e, c);
4919 4939
 }
4920 4940
 

+ 4
- 13
Marlin/temperature.cpp 查看文件

@@ -328,19 +328,10 @@ void PID_autotune(float temp, int extruder, int ncycles) {
328 328
     }
329 329
     // Every 2 seconds...
330 330
     if (ms > temp_ms + 2000) {
331
-      int p;
332
-      if (extruder < 0) {
333
-        p = soft_pwm_bed;
334
-        SERIAL_PROTOCOLPGM(MSG_B);
335
-      }
336
-      else {
337
-        p = soft_pwm[extruder];
338
-        SERIAL_PROTOCOLPGM(MSG_T);
339
-      }
340
-
341
-      SERIAL_PROTOCOL(input);
342
-      SERIAL_PROTOCOLPGM(MSG_AT);
343
-      SERIAL_PROTOCOLLN(p);
331
+      #if HAS_TEMP_0 || HAS_TEMP_BED || ENABLED(HEATER_0_USES_MAX6675)
332
+        print_heaterstates();
333
+        SERIAL_EOL;
334
+      #endif
344 335
 
345 336
       temp_ms = ms;
346 337
     } // every 2 seconds

正在加载...
取消
保存