Dynamic Lighting Lib. of 7Seg-LED (add DP) x4. Features: - Unified Anode/Cathode and NPN/PNP sw. - Non-use wait(); Useing Interrupt Timer. - Modulates Brightness with PWM. - Display Hex. - Using BusOut(s) of Digits(4) and Segments(8). - Sinmple Interface of Class.

Embed: (wiki syntax)

« Back to documentation index

LED7segX4 Class Reference

LED7segX4 Class Reference

Dynamic Lighting Lib. More...

#include <LED7segX4.h>

Public Member Functions

 LED7segX4 (BusOut &portDig, BusOut &portSeg)
 Constructor.
void init (bool revDig=false, bool revSeg=false, int timePeriod=1000, int duty=80)
 Initialize.
void setReverse (bool dig, bool seg)
 set seg TYPE;
void set7seg (char chr[])
 Set 7seg.
void setDP (char chr)
 Set DotPoint.
void setPWM (int timePeriod, int duty)
 Set PWM (Britness).

Detailed Description

Dynamic Lighting Lib.

of 7Seg-LED (add DP) x4.

Features:

  • Unified Anode/Cathode common 7Segs, and NPN/PNP switchings.
  • Using BusOut(s) of Digits(0-3) and Segments(A-G,DP).
  • Simple Interface of Class.
  • Non-use wait(); Useing Interrupt Timer: Ticker and Timeut.
  • Modulates Brightness; You Can Control of Periodic-Time and Duty.
  • Display Hex(0-9,A-F) of 4 Digit; Using char[4].
    #include "mbed.h"
     
    #include "LED7segX4.h"
     
    // port make.
    BusOut pDgit(p21, p22, p23, p24);   // D1, D2, D3, D4
    BusOut pSeg(p11, p12, p13, p14, p15, p16, p17, p18); // A, B, C, D, E, F, G, DP
    
    // Make instance of 7Seg-class.
    LED7segX4 led7seg(pDgit, pSeg);
    
    // for Operation check.
    DigitalOut myled(LED1);
    
    int main() {
        
        char val[4];
        char dp;
        int duty;
        
         // In this case: Anode Common, PNP swiching for Dig-common,
        // and sink port(BusOut) for seg.
        led7seg.init(true, true, 1000, 40);
        
        val[0]= 0;
        val[1]= 0;
        val[2]= 0;
        val[3]= 0;
        
        led7seg.set7seg(val);
        led7seg.setDP(0b0001);
        
        while(true) {
            myled = !myled;
            wait_ms(30);
    
            if(++duty > 100)
                duty= 30;
                
            val[3] += 1;
            for(int i= 0; i < 3; i++){
                if(val[3-i] > 15){
                    if(i < 3){
                        val[3-i]= 0;
                        val[2-i] += 1;
                    }
                    dp += 1;
                }
            }
            if(val[0]==15 && val[1]==15 && val[2]==15 && val[3]==15){
                // = FFFF
                val[0]= 0;
                val[1]= 0;
                val[2]= 0;
                val[3]= 0;
            }
            if(dp > 0b1111)
                dp= 0;
            
            led7seg.set7seg(val);
            led7seg.setDP(dp);
            led7seg.setPWM(1000, duty);
            
        }
        
        return 0;
    }
    

Definition at line 88 of file LED7segX4.h.


Constructor & Destructor Documentation

LED7segX4 ( BusOut &  portDig,
BusOut &  portSeg 
)

Constructor.

Parameters:
BusOut;_portDig: Bus4 of Digit(3~0)
BusOut;_portSeg: Bus8 of Segment(a~g+dp)

Definition at line 3 of file LED7segX4.cpp.


Member Function Documentation

void init ( bool  revDig = false,
bool  revSeg = false,
int  timePeriod = 1000,
int  duty = 80 
)

Initialize.

Parameters:
bool;dig: Reverce(H/L) Digit(3~0)
bool;seg: Reverce(H/L) Segment(a~g+dp)
int;timePeriod[us]: time of priend in PWM.
int;duty[%]: duty of PWM.

Definition at line 15 of file LED7segX4.cpp.

void set7seg ( char  chr[] )

Set 7seg.

Parameters:
chr[4];D3~D1, 0x00(0)~0x15(F) and 0x16(OFF/NULL).

Definition at line 117 of file LED7segX4.cpp.

void setDP ( char  chr )

Set DotPoint.

Parameters:
chr;0b0000~0b1111, bit0~3; TRUE=1.

Definition at line 126 of file LED7segX4.cpp.

void setPWM ( int  timePeriod,
int  duty 
)

Set PWM (Britness).

Parameters:
int;periodic time [us]. "for Each Digit."
int;duty ratio;1~100[%] in timePeriod. ex) In case of 1,000us and 60%,

Definition at line 132 of file LED7segX4.cpp.

void setReverse ( bool  dig,
bool  seg 
)

set seg TYPE;

Parameters:
bool;dig: Digit(3~0)
bool;seg: Segment(a~g+dp)

Definition at line 29 of file LED7segX4.cpp.