EasyCAT LAB - EtherCAT master legacy example

Dependencies:   SOEM SPI_STMPE610 SPI_TFT_ILI9341 TFT_fonts

The EasyCAT LAB is a complete educational and experimental EtherCAT® system, composed of one master and two slaves .

/media/uploads/EasyCAT/easycat_lab.jpg

/media/uploads/EasyCAT/components.jpg

Revision:
2:7d4fd6354015
Parent:
0:7077d8f28b3e
Child:
3:6ee00ee90d4c
diff -r 665b62862f15 -r 7d4fd6354015 main.cpp
--- a/main.cpp	Tue Jun 11 10:35:44 2019 +0000
+++ b/main.cpp	Tue Jun 11 10:46:17 2019 +0000
@@ -129,25 +129,6 @@
 #define TIME_REP_SEG 300
 #define TIME_POTENTIOMETER 100
 
-/*
-//---- slave 3 parameters - EL2004 ---------------------------------------------
-
-#define OUT_X 0                     
-#define OUT_Y 65                     
-#define OUT_WIDTH 42                
-#define OUT_HEIGHT 42               
-#define OUT_STEP 60                     
-
-
-//---- slave 4 parameters - EL1014 ---------------------------------------------
-
-#define INPUTS_X 12
-#define INPUTS_Y 84 
-#define INPUTS_WIDTH 26
-#define INPUTS_R 3
-#define INPUTS_STEP 60 
-*/
-
 
 //---- local functions ---------------------------------------------------------
 
@@ -165,11 +146,6 @@
 void DrawSegmentsValue(uint8_t Value);
 void DrawPotentiometerValue(uint16_t PotValue);
 
-void DrawOutputsValue(uint8_t Value);
-
-void DrawInputsValue(uint8_t Value);
-
-
 
 float ReadAnalog(AnalogIn Ana);
 
@@ -584,70 +560,7 @@
                                                             
                                                                     //----- end LAB_2 ------------------------                                                                        
                                                                           
-    
-    /*
-                                                                    //----- slave 3 EL2004 data management -----  
-                                                                
-        if (Outputs != PrevOutputs)                                 // check if the outputs value has changed
-        {                                                           
-            PrevOutputs = Outputs;                                  // remember the current outputs value 
-            
-            if (VisuSlave == EL2004)                                // if the HMI is setted to slave 3
-            {                                                       //    
-                DrawOutputsValue(Outputs);                          // draw the current Outputs value                                                                                              
-            }                                                       //            
-        }
-               
-        if (VisuSlave == EL2004 && FirstRound)                      // if the HMI is set to slave 3                                                        
-        {                                                           // and it is the first time 
-            FirstRound = false;                                     //                
-                                                                    //       
-            DrawOutputsValue(Outputs);                              // draw the current Outputs value            
-        }    
-                    
-        if (Outputs & 0x01)                                         // send the Outputs status to the slave        
-            out_EL2004->Out_0 = 1;                                  //   
-        else                                                        //        
-            out_EL2004->Out_0 = 0;                                  //
-        if (Outputs & 0x02)                                         //
-            out_EL2004->Out_1 = 1;                                  //
-        else                                                        //
-            out_EL2004->Out_1 = 0;                                  //
-        if (Outputs & 0x04)                                         //
-            out_EL2004->Out_2 = 1;                                  //
-        else                                                        //
-            out_EL2004->Out_2 = 0;                                  //
-        if (Outputs & 0x08)                                         //
-            out_EL2004->Out_3 = 1;                                  //
-        else                                                        //
-            out_EL2004->Out_3 = 0;                                  //
-        
-                                                                    //----- end EL2004 -----------------------               
-              
-            
-                                                                    //----- slave 4 EL1014 data management -----              
-        Inputs = 0;
-        if (in_EL1014->In_0)                                        // read the inputs status from the slave 
-            Inputs |= 0x01;                                         //                
-        if (in_EL1014->In_1)                                        //      
-            Inputs |= 0x02;                                         //    
-        if (in_EL1014->In_2)                                        //
-            Inputs |= 0x04;                                         //
-        if (in_EL1014->In_3)                                        //
-            Inputs |= 0x08;                                         //     
-                   
-        if (Inputs != PrevInputs)                                   // check if the inputs value has changed
-        {
-            PrevInputs = Inputs;                                    // remember the current inputs value  
-            
-            if (VisuSlave == EL1014)                                // if the HMI is setted to slave 4
-            {                                                       //    
-                DrawInputsValue(Inputs);                            // draw the current inputs value                                                                                              
-            }                                                       //
-        }                                               
-                                                                    //----- end EL1014 -----------------------         
-    */               
-            
+                
         TouchScreenManagement();                                    // check if the touchscreen is tapped 
                                                                     // and handle it       
         
@@ -810,28 +723,6 @@
                     }                                               //
                 }                                                       
             break;              //----------------- end slave 2 ----------------                          
