|
@@ -29,7 +29,7 @@
|
29
|
29
|
#endif
|
30
|
30
|
|
31
|
31
|
// flushTX is not implemented in all HAL, so use SFINAE to call the method where it is.
|
32
|
|
-CALL_IF_EXISTS_IMPL(void, flushTX );
|
|
32
|
+CALL_IF_EXISTS_IMPL(void, flushTX);
|
33
|
33
|
CALL_IF_EXISTS_IMPL(bool, connected, true);
|
34
|
34
|
|
35
|
35
|
// In order to catch usage errors in code, we make the base to encode number explicit
|
|
@@ -42,14 +42,14 @@ enum class PrintBase {
|
42
|
42
|
Bin = 2
|
43
|
43
|
};
|
44
|
44
|
|
45
|
|
-// A simple forward struct that prevent the compiler to select print(double, int) as a default overload for any type different than
|
|
45
|
+// A simple forward struct that prevent the compiler to select print(double, int) as a default overload for any type different than
|
46
|
46
|
// double or float. For double or float, a conversion exists so the call will be transparent
|
47
|
47
|
struct EnsureDouble {
|
48
|
48
|
double a;
|
49
|
49
|
FORCE_INLINE operator double() { return a; }
|
50
|
50
|
// If the compiler breaks on ambiguity here, it's likely because you're calling print(X, base) with X not a double or a float, and a
|
51
|
51
|
// base that's not one of PrintBase's value. This exact code is made to detect such error, you NEED to set a base explicitely like this:
|
52
|
|
- // SERIAL_PRINT(v, PrintBase::Hex)
|
|
52
|
+ // SERIAL_PRINT(v, PrintBase::Hex)
|
53
|
53
|
FORCE_INLINE EnsureDouble(double a) : a(a) {}
|
54
|
54
|
FORCE_INLINE EnsureDouble(float a) : a(a) {}
|
55
|
55
|
};
|
|
@@ -147,13 +147,13 @@ struct SerialBase {
|
147
|
147
|
else write('0');
|
148
|
148
|
}
|
149
|
149
|
void printNumber(signed long n, const uint8_t base) {
|
150
|
|
- if (base == 10 && n < 0) {
|
|
150
|
+ if (base == 10 && n < 0) {
|
151
|
151
|
n = -n; // This works because all platforms Marlin's builds on are using 2-complement encoding for negative number
|
152
|
152
|
// On such CPU, changing the sign of a number is done by inverting the bits and adding one, so if n = 0x80000000 = -2147483648 then
|
153
|
153
|
// -n = 0x7FFFFFFF + 1 => 0x80000000 = 2147483648 (if interpreted as unsigned) or -2147483648 if interpreted as signed.
|
154
|
154
|
// On non 2-complement CPU, there would be no possible representation for 2147483648.
|
155
|
|
- write('-');
|
156
|
|
- }
|
|
155
|
+ write('-');
|
|
156
|
+ }
|
157
|
157
|
printNumber((unsigned long)n , base);
|
158
|
158
|
}
|
159
|
159
|
|