Permalink
Browse files

M114 returns millimeters instead of steps

  • Loading branch information...
triffid committed Apr 26, 2011
1 parent ee48186 commit e108ab2548769d9de1aa3690bb5b91b3eb996cde
Showing with 54 additions and 1 deletion.
  1. +10 −0 dda.h
  2. +1 −1 gcode_process.c
  3. +36 −0 sermsg.c
  4. +3 −0 sermsg.h
  5. +4 −0 sersendf.c
View
10 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.
View
@@ -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
View
@@ -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);
+}
View
@@ -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 */
View
@@ -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;

0 comments on commit e108ab2

Please sign in to comment.