Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
INTERFACE.cpp
00001 #include "mbed.h" 00002 #include "INTERFACE.h" 00003 00004 INTERFACE::INTERFACE(PinName Button,PinName Red,PinName Green,PinName Blue,PinName TortillaPin,PinName TempReady): 00005 Start(Button,PullUp), 00006 StartRED(Red,0), 00007 StartGREEN(Green,0), 00008 StartBLUE(Blue,0), 00009 Tortilla(TortillaPin), 00010 TempLED(TempReady,0), 00011 NXP_LED1(LED1,0), 00012 NXP_LED2(LED2,0), 00013 NXP_LED3(LED3,0), 00014 NXP_LED4(LED4,0){ 00015 //Led Memory 00016 redState=0; 00017 greenState=0; 00018 blueState=0; 00019 //Flasher control 00020 FlashTimer=0; 00021 Flash=true; 00022 StartLatch=Start.read(); 00023 //Start Button 00024 StartTimer=0; 00025 return; 00026 }//Constructor 00027 00028 void INTERFACE::Init(){ 00029 setLED(1,1,0); 00030 TempLED=0; 00031 FlashTimer=0; 00032 Flash=true; 00033 return; 00034 }//Init 00035 00036 void INTERFACE::Home(){ 00037 setLED(1,1,0); 00038 TempLED=0; 00039 FlashTimer=0; 00040 Flash=true; 00041 return; 00042 }//Home 00043 00044 bool INTERFACE::getStart(void){ 00045 if(StartLatch!=Start.read()) 00046 return true; 00047 else 00048 return false; 00049 }//getStart 00050 00051 int INTERFACE::getFlashTimer(){ 00052 return FlashTimer; 00053 }//getTimer 00054 00055 void INTERFACE::setFlashTimer(int t){ 00056 FlashTimer=t; 00057 return; 00058 }//setTimer 00059 00060 bool INTERFACE::getFlash(void){ 00061 return Flash; 00062 }//getFlash 00063 00064 void INTERFACE::setFlash(bool state){ 00065 Flash=state; 00066 FlashTimer=0; 00067 return; 00068 }//setFlash 00069 00070 void INTERFACE::setLED(int r,int g,int b){ 00071 StartRED=0; 00072 StartGREEN=0; 00073 StartBLUE=0; 00074 if(r>0) 00075 StartRED=1; 00076 if(g>0) 00077 StartGREEN=1; 00078 if(b>0) 00079 StartBLUE=1; 00080 redState=StartRED; 00081 greenState=StartGREEN; 00082 blueState=StartBLUE; 00083 return; 00084 }//setLED 00085 00086 void INTERFACE::flash(){ 00087 if(FlashTimer==FLASH_TIME){ 00088 FlashTimer=0; 00089 if(Flash){ 00090 if(redState) 00091 StartRED=!StartRED; 00092 if(greenState) 00093 StartGREEN=!StartGREEN; 00094 if(blueState) 00095 StartBLUE=!StartBLUE; 00096 }else{ 00097 StartRED=redState; 00098 StartGREEN=greenState; 00099 StartBLUE=blueState; 00100 }//else 00101 }else 00102 FlashTimer++; 00103 NXP_LED1=StartRED; 00104 NXP_LED2=StartGREEN; 00105 NXP_LED3=StartBLUE; 00106 return; 00107 }//flash 00108 00109 void INTERFACE::check(void){ 00110 flash(); 00111 if(StartTimer<SENSOR_TIME) 00112 StartTimer++; 00113 else{ 00114 StartTimer=0; 00115 StartLatch=Start.read(); 00116 }//else 00117 }//check 00118 00119 int INTERFACE::getTortilla(){ 00120 int DesiredProducction; 00121 if(Tortilla.read()<=0.2) 00122 DesiredProducction=TORTILLA_NO_5; 00123 else if((Tortilla.read()>0.2)&&(Tortilla.read()<=0.4)) 00124 DesiredProducction=TORTILLA_NO_4; 00125 else if((Tortilla.read()>0.4)&&(Tortilla.read()<=0.6)) 00126 DesiredProducction=TORTILLA_NO_3; 00127 else if((Tortilla.read()>0.6)&&(Tortilla.read()<=0.8)) 00128 DesiredProducction=TORTILLA_NO_2; 00129 else if((Tortilla.read()>0.8)&&(Tortilla.read()<=1)) 00130 DesiredProducction=TORTILLA_NO_1; 00131 else 00132 DesiredProducction=1; 00133 return DesiredProducction; 00134 }//getTimer
Generated on Wed Jul 20 2022 02:15:49 by
1.7.2