7 segment display library for mbed This routine support 2,4 and 8 digit anode-common or cathode-common LED.

Dependents:   7segMbed

Revision:
12:59ac7a4f3d9c
Parent:
11:8be75770e375
--- 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;
     }