|
@@ -129,6 +129,30 @@ void safe_delay(millis_t ms) {
|
129
|
129
|
return conv;
|
130
|
130
|
}
|
131
|
131
|
|
|
132
|
+ // Convert float to rj string with 1234, _123, -123, _-12, 12.3, _1.2, or -1.2 format
|
|
133
|
+ char *ftostr4sign(const float& fx) {
|
|
134
|
+ int x = fx * 10, xx = abs(x);
|
|
135
|
+ bool ispos = x >= 0,
|
|
136
|
+ isten = xx >= 100,
|
|
137
|
+ ishun = xx >= 1000;
|
|
138
|
+ if (!isten || (ispos && !ishun)) {
|
|
139
|
+ // 12.3, _1.2, -1.2
|
|
140
|
+ conv[0] = ispos ? (isten ? DIGIMOD(xx, 100) : ' ') : '-';
|
|
141
|
+ conv[1] = DIGIMOD(xx, 10);
|
|
142
|
+ conv[2] = '.';
|
|
143
|
+ conv[3] = DIGIMOD(xx, 1);
|
|
144
|
+ }
|
|
145
|
+ else {
|
|
146
|
+ // 1234, _123, -123, _-12
|
|
147
|
+ conv[0] = ispos ? (xx >= 10000 ? DIGIMOD(xx, 10000) : ' ') : (ishun ? '-' : ' ');
|
|
148
|
+ conv[1] = ishun ? DIGIMOD(xx, 1000) : '-';
|
|
149
|
+ conv[2] = DIGIMOD(xx, 100);
|
|
150
|
+ conv[3] = DIGIMOD(xx, 10);
|
|
151
|
+ }
|
|
152
|
+ conv[4] = '\0';
|
|
153
|
+ return conv;
|
|
154
|
+ }
|
|
155
|
+
|
132
|
156
|
// Convert float to fixed-length string with +123.4 / -123.4 format
|
133
|
157
|
char* ftostr41sign(const float& x) {
|
134
|
158
|
int xx = x * 10;
|