-
-      
- /*       
-            case (EL2004):     //-------------- slave 3 EL2004 ----------------        
-        
-        
-                if(TouchWasReleased)                                // first check if the touch was
-                {                                                   // not tapped in the previous rounds  
-                    TouchWasReleased = false;                       // because for the following fields
-                    TimeTouchReleased = SysMilliS();                // we don't want autorepeat
-                    
-                    uint8_t Mask = 0x08;                            // check if one of the output is tapped
-                                                                    //
-                    for (i=0; i<4; i++)                             //
-                    {                                               //        
-                        if ((X>OUT_X+(i*OUT_STEP)) && (X<OUT_X+(i*OUT_STEP)+OUT_WIDTH) && (Y>OUT_Y) && (Y<OUT_Y+OUT_HEIGHT))                
-                        {                                           //
-                            Outputs ^= Mask >> i;                   //
-                        }                                           //  
-                    }                                               //
-                }  
-*/                                                                                                  
         }             
     }
     
@@ -958,58 +849,7 @@
             DrawSegmentsValue(Segments);                            // draw the segments status 
             DrawButtonsValue (Buttons);                             // draw the buttons status  
             DrawPotentiometerValue(PotValue);                       // draw the potentiometer value                  
-        break;     
-
-/*
-        case (EK1100):     //-------------- slave 3 EK1100 --------------------
-
-            TFT.foreground(Red);   
-            TFT.set_font((unsigned char*) Arial12x12);
-            TFT.locate(0, MENU_Y+(MENU_HEIGHT*2)+12);
-
-            TFT.printf("This slave has no Input/Output:");
-
-        break;
-
-     
-        case (EL2004):     //-------------- slave 4 EL2004 --------------------
-                
-            TFT.foreground(Yellow);   
-
-            for (i=0; i<4; i++)                                     // draw the outputs fixed parts
-            {                                                       //
-                TFT.rect(OUT_X+(i*OUT_STEP), OUT_Y, OUT_X+OUT_WIDTH+(i*OUT_STEP), OUT_Y+OUT_HEIGHT, Yellow);                            
-                                                                    //
-                TFT.set_font((unsigned char*) Arial12x12);          // 
-                TFT.locate(OUT_X+45, OUT_Y+OUT_HEIGHT+40);          // 
-                TFT.printf("DIGITAL OUTPUTS");                      //
-            }                                                       //
-            
-            DrawOutputsValue(Outputs);                              // draw the outputs status           
-        break;           
-        
-        case (EL1014):     //-------------- slave 5 EL1014 --------------------
-                   
-            TFT.foreground(Yellow);   
-
-               
-            for (i=0; i<4; i++)                                     // draw the inputs fixed parts        
-            {                                                       //    
-                TFT.circle(INPUTS_X+(i*INPUTS_STEP), INPUTS_Y, INPUTS_R, Red);                
-                TFT.circle(INPUTS_X+INPUTS_WIDTH+(i*INPUTS_STEP), INPUTS_Y, INPUTS_R, Red); 
-                                                                    //
-                TFT.line(INPUTS_X+(i*INPUTS_STEP)-INPUTS_R, INPUTS_Y, INPUTS_X+(i*INPUTS_STEP)-INPUTS_R-4, INPUTS_Y, Red);  
-                TFT.line(INPUTS_X+INPUTS_WIDTH+(i*INPUTS_STEP)+INPUTS_R, INPUTS_Y, INPUTS_X+INPUTS_WIDTH+(i*INPUTS_STEP)+INPUTS_R+4 , INPUTS_Y, Red);                          
-            }                                                       //
-                                                                    //   
-            TFT.set_font((unsigned char*) Arial12x12);              // 
-            TFT.locate(INPUTS_X+45, INPUTS_Y+40);                   // 
-            TFT.printf("DIGITAL INPUTS");                           //               
-
-            DrawInputsValue (Inputs);                               // draw the inputs status               
-        break;      
-*/       
-                          
+        break;                               
     }    
     
     FirstRound = true;                
@@ -1302,55 +1142,6 @@
 }
 
 
-//****** slave 3 functions EL2004 **********************************************
-/*
-
-//------------------------------------------------------------------------------
-
-void DrawOutputsValue(uint8_t Value)
-{
-    int i;
-    int Color;
-   
-    for (i=0; i<4; i++)
-    {
-        if ((Value & 0x08) == 0x08)
-            Color = Green;
-        else
-            Color = Black;    
-        
-        TFT.fillrect(OUT_X+(i*OUT_STEP)+1, OUT_Y+1, OUT_X+OUT_WIDTH+(i*OUT_STEP)-1, OUT_Y+OUT_HEIGHT-1, Color);   
-    
-        Value = Value << 1;   
-    } 
-}    
-
-//****** slave 4 functions *****************************************************
-
-//------------------------------------------------------------------------------
-
-void DrawInputsValue (uint8_t Value)
-{
-    uint8_t Slope;
-    int i;
-  
-    for (i=0; i<4; i++)
-    {
-        if ((Value & 0x08) == 0x08)
-            Slope = INPUTS_R;
-        else
-            Slope = 16;          
-    
-        TFT.fillrect(INPUTS_X+(i*INPUTS_STEP), INPUTS_Y-16-1, INPUTS_X+INPUTS_WIDTH+(i*INPUTS_STEP), INPUTS_Y-INPUTS_R-1, Black);
-    
-        TFT.line(INPUTS_X+(i*INPUTS_STEP), INPUTS_Y-INPUTS_R-1, INPUTS_X+INPUTS_WIDTH+(i*INPUTS_STEP), INPUTS_Y-Slope-1, Red); 
-
-        Value = Value << 1;    
-    } 
-}    
-*/
-
-
 //****** touchscreen functions *************************************************
 
 //----- read touchscreen status ------------------------------------------------