diff --git a/dda.h b/dda.h index 0bbc0ca..067d6bb 100644 --- a/dda.h +++ b/dda.h @@ -5,6 +5,16 @@ #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_RAMPING #error Cant use ACCELERATION_REPRAP and ACCELERATION_RAMPING together. diff --git a/gcode_process.c b/gcode_process.c index 2181af9..f746271 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -392,7 +392,7 @@ void process_gcode_command() { // M113- extruder PWM // M114- report XYZEF to host 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 break; // M115- capabilities string diff --git a/sermsg.c b/sermsg.c index 429c144..f9d1bcd 100644 --- a/sermsg.c +++ b/sermsg.c @@ -74,3 +74,39 @@ void serwrite_int32(int32_t 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); +} diff --git a/sermsg.h b/sermsg.h index 5566f66..d2ad543 100644 --- a/sermsg.h +++ b/sermsg.h @@ -18,4 +18,7 @@ void serwrite_hex32(uint32_t v); void serwrite_uint32(uint32_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 */ \ No newline at end of file diff --git a/sersendf.c b/sersendf.c index f6dca87..f410f93 100644 --- a/sersendf.c +++ b/sersendf.c @@ -141,6 +141,10 @@ void sersendf_P(PGM_P format, ...) { break; /* case 'p': serwrite_hex16(va_arg(args, uint16_t));*/ + case 'q': + serwrite_int32_vf(va_arg(args, int32_t), 3); + j = 0; + break; default: serial_writechar(c); j = 0;