M114 returns millimeters instead of steps

This commit is contained in:
Michael Moon 2011-04-26 14:44:17 +10:00
parent ee481864fa
commit e108ab2548
5 changed files with 54 additions and 1 deletions

10
dda.h
View File

@ -5,6 +5,16 @@
#include "config.h" #include "config.h"
// Used in distance calculation during DDA setup
/// micrometers per step X
#define UM_PER_STEP_X 1000L / ((uint32_t) STEPS_PER_MM_X)
/// micrometers per step Y
#define UM_PER_STEP_Y 1000L / ((uint32_t) STEPS_PER_MM_Y)
/// micrometers per step Z
#define UM_PER_STEP_Z 1000L / ((uint32_t) STEPS_PER_MM_Z)
/// micrometers per step E
#define UM_PER_STEP_E 1000L / ((uint32_t) STEPS_PER_MM_E)
#ifdef ACCELERATION_REPRAP #ifdef ACCELERATION_REPRAP
#ifdef ACCELERATION_RAMPING #ifdef ACCELERATION_RAMPING
#error Cant use ACCELERATION_REPRAP and ACCELERATION_RAMPING together. #error Cant use ACCELERATION_REPRAP and ACCELERATION_RAMPING together.

View File

@ -392,7 +392,7 @@ void process_gcode_command() {
// M113- extruder PWM // M113- extruder PWM
// M114- report XYZEF to host // M114- report XYZEF to host
case 114: case 114:
sersendf_P(PSTR("X:%ld,Y:%ld,Z:%ld,E:%ld,F:%ld"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F); sersendf_P(PSTR("X:%lq,Y:%lq,Z:%lq,E:%lq,F:%ld"), current_position.X * UM_PER_STEP_X, current_position.Y * UM_PER_STEP_Y, current_position.Z * UM_PER_STEP_Z, current_position.E * UM_PER_STEP_E, current_position.F);
// newline is sent from gcode_parse after we return // newline is sent from gcode_parse after we return
break; break;
// M115- capabilities string // M115- capabilities string

View File

@ -74,3 +74,39 @@ void serwrite_int32(int32_t v) {
serwrite_uint32(v); serwrite_uint32(v);
} }
/** write decimal digits from a long unsigned int
\param v number to send
*/
void serwrite_uint32_vf(uint32_t v, uint8_t fp) {
uint8_t e, t;
for (e = 9; e > 0; e--) {
if (v >= powers[e])
break;
}
if (e < fp)
e = fp;
do
{
for (t = 0; v >= powers[e]; v -= powers[e], t++);
serial_writechar(t + '0');
if (e == fp)
serial_writechar('.');
}
while (e--);
}
/** write decimal digits from a long signed int
\param v number to send
*/
void serwrite_int32_vf(int32_t v, uint8_t fp) {
if (v < 0) {
serial_writechar('-');
v = -v;
}
serwrite_uint32_vf(v, fp);
}

View File

@ -18,4 +18,7 @@ void serwrite_hex32(uint32_t v);
void serwrite_uint32(uint32_t v); void serwrite_uint32(uint32_t v);
void serwrite_int32(int32_t v); void serwrite_int32(int32_t v);
void serwrite_uint32_vf(uint32_t v, uint8_t fp);
void serwrite_int32_vf(int32_t v, uint8_t fp);
#endif /* _SERMSG_H */ #endif /* _SERMSG_H */

View File

@ -141,6 +141,10 @@ void sersendf_P(PGM_P format, ...) {
break; break;
/* case 'p': /* case 'p':
serwrite_hex16(va_arg(args, uint16_t));*/ serwrite_hex16(va_arg(args, uint16_t));*/
case 'q':
serwrite_int32_vf(va_arg(args, int32_t), 3);
j = 0;
break;
default: default:
serial_writechar(c); serial_writechar(c);
j = 0; j = 0;