|
@@ -74,25 +74,32 @@ void safe_delay(millis_t ms) {
|
74
|
74
|
return str;
|
75
|
75
|
}
|
76
|
76
|
|
77
|
|
- // Convert signed int to rj string with _123, -123, _-12, or __-1 format
|
|
77
|
+ // Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
|
78
|
78
|
char *itostr4sign(const int& x) {
|
79
|
|
- int xx = abs(x), sign = 0;
|
80
|
|
- if (xx >= 100) {
|
|
79
|
+ int xx = abs(x);
|
|
80
|
+ if (x >= 1000) {
|
|
81
|
+ conv[0] = DIGIMOD(xx, 1000);
|
81
|
82
|
conv[1] = DIGIMOD(xx, 100);
|
82
|
83
|
conv[2] = DIGIMOD(xx, 10);
|
83
|
84
|
}
|
84
|
85
|
else {
|
85
|
|
- conv[0] = ' ';
|
86
|
|
- if (xx >= 10) {
|
87
|
|
- sign = 1;
|
|
86
|
+ if (xx >= 100) {
|
|
87
|
+ conv[0] = x < 0 ? '-' : ' ';
|
|
88
|
+ conv[1] = DIGIMOD(xx, 100);
|
88
|
89
|
conv[2] = DIGIMOD(xx, 10);
|
89
|
90
|
}
|
90
|
91
|
else {
|
91
|
|
- conv[1] = ' ';
|
92
|
|
- sign = 2;
|
|
92
|
+ conv[0] = ' ';
|
|
93
|
+ if (xx >= 10) {
|
|
94
|
+ conv[1] = x < 0 ? '-' : ' ';
|
|
95
|
+ conv[2] = DIGIMOD(xx, 10);
|
|
96
|
+ }
|
|
97
|
+ else {
|
|
98
|
+ conv[1] = ' ';
|
|
99
|
+ conv[2] = x < 0 ? '-' : ' ';
|
|
100
|
+ }
|
93
|
101
|
}
|
94
|
102
|
}
|
95
|
|
- conv[sign] = x < 0 ? '-' : ' ';
|
96
|
103
|
conv[3] = DIGIMOD(xx, 1);
|
97
|
104
|
conv[4] = '\0';
|
98
|
105
|
return conv;
|