Kojo / FourDigitLED

Dependents:   IF-SmartClock

Revision:
0:7a8925d2a8e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/7segment4LED.h	Thu Jun 25 23:30:58 2015 +0000
@@ -0,0 +1,35 @@
+#ifndef SEVENSEG_4LED_H
+#define SEVENSEG_4LED_H
+
+#define DIGITS 4
+#define MASK_VALUE 0x7f
+#define MASK_DOT   0x80
+#define MASK_DIGIT 0x300
+
+typedef struct {
+    unsigned char val[DIGITS] ;
+} SegmentValue ;
+
+class FourDigitLED {
+public:
+  FourDigitLED    (
+    PinName seg0, PinName seg1, PinName seg2, PinName seg3, 
+    PinName seg4, PinName seg5, PinName seg6, PinName dot, 
+    PinName digit0, PinName digit1, PinName digit2, PinName digit3
+);
+  ~FourDigitLED();
+  bool attach(SegmentValue *v) ;
+  void start(void) ;
+  int setNum(int d, int n) ;
+  int setDot(int d, bool n) ;
+  void test(int n) ;
+  void dump(void) ;
+private:
+    void Scan(void) ;
+    BusOut *LEDs ;
+    unsigned char val[DIGITS] ;
+    Ticker Scan_tick ;
+    int scan_digit ;
+} ;
+
+#endif