Browse Source

Macros to print floats, hiding imprecision

Scott Lahteine 7 years ago
parent
commit
60be3d264b
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      Marlin/serial.h

+ 6
- 0
Marlin/serial.h View File

@@ -65,6 +65,12 @@ extern const char errormagic[] PROGMEM;
65 65
 #define SERIAL_ERRORLN(x)              SERIAL_PROTOCOLLN(x)
66 66
 #define SERIAL_ERRORLNPGM(x)           SERIAL_PROTOCOLLNPGM(x)
67 67
 
68
+// These macros compensate for float imprecision
69
+#define SERIAL_PROTOCOLPAIR_F(name, value)    SERIAL_PROTOCOLPAIR(name, FIXFLOAT(value))
70
+#define SERIAL_PROTOCOLLNPAIR_F(name, value)  SERIAL_PROTOCOLLNPAIR(name, FIXFLOAT(value))
71
+#define SERIAL_ECHOPAIR_F(name,value)         SERIAL_ECHOPAIR(name, FIXFLOAT(value))
72
+#define SERIAL_ECHOLNPAIR_F(name, value)      SERIAL_ECHOLNPAIR(name, FIXFLOAT(value))
73
+
68 74
 void serial_echopair_P(const char* s_P, const char *v);
69 75
 void serial_echopair_P(const char* s_P, char v);
70 76
 void serial_echopair_P(const char* s_P, int v);

Loading…
Cancel
Save