Browse Source

UBL name/state methods

Scott Lahteine 7 years ago
parent
commit
7f4e4b1212
5 changed files with 58 additions and 57 deletions
  1. 5
    5
      Marlin/Marlin_main.cpp
  2. 28
    22
      Marlin/configuration_store.cpp
  3. 10
    0
      Marlin/ubl.cpp
  4. 2
    0
      Marlin/ubl.h
  5. 13
    30
      Marlin/ubl_G29.cpp

+ 5
- 5
Marlin/Marlin_main.cpp View File

@@ -3940,7 +3940,7 @@ void home_all_axes() { gcode_G28(true); }
3940 3940
 #if ENABLED(MESH_BED_LEVELING)
3941 3941
 
3942 3942
   // Save 130 bytes with non-duplication of PSTR
3943
-  void say_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
3943
+  void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
3944 3944
 
3945 3945
   void mbl_mesh_report() {
3946 3946
     SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
@@ -4071,7 +4071,7 @@ void home_all_axes() { gcode_G28(true); }
4071 4071
           }
4072 4072
         }
4073 4073
         else {
4074
-          SERIAL_CHAR('X'); say_not_entered();
4074
+          SERIAL_CHAR('X'); echo_not_entered();
4075 4075
           return;
4076 4076
         }
4077 4077
 
@@ -4083,7 +4083,7 @@ void home_all_axes() { gcode_G28(true); }
4083 4083
           }
4084 4084
         }
4085 4085
         else {
4086
-          SERIAL_CHAR('Y'); say_not_entered();
4086
+          SERIAL_CHAR('Y'); echo_not_entered();
4087 4087
           return;
4088 4088
         }
4089 4089
 
@@ -4091,7 +4091,7 @@ void home_all_axes() { gcode_G28(true); }
4091 4091
           mbl.z_values[px][py] = code_value_linear_units();
4092 4092
         }
4093 4093
         else {
4094
-          SERIAL_CHAR('Z'); say_not_entered();
4094
+          SERIAL_CHAR('Z'); echo_not_entered();
4095 4095
           return;
4096 4096
         }
4097 4097
         break;
@@ -4101,7 +4101,7 @@ void home_all_axes() { gcode_G28(true); }
4101 4101
           mbl.z_offset = code_value_linear_units();
4102 4102
         }
4103 4103
         else {
4104
-          SERIAL_CHAR('Z'); say_not_entered();
4104
+          SERIAL_CHAR('Z'); echo_not_entered();
4105 4105
           return;
4106 4106
         }
4107 4107
         break;

+ 28
- 22
Marlin/configuration_store.cpp View File

