Selaa lähdekoodia

Move leveling_is_active to a macro

Scott Lahteine 7 vuotta sitten
vanhempi
commit
da93a272a0

+ 0
- 1
Marlin/Marlin.h Näytä tiedosto

323
 
323
 
324
 #if HAS_LEVELING
324
 #if HAS_LEVELING
325
   bool leveling_is_valid();
325
   bool leveling_is_valid();
326
-  bool leveling_is_active();
327
   void set_bed_leveling_enabled(const bool enable=true);
326
   void set_bed_leveling_enabled(const bool enable=true);
328
   void reset_bed_level();
327
   void reset_bed_level();
329
 #endif
328
 #endif

+ 11
- 23
Marlin/Marlin_main.cpp Näytä tiedosto

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
    * Turn bed leveling on or off, fixing the current
2475
    * Turn bed leveling on or off, fixing the current
2488
    * position as-needed.
2476
    * position as-needed.
2498
       constexpr bool can_change = true;
2486
       constexpr bool can_change = true;
2499
     #endif
2487
     #endif
2500
 
2488
 
2501
-    if (can_change && enable != leveling_is_active()) {
2489
+    if (can_change && enable != LEVELING_IS_ACTIVE()) {
2502
 
2490
 
2503
       #if ENABLED(MESH_BED_LEVELING)
2491
       #if ENABLED(MESH_BED_LEVELING)
2504
 
2492
 
2559
 
2547
 
2560
     void set_z_fade_height(const float zfh) {
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
       #if ENABLED(AUTO_BED_LEVELING_UBL)
2552
       #if ENABLED(AUTO_BED_LEVELING_UBL)
2565
 
2553
 
3771
       #elif ENABLED(AUTO_BED_LEVELING_UBL)
3759
       #elif ENABLED(AUTO_BED_LEVELING_UBL)
3772
         SERIAL_ECHOPGM("UBL");
3760
         SERIAL_ECHOPGM("UBL");
3773
       #endif
3761
       #endif
3774
-      if (leveling_is_active()) {
3762
+      if (LEVELING_IS_ACTIVE()) {
3775
         SERIAL_ECHOLNPGM(" (enabled)");
3763
         SERIAL_ECHOLNPGM(" (enabled)");
3776
         #if ABL_PLANAR
3764
         #if ABL_PLANAR
3777
           const float diff[XYZ] = {
3765
           const float diff[XYZ] = {
3802
     #elif ENABLED(MESH_BED_LEVELING)
3790
     #elif ENABLED(MESH_BED_LEVELING)
3803
 
3791
 
3804
       SERIAL_ECHOPGM("Mesh Bed Leveling");
3792
       SERIAL_ECHOPGM("Mesh Bed Leveling");
3805
-      if (leveling_is_active()) {
3793
+      if (LEVELING_IS_ACTIVE()) {
3806
         float lz = current_position[Z_AXIS];
3794
         float lz = current_position[Z_AXIS];
3807
         planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz);
3795
         planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz);
3808
         SERIAL_ECHOLNPGM(" (enabled)");
3796
         SERIAL_ECHOLNPGM(" (enabled)");
3971
   // Disable the leveling matrix before homing
3959
   // Disable the leveling matrix before homing
3972
   #if HAS_LEVELING
3960
   #if HAS_LEVELING
3973
     #if ENABLED(AUTO_BED_LEVELING_UBL)
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
     #endif
3963
     #endif
3976
     set_bed_leveling_enabled(false);
3964
     set_bed_leveling_enabled(false);
3977
   #endif
3965
   #endif
4261
     switch (state) {
4249
     switch (state) {
4262
       case MeshReport:
4250
       case MeshReport:
4263
         if (leveling_is_valid()) {
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
           mbl_mesh_report();
4253
           mbl_mesh_report();
4266
         }
4254
         }
4267
         else
4255
         else
4580
         abl_probe_index = -1;
4568
         abl_probe_index = -1;
4581
       #endif
4569
       #endif
4582
 
4570
 
4583
-      abl_should_enable = leveling_is_active();
4571
+      abl_should_enable = LEVELING_IS_ACTIVE();
4584
 
4572
 
4585
       #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4573
       #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
4586
 
4574
 
7077
     // Disable bed level correction in M48 because we want the raw data when we probe
7065
     // Disable bed level correction in M48 because we want the raw data when we probe
7078
 
7066
 
7079
     #if HAS_LEVELING
7067
     #if HAS_LEVELING
7080
-      const bool was_enabled = leveling_is_active();
7068
+      const bool was_enabled = LEVELING_IS_ACTIVE();
7081
       set_bed_leveling_enabled(false);
7069
       set_bed_leveling_enabled(false);
7082
     #endif
7070
     #endif
7083
 
7071
 
9413
       if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
9401
       if (parser.seen('Z')) set_z_fade_height(parser.value_linear_units());
9414
     #endif
9402
     #endif
9415
 
9403
 
9416
-    const bool new_status = leveling_is_active();
9404
+    const bool new_status = LEVELING_IS_ACTIVE();
9417
 
9405
 
9418
     if (to_enable && !new_status) {
9406
     if (to_enable && !new_status) {
9419
       SERIAL_ERROR_START();
9407
       SERIAL_ERROR_START();
9644
       #endif
9632
       #endif
9645
 
9633
 
9646
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
9634
       #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
9647
-        if (!no_babystep && leveling_is_active())
9635
+        if (!no_babystep && LEVELING_IS_ACTIVE())
9648
           thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
9636
           thermalManager.babystep_axis(Z_AXIS, -LROUND(diff * planner.axis_steps_per_mm[Z_AXIS]));
9649
       #else
9637
       #else
9650
         UNUSED(no_babystep);
9638
         UNUSED(no_babystep);
10691
 
10679
 
10692
             #if ENABLED(MESH_BED_LEVELING)
10680
             #if ENABLED(MESH_BED_LEVELING)
10693
 
10681
 
10694
-              if (leveling_is_active()) {
10682
+              if (LEVELING_IS_ACTIVE()) {
10695
                 #if ENABLED(DEBUG_LEVELING_FEATURE)
10683
                 #if ENABLED(DEBUG_LEVELING_FEATURE)
10696
                   if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before MBL: ", current_position[Z_AXIS]);
10684
                   if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before MBL: ", current_position[Z_AXIS]);
10697
                 #endif
10685
                 #endif

+ 2
- 2
Marlin/configuration_store.cpp Näytä tiedosto

1594
         SERIAL_ECHOLNPGM(":");
1594
         SERIAL_ECHOLNPGM(":");
1595
       }
1595
       }
1596
       CONFIG_ECHO_START;
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
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1598
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1599
         SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
1599
         SERIAL_ECHOPAIR(" Z", planner.z_fade_height);
1600
       #endif
1600
       #endif
1615
         SERIAL_ECHOLNPGM("Auto Bed Leveling:");
1615
         SERIAL_ECHOLNPGM("Auto Bed Leveling:");
1616
       }
1616
       }
1617
       CONFIG_ECHO_START;
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
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1619
       #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
1620
         SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
1620
         SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.z_fade_height));
1621
       #endif
1621
       #endif

+ 10
- 0
Marlin/planner.h Näytä tiedosto

468
 
468
 
469
 #define PLANNER_XY_FEEDRATE() (min(planner.max_feedrate_mm_s[X_AXIS], planner.max_feedrate_mm_s[Y_AXIS]))
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
 extern Planner planner;
481
 extern Planner planner;
472
 
482
 
473
 #endif // PLANNER_H
483
 #endif // PLANNER_H

+ 6
- 6
Marlin/ultralcd.cpp Näytä tiedosto

50
 #if ENABLED(AUTO_BED_LEVELING_UBL)
50
 #if ENABLED(AUTO_BED_LEVELING_UBL)
51
   #include "ubl.h"
51
   #include "ubl.h"
52
   bool ubl_lcd_map_control = false;
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
 #endif
58
 #endif
54
 
59
 
55
 // Initialized by settings.load()
60
 // Initialized by settings.load()
194
     void lcd_delta_calibrate_menu();
199
     void lcd_delta_calibrate_menu();
195
   #endif
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
   //////////// Menu System Actions ///////////
203
   //////////// Menu System Actions ///////////
204
   ////////////////////////////////////////////
204
   ////////////////////////////////////////////
1937
       if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
1937
       if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
1938
         MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
1938
         MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
1939
       else if (leveling_is_valid()) {
1939
       else if (leveling_is_valid()) {
1940
-        _level_state = leveling_is_active();
1940
+        _level_state = LEVELING_IS_ACTIVE();
1941
         MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &_level_state, _lcd_toggle_bed_leveling);
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 Näytä tiedosto

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

Loading…
Peruuta
Tallenna