.
Fork of Timer by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "Display.h" 00003 00004 #define Sound 0xA0 00005 #define Servo 0x88 00006 00007 Ticker t; 00008 DigitalIn Button_Launch(D1); 00009 DigitalIn Button_Reset (D0); 00010 DigitalIn Button_Sel1 (D6); 00011 DigitalIn Button_Sel2 (D7); 00012 DigitalOut LED_Timer (D3); 00013 DigitalOut LED_Finish (D4); 00014 DigitalOut LED_Launch (D5); 00015 DigitalIn Camera (D9); 00016 00017 I2C i2c(PTE25, PTE24); // sda, scl 00018 00019 00020 00021 int Time; //time in 10mS 00022 int timer; //Stores timer mode 00023 00024 int main() 00025 { 00026 int count=0; 00027 00028 LED_Launch=1; 00029 00030 wait(0.5); //Allow other IC's to power up 00031 DisplayInit(); 00032 00033 //--------------------------Timer----------------------------- 00034 Time=0; //reset time. 00035 timer=Reset; //Reset timer 00036 t.attach(&DisplayUpdate, 0.01); //Set the timer function as a ticker. 00037 00038 /* 00039 while(1){ 00040 char cmd[4]={1,2,3,4}; 00041 i2c.write(Servo, cmd, 1); 00042 } 00043 */ 00044 00045 //DisplayScroll("dont crash get a badge"); 00046 //timer=Reset; 00047 00048 00049 while(true){ 00050 00051 if(!Button_Launch && timer==Start){ 00052 Time+=1000; 00053 wait(0.2f); 00054 while(!Button_Launch){} 00055 wait(0.2f); 00056 } 00057 00058 if(!Button_Launch && timer==Reset){ 00059 char n='S'; 00060 LED_Launch=0; 00061 wait(1); 00062 00063 if(!Button_Sel1){ 00064 i2c.write(Sound, &n, 1);//Start sound 00065 } 00066 00067 wait(0.5); //Flashing to sync with sound 00068 LED_Launch=1; 00069 DisplayNumber(15,15,3,15,15); 00070 wait(0.5); 00071 LED_Launch=0; 00072 wait(0.5); 00073 LED_Launch=1; 00074 DisplayNumber(15,15,2,15,15); 00075 wait(0.5); 00076 LED_Launch=0; 00077 wait(0.5); 00078 LED_Launch=1; 00079 DisplayNumber(15,15,1,15,15); 00080 wait(0.5); 00081 LED_Launch=0; 00082 wait(0.5); 00083 LED_Launch=1; 00084 timer=Start; //Start the timer 00085 LED_Timer=1; 00086 wait(2); 00087 LED_Launch=0; //Turn off the light 00088 wait(0.2f); 00089 } 00090 00091 if(Button_Reset && (timer==Start)){ 00092 char n='F'; 00093 timer=Pause; 00094 if(!Button_Sel1){ 00095 i2c.write(Sound, &n, 1); //End sound 00096 } 00097 wait(0.1f); 00098 while(Button_Reset){} 00099 LED_Timer=0; 00100 LED_Finish=1; 00101 wait(0.2); 00102 } 00103 00104 if(Button_Reset && (timer==Pause)){ 00105 timer=Reset; 00106 LED_Finish=0; 00107 wait(0.2); 00108 } 00109 00110 if(Camera && (timer==Start)){ 00111 char n='F'; 00112 timer=Pause; 00113 if(!Button_Sel1){ 00114 i2c.write(Sound, &n, 1); //End sound 00115 } 00116 LED_Timer=0; 00117 LED_Finish=1; 00118 wait(0.2); 00119 } 00120 00121 } 00122 00123 }
Generated on Sat Jul 16 2022 20:25:27 by
1.7.2
