File tree Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Expand file tree Collapse file tree 4 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -502,6 +502,7 @@ uint8_t sseg::getCharCode(char symb);
502502
503503// получить длину int числа
504504uint8_t sseg::intLen(int32_t val);
505+ uint8_t sseg::intLen(uint32_t val);
505506
506507// получить длину float числа при указанной точности
507508uint8_t sseg::floatLen(double val, uint8_t dec = 2);
Original file line number Diff line number Diff line change 11name =GyverSegment
2- version =1.4.6
2+ version =1.4.7
33author =AlexGyver <
[email protected] >
44maintainer =AlexGyver <
[email protected] >
55sentence =Powerful library for controlling 7-segment indicators
Original file line number Diff line number Diff line change @@ -90,18 +90,20 @@ uint8_t getCharCode(char symb) {
9090 return pgm_read_byte (_segCharMap + (symb - 32 ));
9191}
9292
93- uint8_t intLen (int32_t val) {
94- if (!val) return 1 ;
95- uint8_t len = (val < 0 );
96- while (val) {
97- len++;
98- val /= 10 ;
99- }
93+ uint8_t intLen (uint32_t val) {
94+ uint8_t len = 0 ;
95+ do len++;
96+ while (val /= 10 );
10097 return len;
10198}
10299
100+ uint8_t intLen (int32_t val) {
101+ bool neg = val < 0 ;
102+ return intLen (uint32_t (neg ? -val : val)) + neg;
103+ }
104+
103105uint8_t floatLen (double val, uint8_t dec) {
104- return intLen (val) + dec;
106+ return intLen (( int32_t ) val) + dec;
105107}
106108
107109} // namespace sseg
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ uint8_t getCharCode(char symb);
99// получить длину int числа
1010uint8_t intLen (int32_t val);
1111
12+ // получить длину uint числа
13+ uint8_t intLen (uint32_t val);
14+
1215// получить длину float числа при указанной точности
1316uint8_t floatLen (double val, uint8_t dec = 2 );
1417
You can’t perform that action at this time.
0 commit comments