Preston Stephens / Mbed 2 deprecated MiniProject5_LightTracker

Dependencies:   mbed

Fork of MiniProject5_LightTracker by Austin Sloop

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SegDisplay.cpp Source File

SegDisplay.cpp

00001 #include "SegDisplay.h"
00002 BusOut Display(p5,p6,p7,p8,p9,p10,p11,p12);
00003 DigitalOut Display1(p16);
00004 DigitalOut Display10(p17);
00005 DigitalOut Negative(p14);
00006 
00007 
00008 void SegInit(void)
00009 {
00010     Display = SegConvert(0);
00011    
00012 }
00013 
00014 char SegConvert(char SegValue)
00015 {
00016     char SegByte = 0x00;
00017     switch(SegValue){
00018         case 0: SegByte = 0x3F; break;
00019         case 1: SegByte = 0x06; break;
00020         case 2: SegByte = 0x5B; break;
00021         case 3: SegByte = 0x4F; break;
00022         case 4: SegByte = 0x66; break;
00023         case 5: SegByte = 0x6D; break;
00024         case 6: SegByte = 0x7D; break;
00025         case 7: SegByte = 0x07; break;
00026         case 8: SegByte = 0x7F; break;
00027         case 9: SegByte = 0x6F; break;
00028     }    
00029     return SegByte;
00030 }
00031 
00032 void SegDisplay(int x)
00033 {
00034     for(int i=0;i<25;i++)
00035     {
00036         if(x<0){Negative=1;}
00037         else{Negative=0;}
00038         wait(0.001);
00039         Negative=0;
00040         Display1 =1;
00041         Display = SegConvert(abs(x)/10);
00042         wait(.001);
00043         Display1=0;
00044         wait(0.0005);
00045         Display10 = 1;
00046         Display = SegConvert(abs(x)%10);
00047         wait(.001);
00048         Display10=0;  
00049     }     
00050 }
00051