7 segment display library for mbed This routine support 2,4 and 8 digit anode-common or cathode-common LED.
Diff: Sseg.cpp
- Revision:
- 7:a19431131213
- Parent:
- 4:858e42224b50
- Child:
- 9:6d3229c8dc0f
--- a/Sseg.cpp Thu Aug 07 11:44:22 2014 +0000 +++ b/Sseg.cpp Sun Sep 21 08:32:50 2014 +0000 @@ -29,6 +29,7 @@ _updateInterval = (8333 / 2); _zeroSupress = true; _kcommon = false; + _sinkDriver = false; } // 4 digit @@ -41,6 +42,7 @@ _updateInterval = (8333 / 4); _zeroSupress = true; _kcommon = false; + _sinkDriver = false; } // 8 digit @@ -54,6 +56,7 @@ _updateInterval = (8333 / 8); _zeroSupress = true; _kcommon = false; + _sinkDriver = false; } @@ -70,6 +73,10 @@ _kcommon = true; } +void Sseg::setSinkDriver(void) { + _sinkDriver = true; +} + char Sseg::segCh(char i) { return Sseg::numConv[i]; } @@ -267,7 +274,7 @@ void Sseg::updateSeg(void) { if( (++_dig) >= _numOfDigs) _dig = 0; - _segPins = ( _kcommon) ? _buffer[_dig] : ~_buffer[_dig]; + _segPins = (( _kcommon) || (_sinkDriver)) ? _buffer[_dig] : ~_buffer[_dig]; } bool Sseg::update(void) {