7 segment display library for mbed This routine support 2,4 and 8 digit anode-common or cathode-common LED.
Revision 12:59ac7a4f3d9c, committed 2015-07-05
- Comitter:
- morecat_lab
- Date:
- Sun Jul 05 08:30:58 2015 +0000
- Parent:
- 11:8be75770e375
- Commit message:
- re-fix logic ;-<
Changed in this revision
Sseg.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Sseg.cpp Sun Jul 05 07:41:22 2015 +0000 +++ b/Sseg.cpp Sun Jul 05 08:30:58 2015 +0000 @@ -283,11 +283,11 @@ } void Sseg::turnOff(void) { - _digPins[_dig] -> write((_kcommon == 0) ? 0 : 1); + _digPins[_dig] -> write((_kcommon) ? 1 : 0); } void Sseg::turnOn(void) { - _digPins[_dig] -> write((_kcommon == 0) ? 1 : 1); + _digPins[_dig] -> write((_kcommon) ? 0 : 1); } void Sseg::updateSeg(void) { @@ -298,9 +298,9 @@ mask = 0x80; for(i=0;i<8;i++){ if(data & mask){ - _segPins[i]->write(((_kcommon) || (_sinkDriver)) ? 0 : 1); + _segPins[i]->write(((_kcommon) || (_sinkDriver)) ? 1 : 0); }else{ - _segPins[i]->write(((_kcommon) || (_sinkDriver)) ? 1 : 0); + _segPins[i]->write(((_kcommon) || (_sinkDriver)) ? 0 : 1); } mask >>= 1; }