@@ -85,45 +85,23 @@ class SegBuffer : public Print {
8585 setCursor (from);
8686 if (hour < 10 ) print (' ' );
8787 print (hour);
88- setCursor (from + 2 );
8988 if (minute < 10 ) print (0 );
9089 print (minute);
9190 }
9291
9392 // вывести байт в текущую позицию курсора
9493 void writeByte (uint8_t data) {
95- _useFont = 0 ;
96- write (data);
97- _useFont = 1 ;
94+ _write (data, false );
9895 }
9996
10097 // вывести байты в текущую позицию курсора
10198 void writeByte (uint8_t * data, uint8_t len) {
102- _useFont = 0 ;
103- while (len--) write (*data++);
104- _useFont = 1 ;
99+ while (len--) writeByte (*data++);
105100 }
106101
107102 // вывести символ в текущую позицию курсора
108103 size_t write (uint8_t data) {
109- if (_useFont && data == ' .' ) {
110- if (!_dec) return 1 ;
111- if (_rtol) {
112- if (_pos >= 0 && _pos < _size) bitSet (buffer[_pos], 7 );
113- } else {
114- if (_pos > 0 && _pos <= _size) bitSet (buffer[_pos - 1 ], 7 );
115- }
116- return 1 ;
117- }
118-
119- if (_pos >= 0 && _pos < _size) {
120- if (_rtol) {
121- uint8_t from = (_shiftSize && _shiftSize <= _pos) ? (_pos - _shiftSize + 1 ) : 0 ;
122- for (int8_t i = from; i < _pos; i++) buffer[i] = buffer[i + 1 ];
123- }
124- buffer[_pos] = _useFont ? sseg::getCharCode (data) : data;
125- }
126- if (!_rtol) _pos++;
104+ _write (data, true );
127105 return 1 ;
128106 }
129107
@@ -156,5 +134,25 @@ class SegBuffer : public Print {
156134 int16_t _pos = 0 ;
157135 bool _rtol = 0 ;
158136 uint8_t _shiftSize = 0 ;
159- bool _useFont = 1 ;
137+
138+ void _write (uint8_t data, bool useFont) {
139+ if (useFont && data == ' .' ) {
140+ if (!_dec) return ;
141+ if (_rtol) {
142+ if (_pos >= 0 && _pos < _size) bitSet (buffer[_pos], 7 );
143+ } else {
144+ if (_pos > 0 && _pos <= _size) bitSet (buffer[_pos - 1 ], 7 );
145+ }
146+ return ;
147+ }
148+
149+ if (_pos >= 0 && _pos < _size) {
150+ if (_rtol) {
151+ uint8_t from = (_shiftSize && _shiftSize <= _pos) ? (_pos - _shiftSize + 1 ) : 0 ;
152+ for (int8_t i = from; i < _pos; i++) buffer[i] = buffer[i + 1 ];
153+ }
154+ buffer[_pos] = useFont ? sseg::getCharCode (data) : data;
155+ }
156+ if (!_rtol) _pos++;
157+ }
160158};
0 commit comments