Final

Dependencies:   mbed

Fork of MiniProject5_LightTracker by Austin Sloop

Committer:
asloop18
Date:
Tue Jan 12 01:41:19 2016 +0000
Revision:
14:69cad6d9a2e5
Parent:
13:871d01d0d250
Mission Accomplished; ; Working Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pstephens18 1:8e14c2404f45 1 #include "SegDisplay.h"
asloop18 2:d50d55831d50 2 BusOut Display(p5,p6,p7,p8,p9,p10,p11,p12);
pstephens18 3:4a3e2dbc111e 3 DigitalOut Display1(p16);
pstephens18 3:4a3e2dbc111e 4 DigitalOut Display10(p17);
pstephens18 11:7b3d64a66efd 5 DigitalOut Negative(p14);
asloop18 2:d50d55831d50 6
pstephens18 1:8e14c2404f45 7
pstephens18 1:8e14c2404f45 8 void SegInit(void)
pstephens18 1:8e14c2404f45 9 {
pstephens18 3:4a3e2dbc111e 10 Display = SegConvert(0);
asloop18 2:d50d55831d50 11
pstephens18 1:8e14c2404f45 12 }
pstephens18 1:8e14c2404f45 13
pstephens18 1:8e14c2404f45 14 char SegConvert(char SegValue)
pstephens18 1:8e14c2404f45 15 {
pstephens18 1:8e14c2404f45 16 char SegByte = 0x00;
asloop18 2:d50d55831d50 17 switch(SegValue){
pstephens18 1:8e14c2404f45 18 case 0: SegByte = 0x3F; break;
pstephens18 1:8e14c2404f45 19 case 1: SegByte = 0x06; break;
pstephens18 1:8e14c2404f45 20 case 2: SegByte = 0x5B; break;
pstephens18 1:8e14c2404f45 21 case 3: SegByte = 0x4F; break;
pstephens18 1:8e14c2404f45 22 case 4: SegByte = 0x66; break;
pstephens18 1:8e14c2404f45 23 case 5: SegByte = 0x6D; break;
pstephens18 1:8e14c2404f45 24 case 6: SegByte = 0x7D; break;
pstephens18 1:8e14c2404f45 25 case 7: SegByte = 0x07; break;
pstephens18 1:8e14c2404f45 26 case 8: SegByte = 0x7F; break;
pstephens18 1:8e14c2404f45 27 case 9: SegByte = 0x6F; break;
pstephens18 1:8e14c2404f45 28 }
pstephens18 1:8e14c2404f45 29 return SegByte;
pstephens18 3:4a3e2dbc111e 30 }
pstephens18 3:4a3e2dbc111e 31
pstephens18 13:871d01d0d250 32 void SegDisplay(int x)
pstephens18 3:4a3e2dbc111e 33 {
pstephens18 13:871d01d0d250 34 for(int i=0;i<25;i++)
pstephens18 3:4a3e2dbc111e 35 {
pstephens18 13:871d01d0d250 36 if(x<0){Negative=1;}
asloop18 14:69cad6d9a2e5 37 else{Negative=0;}
asloop18 14:69cad6d9a2e5 38 wait(0.001);
asloop18 14:69cad6d9a2e5 39 Negative=0;
pstephens18 3:4a3e2dbc111e 40 Display1 =1;
asloop18 14:69cad6d9a2e5 41 Display = SegConvert(abs(x)/10);
pstephens18 11:7b3d64a66efd 42 wait(.001);
pstephens18 3:4a3e2dbc111e 43 Display1=0;
asloop18 14:69cad6d9a2e5 44 wait(0.0005);
pstephens18 3:4a3e2dbc111e 45 Display10 = 1;
asloop18 14:69cad6d9a2e5 46 Display = SegConvert(abs(x)%10);
pstephens18 11:7b3d64a66efd 47 wait(.001);
pstephens18 13:871d01d0d250 48 Display10=0;
pstephens18 13:871d01d0d250 49 }
pstephens18 3:4a3e2dbc111e 50 }
pstephens18 11:7b3d64a66efd 51