Final

Dependencies:   mbed

Fork of MiniProject5_LightTracker by Austin Sloop

SegDisplay.cpp

Committer:
asloop18
Date:
2016-01-12
Revision:
14:69cad6d9a2e5
Parent:
13:871d01d0d250

File content as of revision 14:69cad6d9a2e5:

#include "SegDisplay.h"
BusOut Display(p5,p6,p7,p8,p9,p10,p11,p12);
DigitalOut Display1(p16);
DigitalOut Display10(p17);
DigitalOut Negative(p14);


void SegInit(void)
{
    Display = SegConvert(0);
   
}

char SegConvert(char SegValue)
{
    char SegByte = 0x00;
    switch(SegValue){
        case 0: SegByte = 0x3F; break;
        case 1: SegByte = 0x06; break;
        case 2: SegByte = 0x5B; break;
        case 3: SegByte = 0x4F; break;
        case 4: SegByte = 0x66; break;
        case 5: SegByte = 0x6D; break;
        case 6: SegByte = 0x7D; break;
        case 7: SegByte = 0x07; break;
        case 8: SegByte = 0x7F; break;
        case 9: SegByte = 0x6F; break;
    }    
    return SegByte;
}

void SegDisplay(int x)
{
    for(int i=0;i<25;i++)
    {
        if(x<0){Negative=1;}
        else{Negative=0;}
        wait(0.001);
        Negative=0;
        Display1 =1;
        Display = SegConvert(abs(x)/10);
        wait(.001);
        Display1=0;
        wait(0.0005);
        Display10 = 1;
        Display = SegConvert(abs(x)%10);
        wait(.001);
        Display10=0;  
    }     
}