Alberto Terrazas / Mbed 2 deprecated Lupe

Dependencies:   mbed

Revision:
1:4fb1de70cd4d
Parent:
0:b47aaa131075
Child:
2:364e8d3f9ee4
--- a/main.cpp	Mon Feb 11 15:28:07 2019 +0000
+++ b/main.cpp	Mon Feb 11 23:01:09 2019 +0000
@@ -17,15 +17,19 @@
 GRIDDLE griddle(GriddlePWMPin,GriddleUpPin,GriddleDownPin,GriddleHomePin);
 OVEN oven(OvenPWMPin);
 MACHINE Lupe(BandPWMPin,TempPin,CapsuleDoorPin,CartridgePin,CuttedPin);
-TORTILLA DesiredProduction();
+TORTILLA tortilla;
 
 #if defined(DEBUG_MODE)
     static Serial pc(USBTX, USBRX);
     int DebugTimer=0;
 #endif
 
+void MANAGER(void);
 void init(void);
-void MANAGER(void);
+void ExtruderProduction(void);
+void CutterProduction(void);
+void GriddleProduction(void);
+void OvenProduction(void);
 
 int STATUS=-1;
 int GENERAL_TIME=0;
@@ -73,18 +77,14 @@
                 #if defined(DEBUG_MODE)
                     pc.printf("\nIDLE Done\r\n");
                 #endif
-                STATUS=PRODUCTION;
+                STATUS=INIT_PRODUCTION;
                 GENERAL_TIME=-1;
                 interface.setLED(1,1,1);
                 interface.setFlash(true);
             }//if
         }//if
-    }else if(STATUS==PRODUCTION){/**********************************PRODUCTION*/
+    }else if(STATUS==INIT_PRODUCTION){/*************************INIT_PRODUCTION*/
         if(GENERAL_TIME==0){//INIT
-            //DesiredProduction= TORTILLA(interface.getTortilla());                
-            #if defined(DEBUG_MODE)
-                pc.printf("\nProduction of %f Tortillas...\r\n",extruder.getPosition());
-            #endif
         }//if
         if(extruder.getSwitch()){//No dough detected
             if(extruder.getTimer()>=500){//Check every 0.5s
@@ -94,20 +94,22 @@
                     pc.printf("\nExtruder finding home on:%f\r\n",extruder.getPosition());
                 #endif
             }//if
-        }else{//Dough detected
-            if((extruder.getTimer()>=5000)&&(extruder.getPosition()>=0.1)){//Check every 5s
-                extruder.setTimer(0);
-                extruder.Step();
-                #if defined(DEBUG_MODE)
-                    pc.printf("\nExtruder position:%f\r\n",extruder.getPosition());
-                #endif
-            }//if
+        }else{
+            extruder.setTimer(0);
+            cutter.setTimer(0);
+            griddle.setTimer(0);
+            oven.setTimer(0);
+            tortilla.setDP(interface.getTortilla());                
+            #if defined(DEBUG_MODE)
+                pc.printf("\nProduction of %f Tortillas...\r\n",extruder.getPosition());
+            #endif
         }//else
-        if(extruder.getPosition()>=0.1){
-            //EXTRUDER_PRODUCTION=true;
-            #if defined(DEBUG_MODE)
-                pc.printf("\nExtruder reached end position\r\n");
-            #endif
+    }else if(STATUS==PRODUCTION){/**********************************PRODUCTION*/
+        if(tortilla.getExtruder()){ExtruderProduction();}
+        if(tortilla.getCutter()){CutterProduction();}
+        if(tortilla.getGriddle()){GriddleProduction();}
+        if(tortilla.getOven()){OvenProduction();}
+        if(!tortilla.getTortilla()){            
             GENERAL_TIME=-1;
             STATUS=HOME;
             interface.setLED(1,1,0);
@@ -137,6 +139,9 @@
     
     /*************************GENERAL OVEN CONTROL*****************************/
     
+    
+    /***********************GENERAL TORITLLA CONTROL***************************/
+    tortilla.check();
     return;
 }//MANAGER
 
@@ -179,4 +184,33 @@
     STATUS=HOME;
     GENERAL_TIME=0;
     return;
-}//init
\ No newline at end of file
+}//init
+
+void ExtruderProduction(void){
+    if((extruder.getTimer()>=5000)&&(extruder.getPosition()>=0.1)){//Check every 5s
+        extruder.setTimer(0);
+        extruder.Step();
+        #if defined(DEBUG_MODE)
+            pc.printf("\nExtruder position:%f\r\n",extruder.getPosition());
+        #endif
+    }//if
+    if(extruder.getPosition()>=0.1){
+        //EXTRUDER_PRODUCTION=true;
+        #if defined(DEBUG_MODE)
+            pc.printf("\nExtruder reached end position\r\n");
+        #endif
+    }//if
+    return;
+}//ExtruderProduction
+
+void CutterProduction(void){
+    return;
+}//CutterProduction
+
+void GriddleProduction(void){
+    return;
+}//GriddleProduction
+
+void OvenProduction(void){
+    return;
+}//OvenProduction
\ No newline at end of file