|
@@ -57,14 +57,14 @@ void safe_delay(millis_t ms) {
|
57
|
57
|
#define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
|
58
|
58
|
|
59
|
59
|
// Convert unsigned int to string with 12 format
|
60
|
|
- char* itostr2(const uint8_t& xx) {
|
|
60
|
+ char* itostr2(const uint8_t &xx) {
|
61
|
61
|
conv[5] = DIGIMOD(xx, 10);
|
62
|
62
|
conv[6] = DIGIMOD(xx, 1);
|
63
|
63
|
return &conv[5];
|
64
|
64
|
}
|
65
|
65
|
|
66
|
66
|
// Convert signed int to rj string with 123 or -12 format
|
67
|
|
- char* itostr3(const int& x) {
|
|
67
|
+ char* itostr3(const int &x) {
|
68
|
68
|
int xx = x;
|
69
|
69
|
conv[4] = MINUSOR(xx, RJDIGIT(xx, 100));
|
70
|
70
|
conv[5] = RJDIGIT(xx, 10);
|
|
@@ -73,7 +73,7 @@ void safe_delay(millis_t ms) {
|
73
|
73
|
}
|
74
|
74
|
|
75
|
75
|
// Convert unsigned int to lj string with 123 format
|
76
|
|
- char* itostr3left(const int& xx) {
|
|
76
|
+ char* itostr3left(const int &xx) {
|
77
|
77
|
char *str = &conv[6];
|
78
|
78
|
*str = DIGIMOD(xx, 1);
|
79
|
79
|
if (xx >= 10) {
|
|
@@ -85,7 +85,7 @@ void safe_delay(millis_t ms) {
|
85
|
85
|
}
|
86
|
86
|
|
87
|
87
|
// Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
|
88
|
|
- char *itostr4sign(const int& x) {
|
|
88
|
+ char *itostr4sign(const int &x) {
|
89
|
89
|
const bool neg = x < 0;
|
90
|
90
|
const int xx = neg ? -x : x;
|
91
|
91
|
if (x >= 1000) {
|
|
@@ -116,7 +116,7 @@ void safe_delay(millis_t ms) {
|
116
|
116
|
}
|
117
|
117
|
|
118
|
118
|
// Convert unsigned float to string with 1.23 format
|
119
|
|
- char* ftostr12ns(const float& x) {
|
|
119
|
+ char* ftostr12ns(const float &x) {
|
120
|
120
|
const long xx = (x < 0 ? -x : x) * 100;
|
121
|
121
|
conv[3] = DIGIMOD(xx, 100);
|
122
|
122
|
conv[4] = '.';
|
|
@@ -126,7 +126,7 @@ void safe_delay(millis_t ms) {
|
126
|
126
|
}
|
127
|
127
|
|
128
|
128
|
// Convert signed float to fixed-length string with 023.45 / -23.45 format
|
129
|
|
- char *ftostr32(const float& x) {
|
|
129
|
+ char *ftostr32(const float &x) {
|
130
|
130
|
long xx = x * 100;
|
131
|
131
|
conv[1] = MINUSOR(xx, DIGIMOD(xx, 10000));
|
132
|
132
|
conv[2] = DIGIMOD(xx, 1000);
|
|
@@ -140,7 +140,7 @@ void safe_delay(millis_t ms) {
|
140
|
140
|
#if ENABLED(LCD_DECIMAL_SMALL_XY)
|
141
|
141
|
|
142
|
142
|
// Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format
|
143
|
|
- char *ftostr4sign(const float& fx) {
|
|
143
|
+ char *ftostr4sign(const float &fx) {
|
144
|
144
|
const int x = fx * 10;
|
145
|
145
|
if (!WITHIN(x, -99, 999)) return itostr4sign((int)fx);
|
146
|
146
|
const bool neg = x < 0;
|
|
@@ -155,7 +155,7 @@ void safe_delay(millis_t ms) {
|
155
|
155
|
#endif // LCD_DECIMAL_SMALL_XY
|
156
|
156
|
|
157
|
157
|
// Convert float to fixed-length string with +123.4 / -123.4 format
|
158
|
|
- char* ftostr41sign(const float& x) {
|
|
158
|
+ char* ftostr41sign(const float &x) {
|
159
|
159
|
int xx = x * 10;
|
160
|
160
|
conv[1] = MINUSOR(xx, '+');
|
161
|
161
|
conv[2] = DIGIMOD(xx, 1000);
|
|
@@ -167,7 +167,7 @@ void safe_delay(millis_t ms) {
|
167
|
167
|
}
|
168
|
168
|
|
169
|
169
|
// Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
|
170
|
|
- char* ftostr43sign(const float& x, char plus/*=' '*/) {
|
|
170
|
+ char* ftostr43sign(const float &x, char plus/*=' '*/) {
|
171
|
171
|
long xx = x * 1000;
|
172
|
172
|
conv[1] = xx ? MINUSOR(xx, plus) : ' ';
|
173
|
173
|
conv[2] = DIGIMOD(xx, 1000);
|
|
@@ -179,7 +179,7 @@ void safe_delay(millis_t ms) {
|
179
|
179
|
}
|
180
|
180
|
|
181
|
181
|
// Convert unsigned float to rj string with 12345 format
|
182
|
|
- char* ftostr5rj(const float& x) {
|
|
182
|
+ char* ftostr5rj(const float &x) {
|
183
|
183
|
const long xx = x < 0 ? -x : x;
|
184
|
184
|
conv[2] = RJDIGIT(xx, 10000);
|
185
|
185
|
conv[3] = RJDIGIT(xx, 1000);
|
|
@@ -190,7 +190,7 @@ void safe_delay(millis_t ms) {
|
190
|
190
|
}
|
191
|
191
|
|
192
|
192
|
// Convert signed float to string with +1234.5 format
|
193
|
|
- char* ftostr51sign(const float& x) {
|
|
193
|
+ char* ftostr51sign(const float &x) {
|
194
|
194
|
long xx = x * 10;
|
195
|
195
|
conv[0] = MINUSOR(xx, '+');
|
196
|
196
|
conv[1] = DIGIMOD(xx, 10000);
|
|
@@ -203,7 +203,7 @@ void safe_delay(millis_t ms) {
|
203
|
203
|
}
|
204
|
204
|
|
205
|
205
|
// Convert signed float to string with +123.45 format
|
206
|
|
- char* ftostr52sign(const float& x) {
|
|
206
|
+ char* ftostr52sign(const float &x) {
|
207
|
207
|
long xx = x * 100;
|
208
|
208
|
conv[0] = MINUSOR(xx, '+');
|
209
|
209
|
conv[1] = DIGIMOD(xx, 10000);
|
|
@@ -216,7 +216,7 @@ void safe_delay(millis_t ms) {
|
216
|
216
|
}
|
217
|
217
|
|
218
|
218
|
// Convert unsigned float to string with 1234.56 format omitting trailing zeros
|
219
|
|
- char* ftostr62rj(const float& x) {
|
|
219
|
+ char* ftostr62rj(const float &x) {
|
220
|
220
|
const long xx = (x < 0 ? -x : x) * 100;
|
221
|
221
|
conv[0] = RJDIGIT(xx, 100000);
|
222
|
222
|
conv[1] = RJDIGIT(xx, 10000);
|
|
@@ -229,7 +229,7 @@ void safe_delay(millis_t ms) {
|
229
|
229
|
}
|
230
|
230
|
|
231
|
231
|
// Convert signed float to space-padded string with -_23.4_ format
|
232
|
|
- char* ftostr52sp(const float& x) {
|
|
232
|
+ char* ftostr52sp(const float &x) {
|
233
|
233
|
long xx = x * 100;
|
234
|
234
|
uint8_t dig;
|
235
|
235
|
conv[1] = MINUSOR(xx, RJDIGIT(xx, 10000));
|