|
@@ -87,7 +87,7 @@ void safe_delay(millis_t ms) {
|
87
|
87
|
}
|
88
|
88
|
|
89
|
89
|
// Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
|
90
|
|
- char *itostr4sign(const int x) {
|
|
90
|
+ char* itostr4sign(const int x) {
|
91
|
91
|
const bool neg = x < 0;
|
92
|
92
|
const int xx = neg ? -x : x;
|
93
|
93
|
if (x >= 1000) {
|
|
@@ -119,7 +119,7 @@ void safe_delay(millis_t ms) {
|
119
|
119
|
|
120
|
120
|
// Convert unsigned float to string with 1.23 format
|
121
|
121
|
char* ftostr12ns(const float &x) {
|
122
|
|
- const long xx = (x < 0 ? -x : x) * 100;
|
|
122
|
+ const long xx = ((x < 0 ? -x : x) + 0.001) * 100;
|
123
|
123
|
conv[3] = DIGIMOD(xx, 100);
|
124
|
124
|
conv[4] = '.';
|
125
|
125
|
conv[5] = DIGIMOD(xx, 10);
|
|
@@ -128,8 +128,8 @@ void safe_delay(millis_t ms) {
|
128
|
128
|
}
|
129
|
129
|
|
130
|
130
|
// Convert signed float to fixed-length string with 023.45 / -23.45 format
|
131
|
|
- char *ftostr32(const float &x) {
|
132
|
|
- long xx = x * 100;
|
|
131
|
+ char* ftostr32(const float &x) {
|
|
132
|
+ long xx = FIXFLOAT(x) * 100;
|
133
|
133
|
conv[1] = MINUSOR(xx, DIGIMOD(xx, 10000));
|
134
|
134
|
conv[2] = DIGIMOD(xx, 1000);
|
135
|
135
|
conv[3] = DIGIMOD(xx, 100);
|
|
@@ -142,8 +142,8 @@ void safe_delay(millis_t ms) {
|
142
|
142
|
#if ENABLED(LCD_DECIMAL_SMALL_XY)
|
143
|
143
|
|
144
|
144
|
// Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format
|
145
|
|
- char *ftostr4sign(const float &fx) {
|
146
|
|
- const int x = fx * 10;
|
|
145
|
+ char* ftostr4sign(const float &fx) {
|
|
146
|
+ const int x = FIXFLOAT(fx) * 10;
|
147
|
147
|
if (!WITHIN(x, -99, 999)) return itostr4sign((int)fx);
|
148
|
148
|
const bool neg = x < 0;
|
149
|
149
|
const int xx = neg ? -x : x;
|
|
@@ -158,7 +158,7 @@ void safe_delay(millis_t ms) {
|
158
|
158
|
|
159
|
159
|
// Convert float to fixed-length string with +123.4 / -123.4 format
|
160
|
160
|
char* ftostr41sign(const float &x) {
|
161
|
|
- int xx = x * 10;
|
|
161
|
+ int xx = FIXFLOAT(x) * 10;
|
162
|
162
|
conv[1] = MINUSOR(xx, '+');
|
163
|
163
|
conv[2] = DIGIMOD(xx, 1000);
|
164
|
164
|
conv[3] = DIGIMOD(xx, 100);
|
|
@@ -170,7 +170,7 @@ void safe_delay(millis_t ms) {
|
170
|
170
|
|
171
|
171
|
// Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format
|
172
|
172
|
char* ftostr43sign(const float &x, char plus/*=' '*/) {
|
173
|
|
- long xx = x * 1000;
|
|
173
|
+ long xx = FIXFLOAT(x) * 1000;
|
174
|
174
|
conv[1] = xx ? MINUSOR(xx, plus) : ' ';
|
175
|
175
|
conv[2] = DIGIMOD(xx, 1000);
|
176
|
176
|
conv[3] = '.';
|
|
@@ -193,7 +193,7 @@ void safe_delay(millis_t ms) {
|
193
|
193
|
|
194
|
194
|
// Convert signed float to string with +1234.5 format
|
195
|
195
|
char* ftostr51sign(const float &x) {
|
196
|
|
- long xx = x * 10;
|
|
196
|
+ long xx = FIXFLOAT(x) * 10;
|
197
|
197
|
conv[0] = MINUSOR(xx, '+');
|
198
|
198
|
conv[1] = DIGIMOD(xx, 10000);
|
199
|
199
|
conv[2] = DIGIMOD(xx, 1000);
|
|
@@ -206,7 +206,7 @@ void safe_delay(millis_t ms) {
|
206
|
206
|
|
207
|
207
|
// Convert signed float to string with +123.45 format
|
208
|
208
|
char* ftostr52sign(const float &x) {
|
209
|
|
- long xx = x * 100;
|
|
209
|
+ long xx = FIXFLOAT(x) * 100;
|
210
|
210
|
conv[0] = MINUSOR(xx, '+');
|
211
|
211
|
conv[1] = DIGIMOD(xx, 10000);
|
212
|
212
|
conv[2] = DIGIMOD(xx, 1000);
|
|
@@ -219,7 +219,7 @@ void safe_delay(millis_t ms) {
|
219
|
219
|
|
220
|
220
|
// Convert unsigned float to string with 1234.56 format omitting trailing zeros
|
221
|
221
|
char* ftostr62rj(const float &x) {
|
222
|
|
- const long xx = (x < 0 ? -x : x) * 100;
|
|
222
|
+ const long xx = ((x < 0 ? -x : x) + 0.001) * 100;
|
223
|
223
|
conv[0] = RJDIGIT(xx, 100000);
|
224
|
224
|
conv[1] = RJDIGIT(xx, 10000);
|
225
|
225
|
conv[2] = RJDIGIT(xx, 1000);
|
|
@@ -232,7 +232,7 @@ void safe_delay(millis_t ms) {
|
232
|
232
|
|
233
|
233
|
// Convert signed float to space-padded string with -_23.4_ format
|
234
|
234
|
char* ftostr52sp(const float &x) {
|
235
|
|
- long xx = x * 100;
|
|
235
|
+ long xx = FIXFLOAT(x) * 100;
|
236
|
236
|
uint8_t dig;
|
237
|
237
|
conv[1] = MINUSOR(xx, RJDIGIT(xx, 10000));
|
238
|
238
|
conv[2] = RJDIGIT(xx, 1000);
|