2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-17 07:36:30 +02:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
#include "../../module/stepper.h"
|
|
|
|
|
2017-11-14 07:03:17 +01:00
|
|
|
#if ENABLED(M114_DETAIL)
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-01-24 02:06:54 +01:00
|
|
|
#if HAS_DRIVER(L6470)
|
|
|
|
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp
|
|
|
|
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp
|
|
|
|
#include "../../module/L6470/L6470_Marlin.h"
|
2019-03-14 08:25:42 +01:00
|
|
|
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
|
|
|
|
#include "../../core/debug_out.h"
|
2019-01-24 02:06:54 +01:00
|
|
|
#endif
|
|
|
|
|
2017-12-09 09:10:54 +01:00
|
|
|
void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) {
|
2017-09-06 13:28:31 +02:00
|
|
|
char str[12];
|
|
|
|
for (uint8_t i = 0; i < n; i++) {
|
|
|
|
SERIAL_CHAR(' ');
|
|
|
|
SERIAL_CHAR(axis_codes[i]);
|
|
|
|
SERIAL_CHAR(':');
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHO(dtostrf(pos[i], 8, precision, str));
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
|
2017-12-09 09:10:54 +01:00
|
|
|
inline void report_xyz(const float pos[]) { report_xyze(pos, 3); }
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
void report_current_position_detail() {
|
|
|
|
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("\nLogical:");
|
2017-11-03 05:59:42 +01:00
|
|
|
const float logical[XYZ] = {
|
|
|
|
LOGICAL_X_POSITION(current_position[X_AXIS]),
|
|
|
|
LOGICAL_Y_POSITION(current_position[Y_AXIS]),
|
|
|
|
LOGICAL_Z_POSITION(current_position[Z_AXIS])
|
|
|
|
};
|
2018-01-24 01:50:37 +01:00
|
|
|
report_xyz(logical);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("Raw: ");
|
2017-11-03 05:59:42 +01:00
|
|
|
report_xyz(current_position);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-11-14 09:13:38 +01:00
|
|
|
float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
|
|
|
|
|
2018-09-17 04:24:15 +02:00
|
|
|
#if HAS_LEVELING
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("Leveled:");
|
2017-11-13 06:03:38 +01:00
|
|
|
planner.apply_leveling(leveled);
|
|
|
|
report_xyz(leveled);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("UnLevel:");
|
2017-11-13 06:03:38 +01:00
|
|
|
float unleveled[XYZ] = { leveled[X_AXIS], leveled[Y_AXIS], leveled[Z_AXIS] };
|
|
|
|
planner.unapply_leveling(unleveled);
|
|
|
|
report_xyz(unleveled);
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
#if IS_SCARA
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("ScaraK: ");
|
2017-09-06 13:28:31 +02:00
|
|
|
#else
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("DeltaK: ");
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
inverse_kinematics(leveled); // writes delta[]
|
|
|
|
report_xyz(delta);
|
|
|
|
#endif
|
|
|
|
|
2018-05-12 08:38:02 +02:00
|
|
|
planner.synchronize();
|
2018-05-04 03:51:10 +02:00
|
|
|
|
2019-01-24 02:06:54 +01:00
|
|
|
#if HAS_DRIVER(L6470)
|
|
|
|
char temp_buf[80];
|
|
|
|
int32_t temp;
|
|
|
|
//#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000
|
|
|
|
#define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000
|
|
|
|
#define REPORT_ABSOLUTE_POS(Q) do{ \
|
|
|
|
L6470.say_axis(Q, false); \
|
|
|
|
temp = L6470_GETPARAM(L6470_ABS_POS,Q); \
|
|
|
|
if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \
|
|
|
|
sprintf_P(temp_buf, PSTR(":%8ld "), temp); \
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_ECHO(temp_buf); \
|
2019-01-24 02:06:54 +01:00
|
|
|
}while(0)
|
|
|
|
|
2019-03-14 08:25:42 +01:00
|
|
|
DEBUG_ECHOPGM("\nL6470:");
|
2019-01-24 02:06:54 +01:00
|
|
|
#if AXIS_DRIVER_TYPE_X(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(X);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_X2(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(X2);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_Y(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(Y);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_Y2(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(Y2);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_Z(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(Z);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_Z2(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(Z2);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_Z3(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(Z3);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_E0(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(E0);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_E1(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(E1);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_E2(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(E2);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_E3(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(E3);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_E4(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(E4);
|
|
|
|
#endif
|
|
|
|
#if AXIS_DRIVER_TYPE_E5(L6470)
|
|
|
|
REPORT_ABSOLUTE_POS(E5);
|
|
|
|
#endif
|
|
|
|
SERIAL_EOL();
|
|
|
|
#endif // HAS_DRIVER(L6470)
|
|
|
|
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("Stepper:");
|
2017-12-11 02:12:00 +01:00
|
|
|
LOOP_XYZE(i) {
|
|
|
|
SERIAL_CHAR(' ');
|
|
|
|
SERIAL_CHAR(axis_codes[i]);
|
|
|
|
SERIAL_CHAR(':');
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHO(stepper.position((AxisEnum)i));
|
2017-12-11 02:12:00 +01:00
|
|
|
}
|
|
|
|
SERIAL_EOL();
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if IS_SCARA
|
|
|
|
const float deg[XYZ] = {
|
2018-05-12 16:59:11 +02:00
|
|
|
planner.get_axis_position_degrees(A_AXIS),
|
|
|
|
planner.get_axis_position_degrees(B_AXIS)
|
2017-09-06 13:28:31 +02:00
|
|
|
};
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("Degrees:");
|
2017-09-06 13:28:31 +02:00
|
|
|
report_xyze(deg, 2);
|
|
|
|
#endif
|
|
|
|
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("FromStp:");
|
2017-09-06 13:28:31 +02:00
|
|
|
get_cartesian_from_steppers(); // writes cartes[XYZ] (with forward kinematics)
|
2018-05-12 16:59:11 +02:00
|
|
|
const float from_steppers[XYZE] = { cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS], planner.get_axis_position_mm(E_AXIS) };
|
2017-09-06 13:28:31 +02:00
|
|
|
report_xyze(from_steppers);
|
|
|
|
|
|
|
|
const float diff[XYZE] = {
|
|
|
|
from_steppers[X_AXIS] - leveled[X_AXIS],
|
|
|
|
from_steppers[Y_AXIS] - leveled[Y_AXIS],
|
|
|
|
from_steppers[Z_AXIS] - leveled[Z_AXIS],
|
|
|
|
from_steppers[E_AXIS] - current_position[E_AXIS]
|
|
|
|
};
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("Differ: ");
|
2017-09-06 13:28:31 +02:00
|
|
|
report_xyze(diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // M114_DETAIL
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M114: Report current position to host
|
|
|
|
*/
|
2017-09-17 07:36:30 +02:00
|
|
|
void GcodeSuite::M114() {
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-11-14 07:03:17 +01:00
|
|
|
#if ENABLED(M114_DETAIL)
|
2017-09-06 13:28:31 +02:00
|
|
|
if (parser.seen('D')) {
|
|
|
|
report_current_position_detail();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-05-12 08:38:02 +02:00
|
|
|
planner.synchronize();
|
2017-09-06 13:28:31 +02:00
|
|
|
report_current_position();
|
|
|
|
}
|