Subversion Repositories Tronxy-X3A-Marlin

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ron 1
/**
2
 * Marlin 3D Printer Firmware
3
 * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
 *
5
 * Based on Sprinter and grbl.
6
 * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
 
23
#include "MarlinConfig.h"
24
 
25
#if ENABLED(MESH_BED_LEVELING)
26
 
27
  #include "mesh_bed_leveling.h"
28
  #include "Marlin.h"
29
  #include "serial.h"
30
 
31
  mesh_bed_leveling mbl;
32
 
33
  float mesh_bed_leveling::z_offset,
34
        mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y],
35
        mesh_bed_leveling::index_to_xpos[GRID_MAX_POINTS_X],
36
        mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y];
37
 
38
  mesh_bed_leveling::mesh_bed_leveling() {
39
    for (uint8_t i = 0; i < GRID_MAX_POINTS_X; ++i)
40
      index_to_xpos[i] = MESH_MIN_X + i * (MESH_X_DIST);
41
    for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; ++i)
42
      index_to_ypos[i] = MESH_MIN_Y + i * (MESH_Y_DIST);
43
    reset();
44
  }
45
 
46
  void mesh_bed_leveling::reset() {
47
    z_offset = 0;
48
    ZERO(z_values);
49
  }
50
 
51
  void mesh_bed_leveling::report_mesh() {
52
    SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(GRID_MAX_POINTS_X) "," STRINGIFY(GRID_MAX_POINTS_Y));
53
    SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(z_offset, 5);
54
    SERIAL_PROTOCOLLNPGM("\nMeasured points:");
55
    print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5,
56
      [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; }
57
    );
58
  }
59
 
60
#endif // MESH_BED_LEVELING