Browse Source

Move leveling_is_active to a macro

Scott Lahteine 7 years ago
parent
commit
da93a272a0
6 changed files with 30 additions and 33 deletions
  1. 0
    1
      Marlin/Marlin.h
  2. 11
    23
      Marlin/Marlin_main.cpp
  3. 2
    2
      Marlin/configuration_store.cpp
  4. 10
    0
      Marlin/planner.h
  5. 6
    6
      Marlin/ultralcd.cpp
  6. 1
    1
      Marlin/ultralcd_impl_HD44780.h

+ 0
- 1
Marlin/Marlin.h View File

@@ -323,7 +323,6 @@ extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
323 323
 
324 324
 #if HAS_LEVELING
325 325
   bool leveling_is_valid();
326
-  bool leveling_is_active();
327 326
   void set_bed_leveling_enabled(const bool enable=true);
328 327
   void reset_bed_level();
329 328
 #endif

+ 11
- 23
Marlin/Marlin_main.cpp View File

@@ -2471,18 +2471,6 @@ static void clean_up_after_endstop_or_probe_move() {
2471 2471
     ;
2472 2472
   }
2473 2473
 
2474
-  bool leveling_is_active() {
2475
-    return
2476
-      #if ENABLED(MESH_BED_LEVELING)
2477
-        mbl.active()
2478
-      #elif ENABLED(AUTO_BED_LEVELING_UBL)
2479
-        ubl.state.active
2480
-      #else
2481
-        planner.abl_enabled
2482
-      #endif
2483
-    ;
2484
-  }
2485
-
2486 2474
   /**
2487 2475
    * Turn bed leveling on or off, fixing the current
2488 2476
    * position as-needed.
@@ -2498,7 +2486,7 @@ static void clean_up_after_endstop_or_probe_move() {
2498 2486
       constexpr bool can_change = true;
2499 2487
     #endif
2500 2488
 
2501
-    if (can_change && enable != leveling_is_active()) {
2489
+    if (can_change && enable != LEVELING_IS_ACTIVE()) {
2502 2490
 
2503 2491
       #if ENABLED(MESH_BED_LEVELING)
2504 2492
 
@@ -2559,7 +2547,7 @@ static void clean_up_after_endstop_or_probe_move() {
2559 2547
 
2560 2548
     void set_z_fade_height(const float zfh) {
2561 2549
 
2562
-      const bool level_active = leveling_is_active();
2550
+      const bool level_active = LEVELING_IS_ACTIVE();
2563 2551
 
2564 2552
       #if ENABLED(AUTO_BED_LEVELING_UBL)
2565 2553
 
@@ -3771,7 +3759,7 @@ inline void gcode_G4() {
3771 3759
       #elif ENABLED(AUTO_BED_LEVELING_UBL)
3772 3760
         SERIAL_ECHOPGM("UBL");
3773 3761
       #endif
3774
-      if (leveling_is_active()) {
3762
+      if (LEVELING_IS_ACTIVE()) {
3775 3763
         SERIAL_ECHOLNPGM(" (enabled)");
3776 3764
         #if ABL_PLANAR
3777 3765
           const float diff[XYZ] = {
@@ -3802,7 +3790,7 @@ inline void gcode_G4() {
3802 3790
     #elif ENABLED(MESH_BED_LEVELING)
3803 3791
 
3804 3792
       SERIAL_ECHOPGM("Mesh Bed Leveling");
3805
-      if (leveling_is_active()) {
3793
+      if (LEVELING_IS_ACTIVE()) {
3806 3794
         float lz = current_position[Z_AXIS];
3807 3795
         planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz);
3808 3796
         SERIAL_ECHOLNPGM(" (enabled)");
@@ -3971,7 +3959,7 @@ inline void gcode_G28(const bool always_home_all) {
3971 3959
   // Disable the leveling matrix before homing
3972 3960
   #if HAS_LEVELING
3973 3961
     #if ENABLED(AUTO_BED_LEVELING_UBL)
3974
-      const bool ubl_state_at_entry = leveling_is_active();
3962
+      const bool ubl_state_at_entry = LEVELING_IS_ACTIVE();
3975 3963
     #endif
3976 3964
     set_bed_leveling_enabled(false);
3977 3965
   #endif
@@ -4261,7 +4249,7 @@ void home_all_axes() { gcode_G28(true); }
4261 4249
     switch (state) {
4262 4250
       case MeshReport:
4263 4251
         if (leveling_is_valid()) {
4264
-          SERIAL_PROTOCOLLNPAIR("State: ", leveling_is_active() ? MSG_ON : MSG_OFF);
4252
+          SERIAL_PROTOCOLLNPAIR("State: ", LEVELING_IS_ACTIVE() ? MSG_ON : MSG_OFF);
4265 4253
           mbl_mesh_report();
4266 4254
         }
4267 4255
         else
@@ -4580,7 +4568,7 @@ void home_all_axes() { gcode_G28(true); }
4580 4568
         abl_probe_index = -1;
4581 4569
       #endif
4582 4570
 
4583
-      abl_should_enable = leveling_is_active();
4571
+      abl_should_enable = LEVELING_IS_ACTIVE();
4584 4572
 
4585 4573
       #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4586 4574
 
@@ -7077,7 +7065,7 @@ inline void gcode_M42() {
7077 7065
     // Disable bed level correction in M48 because we want the raw data when we probe
7078 7066
 
7079 7067
     #if HAS_LEVELING
7080
-      const bool was_enabled = leveling_is_active();
7068
+      const bool was_enabled = LEVELING_IS_ACTIVE();
7081 7069
       set_bed_leveling_enabled(false);
7082 7070
     #endif
7083 7071
 
@@ -9413,7 +9401,7 @@ void quickstop_stepper() {
9413 9401
       if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
9414 9402
     #endif
9415 9403
 
9416
-    const bool new_status = leveling_is_active();
9404
+    const bool new_status = LEVELING_IS_ACTIVE();
9417 9405
 
9418 9406
     if (to_enable && !new_status) {
9419 9407
       SERIAL_ERROR_START();
@@ -9644,7 +9632,7 @@ inline void gcode_M502() {
9644 9632
       #endif
9645 9633
 
9646 9634
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
9647
-        if (!no_babystep && leveling_is_active())
9635
+        if (!no_babystep && LEVELING_IS_ACTIVE())
9648 9636
           thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
9649 9637
       #else
9650 9638
         UNUSED(no_babystep);
@@ -10691,7 +10679,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
10691 10679
 
10692 10680
             #if ENABLED(MESH_BED_LEVELING)
10693 10681
 
10694
-              if (leveling_is_active()) {
10682
+              if (LEVELING_IS_ACTIVE()) {
10695 10683
                 #if ENABLED(DEBUG_LEVELING_FEATURE)
10696 10684
                   if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before MBL: ", current_position[Z_AXIS]);
10697 10685
                 #endif

+ 2
- 2
Marlin/configuration_store.cpp View File

@@ -1594,7 +1594,7 @@ void MarlinSettings::reset() {
1594 1594
         SERIAL_ECHOLNPGM(":");
1595 1595
       }
1596 1596
       CONFIG_ECHO_START;
1597
-      SERIAL_ECHOPAIR("  M420 S", leveling_is_active() ? 1 : 0);
1597
+      SERIAL_ECHOPAIR("  M420 S", LEVELING_IS_ACTIVE() ? 1 : 0);
1598 1598
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1599 1599
         SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
1600 1600
       #endif
@@ -1615,7 +1615,7 @@ void MarlinSettings::reset() {
1615 1615
         SERIAL_ECHOLNPGM("Auto Bed Leveling:");
1616 1616
       }
1617 1617
       CONFIG_ECHO_START;
1618
-      SERIAL_ECHOPAIR("  M420 S", leveling_is_active() ? 1 : 0);
1618
+      SERIAL_ECHOPAIR("  M420 S", LEVELING_IS_ACTIVE() ? 1 : 0);
1619 1619
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1620 1620
         SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
1621 1621
       #endif

+ 10
- 0
Marlin/planner.h View File

@@ -468,6 +468,16 @@ class Planner {
468 468
 
469 469
 #define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
470 470
 
471
+#if ENABLED(MESH_BED_LEVELING)
472
+  #define LEVELING_IS_ACTIVE() (mesh_bed_leveling::active())
473
+#elif ENABLED(AUTO_BED_LEVELING_UBL)
474
+  #define LEVELING_IS_ACTIVE() (unified_bed_leveling::state.active)
475
+#elif HAS_ABL
476
+  #define LEVELING_IS_ACTIVE() (Planner::abl_enabled)
477
+#else
478
+  #define LEVELING_IS_ACTIVE() (false)
479
+#endif
480
+
471 481
 extern Planner planner;
472 482
 
473 483
 #endif // PLANNER_H

+ 6
- 6
Marlin/ultralcd.cpp View File

@@ -50,6 +50,11 @@
50 50
 #if ENABLED(AUTO_BED_LEVELING_UBL)
51 51
   #include "ubl.h"
52 52
   bool ubl_lcd_map_control = false;
53
+#elif HAS_ABL
54
+  #include "planner.h"
55
+#elif ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
56
+  #include "mesh_bed_leveling.h"
57
+  extern void mesh_probing_done();
53 58
 #endif
54 59
 
55 60
 // Initialized by settings.load()
@@ -194,11 +199,6 @@ uint16_t max_display_update_time = 0;
194 199
     void lcd_delta_calibrate_menu();
195 200
   #endif
196 201
 
197
-  #if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
198
-    #include "mesh_bed_leveling.h"
199
-    extern void mesh_probing_done();
200
-  #endif
201
-
202 202
   ////////////////////////////////////////////
203 203
   //////////// Menu System Actions ///////////
204 204
   ////////////////////////////////////////////
@@ -1937,7 +1937,7 @@ void kill_screen(const char* lcd_msg) {
1937 1937
       if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
1938 1938
         MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
1939 1939
       else if (leveling_is_valid()) {
1940
-        _level_state = leveling_is_active();
1940
+        _level_state = LEVELING_IS_ACTIVE();
1941 1941
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &_level_state, _lcd_toggle_bed_leveling);
1942 1942
       }
1943 1943
 

+ 1
- 1
Marlin/ultralcd_impl_HD44780.h View File

@@ -792,7 +792,7 @@ static void lcd_implementation_status_screen() {
792 792
     lcd.print(ftostr52sp(FIXFLOAT(current_position[Z_AXIS])));
793 793
 
794 794
     #if HAS_LEVELING
795
-      lcd.write(leveling_is_active() || blink ? '_' : ' ');
795
+      lcd.write(LEVELING_IS_ACTIVE() || blink ? '_' : ' ');
796 796
     #endif
797 797
 
798 798
   #endif // LCD_HEIGHT > 2

Loading…
Cancel
Save