ソースを参照

UBL name/state methods

Scott Lahteine 8年前
コミット
7f4e4b1212
5個のファイルの変更58行の追加57行の削除
  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 ファイルの表示

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

+ 28
- 22
Marlin/configuration_store.cpp ファイルの表示

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

+ 10
- 0
Marlin/ubl.cpp ファイルの表示

41
 
41
 
42
   uint8_t ubl_cnt = 0;
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
   static void serial_echo_xy(const int16_t x, const int16_t y) {
54
   static void serial_echo_xy(const int16_t x, const int16_t y) {
45
     SERIAL_CHAR('(');
55
     SERIAL_CHAR('(');
46
     SERIAL_ECHO(x);
56
     SERIAL_ECHO(x);

+ 2
- 0
Marlin/ubl.h ファイルの表示

103
 
103
 
104
     public:
104
     public:
105
 
105
 
106
+      void echo_name();
107
+      void report_state();
106
       void find_mean_mesh_height();
108
       void find_mean_mesh_height();
107
       void shift_mesh_height();
109
       void shift_mesh_height();
108
       void probe_entire_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map, const bool stow_probe, bool do_furthest);
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 ファイルの表示

906
     return current_position[Z_AXIS];
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
     SERIAL_PROTOCOLLNPGM(" and take a measurement.");
910
     SERIAL_PROTOCOLLNPGM(" and take a measurement.");
911
   }
911
   }
912
 
912
 
922
     SERIAL_PROTOCOLPGM("Place shim under nozzle");
922
     SERIAL_PROTOCOLPGM("Place shim under nozzle");
923
     LCD_MESSAGEPGM("Place shim & measure");
923
     LCD_MESSAGEPGM("Place shim & measure");
924
     lcd_goto_screen(lcd_status_screen);
924
     lcd_goto_screen(lcd_status_screen);
925
-    say_and_take_a_measurement();
925
+    echo_and_take_a_measurement();
926
 
926
 
927
     const float z1 = use_encoder_wheel_to_measure_point();
927
     const float z1 = use_encoder_wheel_to_measure_point();
928
     do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
928
     do_blocking_move_to_z(current_position[Z_AXIS] + SIZE_OF_LITTLE_RAISE);
929
     stepper.synchronize();
929
     stepper.synchronize();
930
 
930
 
931
     SERIAL_PROTOCOLPGM("Remove shim");
931
     SERIAL_PROTOCOLPGM("Remove shim");
932
-    LCD_MESSAGEPGM("Remove & measure bed");
932
+    LCD_MESSAGEPGM("Remove & measure bed"); // TODO: Make translatable string
933
-    say_and_take_a_measurement();
933
+    echo_and_take_a_measurement();
934
 
934
 
935
     const float z2 = use_encoder_wheel_to_measure_point();
935
     const float z2 = use_encoder_wheel_to_measure_point();
936
 
936
 
1031
     do_blocking_move_to_xy(lx, ly);
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
   bool g29_parameter_parsing() {
1034
   bool g29_parameter_parsing() {
1046
     bool err_flag = false;
1035
     bool err_flag = false;
1047
 
1036
 
1110
         SERIAL_PROTOCOLLNPGM("?Can't activate and deactivate at the same time.\n");
1099
         SERIAL_PROTOCOLLNPGM("?Can't activate and deactivate at the same time.\n");
1111
         return UBL_ERR;
1100
         return UBL_ERR;
1112
       }
1101
       }
1113
-      ubl.state.active = 1;
1102
+      ubl.state.active = true;
1114
-      report_ubl_state();
1103
+      ubl.report_state();
1115
     }
1104
     }
1116
     else if (code_seen('D')) {
1105
     else if (code_seen('D')) {
1117
-      ubl.state.active = 0;
1106
+      ubl.state.active = false;
1118
-      report_ubl_state();
1107
+      ubl.report_state();
1119
     }
1108
     }
1120
 
1109
 
1121
     // Set global 'C' flag and its value
1110
     // Set global 'C' flag and its value
1171
    * good to have the extra information. Soon... we prune this to just a few items
1160
    * good to have the extra information. Soon... we prune this to just a few items
1172
    */
1161
    */
1173
   void unified_bed_leveling::g29_what_command() {
1162
   void unified_bed_leveling::g29_what_command() {
1174
-    say_ubl_name();
1163
+    report_state();
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);
1182
 
1164
 
1183
     if (state.storage_slot == -1)
1165
     if (state.storage_slot == -1)
1184
       SERIAL_PROTOCOLPGM("No Mesh Loaded.");
1166
       SERIAL_PROTOCOLPGM("No Mesh Loaded.");
1260
     safe_delay(25);
1242
     safe_delay(25);
1261
 
1243
 
1262
     if (!sanity_check()) {
1244
     if (!sanity_check()) {
1263
-      say_ubl_name();
1245
+      echo_name();
1264
-      SERIAL_PROTOCOLLNPGM("sanity checks passed.");
1246
+      SERIAL_PROTOCOLLNPGM(" sanity checks passed.");
1265
     }
1247
     }
1266
   }
1248
   }
1267
 
1249
 
1319
     float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
1301
     float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
1320
     settings.load_mesh(storage_slot, &tmp_z_values);
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
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
1307
     for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
1325
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
1308
       for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)

読み込み中…
キャンセル
保存