Real-time Embedded System final report code
Fork of app-shield-LCD by
Revision 6:5e9bc6b0d221, committed 2017-01-10
- Comitter:
- liusiyu
- Date:
- Tue Jan 10 18:18:48 2017 +0000
- Parent:
- 5:f8ef5e45e488
- Commit message:
- Real-time Embedded Systems Final Laboratory Report Code
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f8ef5e45e488 -r 5e9bc6b0d221 main.cpp --- a/main.cpp Fri Aug 01 14:30:24 2014 +0000 +++ b/main.cpp Tue Jan 10 18:18:48 2017 +0000 @@ -4,17 +4,210 @@ // Using Arduino pin notation C12832 lcd(D11, D13, D12, D7, D10); +int i,j,m,n,h,r,i1,j1,m1,n1,h1,r1,a,b,c,d,e,f,g; + +void second1(void); +void minute1(void); +void hour1(void); + int main() { - int j=0; - lcd.cls(); - lcd.locate(0,3); - lcd.printf("mbed application shield!"); + int second=0; + int minute=0; + int hour=0; + int number=0; + + while(1) { + for (i=0;i<10;i=i+1) + { + for (j=0;j<6;j=j+1) + { + number =j*10+i; + if (number == second) + {i1=i;j1=j;} + if (number == minute) + {m1=i;n1=j;} + if (number == hour) + {h1=i;r1=j;} + } + } + + second1(); + + minute1(); + + hour1(); + + second=second+1; + wait(0.01); + + if (second == 60) + {second = 0; + minute=minute+1;} + if (minute == 60) + {minute=0; + hour=hour+1;} + if (hour == 24) + {hour=0;} + }//while +}//main + + +void second1() +{ + if (i1==0) + {a=1;b=1;c=0;d=1;e=1;f=1;g=1;} + if (i1==1) + {a=0;b=0;c=0;d=1;e=0;f=0;g=1;} + if (i1==2) + {a=1;b=0;c=1;d=1;e=1;f=1;g=0;} + if (i1==3) + {a=1;b=0;c=1;d=1;e=0;f=1;g=1;} + if (i1==4) + {a=0;b=1;c=1;d=1;e=0;f=0;g=1;} + if (i1==5) + {a=1;b=1;c=1;d=0;e=0;f=1;g=1;} + if (i1==6) + {a=1,b=1;c=1;d=0;e=1;f=1;g=1;} + if (i1==7) + {a=1;b=0;c=0;d=1;e=0;f=0;g=1;} + if (i1==8) + {a=1;b=1;c=1;d=1;e=1;f=1;g=1;} + if (i1==9) + {a=1;b=1;c=1;d=1;e=0;f=1;g=1;} + + lcd.line(108,0,126,0,a); + lcd.line(108,0,108,15,b); + lcd.line(108,15,126,15,c); + lcd.line(126,0,126,15,d); + lcd.line(108,15,108,30,e); + lcd.line(108,30,126,30,f); + lcd.line(126,15,126,30,g); + + if (j1==0) + {a=1;b=1;c=0;d=1;e=1;f=1;g=1;} + if (j1==1) + {a=0;b=0;c=0;d=1;e=0;f=0;g=1;} + if (j1==2) + {a=1;b=0;c=1;d=1;e=1;f=1;g=0;} + if (j1==3) + {a=1;b=0;c=1;d=1;e=0;f=1;g=1;} + if (j1==4) + {a=0;b=1;c=1;d=1;e=0;f=0;g=1;} + if (j1==5) + {a=1;b=1;c=1;d=0;e=0;f=1;g=1;} + + lcd.line(87,0,106,0,a); + lcd.line(87,0,87,15,b); + lcd.line(87,15,106,15,c); + lcd.line(106,0,106,15,d); + lcd.line(87,15,87,30,e); + lcd.line(87,30,106,30,f); + lcd.line(106,15,106,30,g); +} - while(true) { // this is the third thread - lcd.locate(0,15); - lcd.printf("Counting : %d",j); - j++; - wait(1.0); - } +void minute1() +{ + if (m1==0) + {a=1;b=1;c=0;d=1;e=1;f=1;g=1;} + if (m1==1) + {a=0;b=0;c=0;d=1;e=0;f=0;g=1;} + if (m1==2) + {a=1;b=0;c=1;d=1;e=1;f=1;g=0;} + if (m1==3) + {a=1;b=0;c=1;d=1;e=0;f=1;g=1;} + if (m1==4) + {a=0;b=1;c=1;d=1;e=0;f=0;g=1;} + if (m1==5) + {a=1;b=1;c=1;d=0;e=0;f=1;g=1;} + if (m1==6) + {a=1,b=1;c=1;d=0;e=1;f=1;g=1;} + if (m1==7) + {a=1;b=0;c=0;d=1;e=0;f=0;g=1;} + if (m1==8) + {a=1;b=1;c=1;d=1;e=1;f=1;g=1;} + if (m1==9) + {a=1;b=1;c=1;d=1;e=0;f=1;g=1;} + + lcd.line(64,0,82,0,a); + lcd.line(64,0,64,15,b); + lcd.line(64,15,82,15,c); + lcd.line(82,0,82,15,d); + lcd.line(64,15,64,30,e); + lcd.line(64,30,82,30,f); + lcd.line(82,15,82,30,g); + + if (n1==0) + {a=1;b=1;c=0;d=1;e=1;f=1;g=1;} + if (n1==1) + {a=0;b=0;c=0;d=1;e=0;f=0;g=1;} + if (n1==2) + {a=1;b=0;c=1;d=1;e=1;f=1;g=0;} + if (n1==3) + {a=1;b=0;c=1;d=1;e=0;f=1;g=1;} + if (n1==4) + {a=0;b=1;c=1;d=1;e=0;f=0;g=1;} + if (n1==5) + {a=1;b=1;c=1;d=0;e=0;f=1;g=1;} + + lcd.line(44,0,62,0,a); + lcd.line(44,0,44,15,b); + lcd.line(44,15,62,15,c); + lcd.line(62,0,62,15,d); + lcd.line(44,15,44,30,e); + lcd.line(44,30,62,30,f); + lcd.line(62,15,62,30,g); } + +void hour1() +{ + if (h1==0) + {a=1;b=1;c=0;d=1;e=1;f=1;g=1;} + if (h1==1) + {a=0;b=0;c=0;d=1;e=0;f=0;g=1;} + if (h1==2) + {a=1;b=0;c=1;d=1;e=1;f=1;g=0;} + if (h1==3) + {a=1;b=0;c=1;d=1;e=0;f=1;g=1;} + if (h1==4) + {a=0;b=1;c=1;d=1;e=0;f=0;g=1;} + if (h1==5) + {a=1;b=1;c=1;d=0;e=0;f=1;g=1;} + if (h1==6) + {a=1,b=1;c=1;d=0;e=1;f=1;g=1;} + if (h1==7) + {a=1;b=0;c=0;d=1;e=0;f=0;g=1;} + if (h1==8) + {a=1;b=1;c=1;d=1;e=1;f=1;g=1;} + if (h1==9) + {a=1;b=1;c=1;d=1;e=0;f=1;g=1;} + + lcd.line(22,0,40,0,a); + lcd.line(22,0,22,15,b); + lcd.line(22,15,40,15,c); + lcd.line(40,0,40,15,d); + lcd.line(22,15,22,30,e); + lcd.line(22,30,40,30,f); + lcd.line(40,15,40,30,g); + + if (r1==0) + {a=1;b=1;c=0;d=1;e=1;f=1;g=1;} + if (r1==1) + {a=0;b=0;c=0;d=1;e=0;f=0;g=1;} + if (r1==2) + {a=1;b=0;c=1;d=1;e=1;f=1;g=0;} + if (r1==3) + {a=1;b=0;c=1;d=1;e=0;f=1;g=1;} + if (r1==4) + {a=0;b=1;c=1;d=1;e=0;f=0;g=1;} + if (r1==5) + {a=1;b=1;c=1;d=0;e=0;f=1;g=1;} + + lcd.line(2,0,20,0,a); + lcd.line(2,0,2,15,b); + lcd.line(2,15,20,15,c); + lcd.line(20,0,20,15,d); + lcd.line(2,15,2,30,e); + lcd.line(2,30,20,30,f); + lcd.line(20,15,20,30,g); +}