Four digit 7 segment LED driver

Dependents:   IF-SmartClock

Committer:
takashikojo
Date:
Sun Nov 22 08:46:13 2015 +0000
Revision:
4:5ed17505c88e
Parent:
3:73f31aea935a
Cleaned comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takashikojo 0:7a8925d2a8e7 1 #ifndef SEVENSEG_4LED_H
takashikojo 0:7a8925d2a8e7 2 #define SEVENSEG_4LED_H
takashikojo 0:7a8925d2a8e7 3
takashikojo 0:7a8925d2a8e7 4 #define DIGITS 4
takashikojo 0:7a8925d2a8e7 5 #define MASK_VALUE 0x7f
takashikojo 0:7a8925d2a8e7 6 #define MASK_DOT 0x80
takashikojo 0:7a8925d2a8e7 7 #define MASK_DIGIT 0x300
takashikojo 0:7a8925d2a8e7 8
takashikojo 0:7a8925d2a8e7 9 typedef struct {
takashikojo 0:7a8925d2a8e7 10 unsigned char val[DIGITS] ;
takashikojo 0:7a8925d2a8e7 11 } SegmentValue ;
takashikojo 0:7a8925d2a8e7 12
takashikojo 0:7a8925d2a8e7 13 class FourDigitLED {
takashikojo 0:7a8925d2a8e7 14 public:
takashikojo 0:7a8925d2a8e7 15 FourDigitLED (
takashikojo 0:7a8925d2a8e7 16 PinName seg0, PinName seg1, PinName seg2, PinName seg3,
takashikojo 0:7a8925d2a8e7 17 PinName seg4, PinName seg5, PinName seg6, PinName dot,
takashikojo 0:7a8925d2a8e7 18 PinName digit0, PinName digit1, PinName digit2, PinName digit3
takashikojo 0:7a8925d2a8e7 19 );
takashikojo 0:7a8925d2a8e7 20 ~FourDigitLED();
takashikojo 0:7a8925d2a8e7 21 bool attach(SegmentValue *v) ;
takashikojo 0:7a8925d2a8e7 22 void start(void) ;
takashikojo 2:c4e8b2fd8f7e 23 unsigned int getPtn(int d) ;
takashikojo 2:c4e8b2fd8f7e 24 unsigned int setPtn(int d, unsigned int ptn, unsigned int mask) ;
takashikojo 0:7a8925d2a8e7 25 int setNum(int d, int n) ;
takashikojo 0:7a8925d2a8e7 26 int setDot(int d, bool n) ;
takashikojo 0:7a8925d2a8e7 27 void test(int n) ;
takashikojo 0:7a8925d2a8e7 28 void dump(void) ;
takashikojo 3:73f31aea935a 29 void scanDigit(void);
takashikojo 3:73f31aea935a 30
takashikojo 0:7a8925d2a8e7 31 private:
takashikojo 3:73f31aea935a 32
takashikojo 0:7a8925d2a8e7 33 BusOut *LEDs ;
takashikojo 0:7a8925d2a8e7 34 unsigned char val[DIGITS] ;
takashikojo 3:73f31aea935a 35 //Ticker Scan_tick ;
takashikojo 0:7a8925d2a8e7 36 int scan_digit ;
takashikojo 0:7a8925d2a8e7 37 } ;
takashikojo 0:7a8925d2a8e7 38
takashikojo 0:7a8925d2a8e7 39 #endif