@@ -425,7 +425,7 @@ void MarlinSettings::postprocess() {
425 425
       EEPROM_WRITE(ubl.state.z_offset);
426 426
       EEPROM_WRITE(ubl.state.storage_slot);
427 427
     #else
428
-      const bool ubl_active = 0;
428
+      const bool ubl_active = false;
429 429
       dummy = 0.0f;
430 430
       const int8_t storage_slot = -1;
431 431
       EEPROM_WRITE(ubl_active);
@@ -991,18 +991,20 @@ void MarlinSettings::postprocess() {
991 991
       }
992 992
 
993 993
       #if ENABLED(AUTO_BED_LEVELING_UBL)
994
-        meshes_begin = (eeprom_index + 32) & 0xFFF8;   // Pad the end of configuration data so it
995
-                                                          // can float up or down a little bit without
996
-                                                          // disrupting the mesh data
997
-        SERIAL_ECHOPGM(" UBL ");
998
-        if (!ubl.state.active) SERIAL_ECHO("not ");
999
-        SERIAL_ECHOLNPGM("active!");
994
+        meshes_begin = (eeprom_index + 32) & 0xFFF8;  // Pad the end of configuration data so it
995
+                                                      // can float up or down a little bit without
996
+                                                      // disrupting the mesh data
997
+        ubl.report_state();
1000 998
 
1001 999
         if (!ubl.sanity_check()) {
1002
-          SERIAL_ECHOLNPGM("\nUnified Bed Leveling system initialized.\n");
1000
+          SERIAL_EOL;
1001
+          ubl.echo_name();
1002
+          SERIAL_ECHOLNPGM(" initialized.\n");
1003 1003
         }
1004 1004
         else {
1005
-          SERIAL_PROTOCOLPGM("?Unable to enable Unified Bed Leveling system.\n");
1005
+          SERIAL_PROTOCOLPGM("?Can't enable ");
1006
+          ubl.echo_name();
1007
+          SERIAL_PROTOCOLLNPGM(".");
1006 1008
           ubl.reset();
1007 1009
         }
1008 1010
 
@@ -1028,6 +1030,12 @@ void MarlinSettings::postprocess() {
1028 1030
 
1029 1031
   #if ENABLED(AUTO_BED_LEVELING_UBL)
1030 1032
 
1033
+    void ubl_invalid_slot(const int s) {
1034
+      SERIAL_PROTOCOLLNPGM("?Invalid slot.");
1035
+      SERIAL_PROTOCOL(s);
1036
+      SERIAL_PROTOCOLLNPGM(" mesh slots available.");
1037
+    }
1038
+
1031 1039
     int MarlinSettings::calc_num_meshes() {
1032 1040
       //obviously this will get more sophisticated once we've added an actual MAT
1033 1041
 
@@ -1041,12 +1049,10 @@ void MarlinSettings::postprocess() {
1041 1049
       #if ENABLED(AUTO_BED_LEVELING_UBL)
1042 1050
         const int a = calc_num_meshes();
1043 1051
         if (!WITHIN(slot, 0, a - 1)) {
1044
-          SERIAL_PROTOCOLLNPGM("?Invalid slot.");
1045
-          SERIAL_PROTOCOL(a);
1046
-          SERIAL_PROTOCOLLNPGM(" mesh slots available.");
1047
-          SERIAL_PROTOCOLLNPAIR("E2END      : ", E2END);
1048
-          SERIAL_PROTOCOLLNPAIR("meshes_end : ", (int)meshes_end);
1049
-          SERIAL_PROTOCOLLNPAIR("slot       : ", slot);
1052
+          ubl_invalid_slot(a);
1053
+          SERIAL_PROTOCOLPAIR("E2END=", E2END);
1054
+          SERIAL_PROTOCOLPAIR(" meshes_end=", (int)meshes_end);
1055
+          SERIAL_PROTOCOLLNPAIR(" slot=", slot);
1050 1056
           SERIAL_EOL;
1051 1057
           return;
1052 1058
         }
@@ -1074,9 +1080,7 @@ void MarlinSettings::postprocess() {
1074 1080
         const int16_t a = settings.calc_num_meshes();
1075 1081
 
1076 1082
         if (!WITHIN(slot, 0, a - 1)) {
1077
-          SERIAL_PROTOCOLLNPGM("?Invalid Slot.");
1078
-          SERIAL_PROTOCOL(a);
1079
-          SERIAL_PROTOCOLLNPGM(" mesh slots available.");
1083
+          ubl_invalid_slot(a);
1080 1084
           return;
1081 1085
         }
1082 1086
 
@@ -1538,7 +1542,8 @@ void MarlinSettings::reset() {
1538 1542
 
1539 1543
       if (!forReplay) {
1540 1544
         CONFIG_ECHO_START;
1541
-        SERIAL_ECHOLNPGM("Unified Bed Leveling:");
1545
+        ubl.echo_name();
1546
+        SERIAL_ECHOLNPGM(":");
1542 1547
       }
1543 1548
       CONFIG_ECHO_START;
1544 1549
       SERIAL_ECHOPAIR("  M420 S", ubl.state.active ? 1 : 0);
@@ -1548,9 +1553,10 @@ void MarlinSettings::reset() {
1548 1553
       SERIAL_EOL;
1549 1554
 
1550 1555
       if (!forReplay) {
1551
-        SERIAL_ECHOPGM("\nUBL is ");
1552
-        ubl.state.active ? SERIAL_CHAR('A') : SERIAL_ECHOPGM("Ina");
1553
-        SERIAL_ECHOLNPAIR("ctive\n\nActive Mesh Slot: ", ubl.state.storage_slot);
1556
+        SERIAL_EOL;
1557
+        ubl.report_state();
1558
+
1559
+        SERIAL_ECHOLNPAIR("\nActive Mesh Slot: ", ubl.state.storage_slot);
1554 1560
 
1555 1561
         SERIAL_ECHOPGM("z_offset: ");
1556 1562
         SERIAL_ECHO_F(ubl.state.z_offset, 6);

+ 10
- 0
Marlin/ubl.cpp View File

@@ -41,6 +41,16 @@
41 41
 
42 42
   uint8_t ubl_cnt = 0;
43 43
 
44
+  void unified_bed_leveling::echo_name() { SERIAL_PROTOCOLPGM("Unified Bed Leveling"); }
45
+
46
+  void unified_bed_leveling::report_state() {
47
+    echo_name();
48
+    SERIAL_PROTOCOLPGM(" System v" UBL_VERSION " ");
49
+    if (!state.active) SERIAL_PROTOCOLPGM("in");
50
+    SERIAL_PROTOCOLLNPGM("active.");
51
+    safe_delay(50);
52
+  }
53
+
44 54
   static void serial_echo_xy(const int16_t x, const int16_t y) {
45 55
     SERIAL_CHAR('(');
46 56
     SERIAL_ECHO(x);

+ 2
- 0
Marlin/ubl.h View File

@@ -103,6 +103,8 @@
103 103
 
104 104
     public:
105 105
 
106
+      void echo_name();
107
+      void report_state();
106 108
       void find_mean_mesh_height();
107 109
       void shift_mesh_height();
108 110
       void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);

+ 13
- 30
Marlin/ubl_G29.cpp View File

@@ -906,7 +906,7 @@
906 906
     return current_position[Z_AXIS];
907 907
   }
908 908
 
909
-  static void say_and_take_a_measurement() {
909
+  static void echo_and_take_a_measurement() {
910 910
     SERIAL_PROTOCOLLNPGM(" and take a measurement.");
911 911
   }
912 912
 
@@ -922,15 +922,15 @@
922 922
     SERIAL_PROTOCOLPGM("Place shim under nozzle");
923 923
     LCD_MESSAGEPGM("Place shim & measure");
924 924
     lcd_goto_screen(lcd_status_screen);
925
-    say_and_take_a_measurement();
925
+    echo_and_take_a_measurement();
926 926
 
927 927
     const float z1 = use_encoder_wheel_to_measure_point();
928 928
     do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
929 929
     stepper.synchronize();
930 930
 
931 931
     SERIAL_PROTOCOLPGM("Remove shim");
932
-    LCD_MESSAGEPGM("Remove & measure bed");
933
-    say_and_take_a_measurement();
932
+    LCD_MESSAGEPGM("Remove & measure bed"); // TODO: Make translatable string
933
+    echo_and_take_a_measurement();
934 934
 
935 935
     const float z2 = use_encoder_wheel_to_measure_point();
936 936
 
@@ -1031,17 +1031,6 @@
1031 1031
     do_blocking_move_to_xy(lx, ly);
1032 1032
   }
1033 1033
 
1034
-  static void say_ubl_name() {
1035
-    SERIAL_PROTOCOLPGM("Unified Bed Leveling ");
1036
-  }
1037
-
1038
-  static void report_ubl_state() {
1039
-    say_ubl_name();
1040
-    SERIAL_PROTOCOLPGM("System ");
1041
-    if (!ubl.state.active) SERIAL_PROTOCOLPGM("de");
1042
-    SERIAL_PROTOCOLLNPGM("activated.\n");
1043
-  }
1044
-
1045 1034
   bool g29_parameter_parsing() {
1046 1035
     bool err_flag = false;
1047 1036
 
@@ -1110,12 +1099,12 @@
1110 1099
         SERIAL_PROTOCOLLNPGM("?Can't activate and deactivate at the same time.\n");
1111 1100
         return UBL_ERR;
1112 1101
       }
1113
-      ubl.state.active = 1;
1114
-      report_ubl_state();
1102
+      ubl.state.active = true;
1103
+      ubl.report_state();
1115 1104
     }
1116 1105
     else if (code_seen('D')) {
1117
-      ubl.state.active = 0;
1118
-      report_ubl_state();
1106
+      ubl.state.active = false;
1107
+      ubl.report_state();
1119 1108
     }
1120 1109
 
1121 1110
     // Set global 'C' flag and its value
@@ -1171,14 +1160,7 @@
1171 1160
    * good to have the extra information. Soon... we prune this to just a few items
1172 1161
    */
1173 1162
   void unified_bed_leveling::g29_what_command() {
1174
-    say_ubl_name();
1175
-    SERIAL_PROTOCOLPGM("System Version " UBL_VERSION " ");
1176
-    if (state.active)
1177
-      SERIAL_PROTOCOLCHAR('A');
1178
-    else
1179
-      SERIAL_PROTOCOLPGM("Ina");
1180
-    SERIAL_PROTOCOLLNPGM("ctive.\n");
1181
-    safe_delay(50);
1163
+    report_state();
1182 1164
 
1183 1165
     if (state.storage_slot == -1)
1184 1166
       SERIAL_PROTOCOLPGM("No Mesh Loaded.");
@@ -1260,8 +1242,8 @@
1260 1242
     safe_delay(25);
1261 1243
 
1262 1244
     if (!sanity_check()) {
1263
-      say_ubl_name();
1264
-      SERIAL_PROTOCOLLNPGM("sanity checks passed.");
1245
+      echo_name();
1246
+      SERIAL_PROTOCOLLNPGM(" sanity checks passed.");
1265 1247
     }
1266 1248
   }
1267 1249
 
@@ -1319,7 +1301,8 @@
1319 1301
     float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
1320 1302
     settings.load_mesh(storage_slot, &tmp_z_values);
1321 1303
 
1322
-    SERIAL_ECHOPAIR("Subtracting current mesh from mesh loaded from slot ", storage_slot);
1304
+    SERIAL_PROTOCOLPAIR("Subtracting mesh in slot ", storage_slot);
1305
+    SERIAL_PROTOCOLLNPGM(" from current mesh.");
1323 1306
 
1324 1307
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
1325 1308
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)

Loading…
Cancel
Save