alison castiblanco

Dependencies:   mbed

Fork of 00_01LAB_matrix8x8_fig_tetris1 by Alyson Castiblanco

Revision:
8:0ddb5ffca870
Parent:
7:0a94835bc6e4
Child:
9:f6536806c250
--- a/main.cpp	Thu Sep 13 11:54:25 2018 +0000
+++ b/main.cpp	Thu Sep 13 13:02:21 2018 +0000
@@ -25,7 +25,16 @@
     deviceM.lock();
 };
 
-
+void imp_fig(){
+    int i=0;
+    for(i=0;i<=8;i++){
+        sendSPI(i-2,0);
+        sendSPI(i-1,matrix_tmp[0]);
+        sendSPI(i,matrix_tmp[1]);
+        sendSPI(i+1,matrix_tmp[2]);
+        wait_ms(VELOCITY);
+        }
+    }
 
 
 void debug_m(char *s , ... ){
@@ -118,64 +127,467 @@
             }
             break;
             case ZERO:
-            copy_matrix(FIG_L,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_L,1);
+             break;
+             case 2:
+             copy_matrix(FIG_L,2);
+             break;
+             case 3:
+             copy_matrix(FIG_L,3);
+             break;
+             case 4:
+             copy_matrix(FIG_L,4);
+             break;
+             case 5:
+             copy_matrix(FIG_L,5);
+             break;
+             case 6:
+             copy_matrix(FIG_L,6);
+             break;
+             case 7:
+             copy_matrix(FIG_L,7);
+             break;
+             case 8:
+             copy_matrix(FIG_L,8);
+             break;
+            }
+            
         break ; 
         case PII:
-            copy_matrix(FIG_L2,1);
+            
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_L2,1);
+             break;
+             case 2:
+             copy_matrix(FIG_L2,2);
+             break;
+             case 3:
+             copy_matrix(FIG_L2,3);
+             break;
+             case 4:
+             copy_matrix(FIG_L2,4);
+             break;
+             case 5:
+             copy_matrix(FIG_L2,5);
+             break;
+             case 6:
+             copy_matrix(FIG_L2,6);
+             break;
+             case 7:
+             copy_matrix(FIG_L2,7);
+             break;
+             case 8:
+             copy_matrix(FIG_L2,8);
+             break;
+            }
             break;
             case DOSSE:
-            copy_matrix(FIG_L3,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_L3,1);
+             break;
+             case 2:
+             copy_matrix(FIG_L3,2);
+             break;
+             case 3:
+             copy_matrix(FIG_L3,3);
+             break;
+             case 4:
+             copy_matrix(FIG_L3,4);
+             break;
+             case 5:
+             copy_matrix(FIG_L3,5);
+             break;
+             case 6:
+             copy_matrix(FIG_L3,6);
+             break;
+             case 7:
+             copy_matrix(FIG_L3,7);
+             break;
+             case 8:
+             copy_matrix(FIG_L3,8);
+             break;
+            }
             break; 
         }
                 break ;     
     case  S_TYPE: 
         switch (ang)
          {  case NOVEN:
-            copy_matrix(FIG_S1,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_S1,1);
+             break;
+             case 2:
+             copy_matrix(FIG_S1,2);
+             break;
+             case 3:
+             copy_matrix(FIG_S1,3);
+             break;
+             case 4:
+             copy_matrix(FIG_S1,4);
+             break;
+             case 5:
+             copy_matrix(FIG_S1,5);
+             break;
+             case 6:
+             copy_matrix(FIG_S1,6);
+             break;
+             case 7:
+             copy_matrix(FIG_S1,7);
+             break;
+             case 8:
+             copy_matrix(FIG_S1,8);
+             break;
+            }
             break;
             case ZERO:
-            copy_matrix(FIG_S,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_S,1);
+             break;
+             case 2:
+             copy_matrix(FIG_S,2);
+             break;
+             case 3:
+             copy_matrix(FIG_S,3);
+             break;
+             case 4:
+             copy_matrix(FIG_S,4);
+             break;
+             case 5:
+             copy_matrix(FIG_S,5);
+             break;
+             case 6:
+             copy_matrix(FIG_S,6);
+             break;
+             case 7:
+             copy_matrix(FIG_S,7);
+             break;
+             case 8:
+             copy_matrix(FIG_S,8);
+             break;
+            }
         break ; 
         case PII:
-            copy_matrix(FIG_S2,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_S2,1);
+             break;
+             case 2:
+             copy_matrix(FIG_S2,2);
+             break;
+             case 3:
+             copy_matrix(FIG_S2,3);
+             break;
+             case 4:
+             copy_matrix(FIG_S2,4);
+             break;
+             case 5:
+             copy_matrix(FIG_S2,5);
+             break;
+             case 6:
+             copy_matrix(FIG_S2,6);
+             break;
+             case 7:
+             copy_matrix(FIG_S2,7);
+             break;
+             case 8:
+             copy_matrix(FIG_S2,8);
+             break;
+            }
             break;
             case DOSSE:
-            copy_matrix(FIG_S3,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_S3,1);
+             break;
+             case 2:
+             copy_matrix(FIG_S3,2);
+             break;
+             case 3:
+             copy_matrix(FIG_S3,3);
+             break;
+             case 4:
+             copy_matrix(FIG_S3,4);
+             break;
+             case 5:
+             copy_matrix(FIG_S3,5);
+             break;
+             case 6:
+             copy_matrix(FIG_S3,6);
+             break;
+             case 7:
+             copy_matrix(FIG_S3,7);
+             break;
+             case 8:
+             copy_matrix(FIG_S3,8);
+             break;
+            }
             break; 
         }
         break ;     
     case  I_TYPE: 
         switch (ang)
-         {  case NOVEN:
-            copy_matrix(FIG_I1,1);
+         {  
+         case NOVEN:
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_I1,1);
+             break;
+             case 2:
+             copy_matrix(FIG_I1,2);
+             break;
+             case 3:
+             copy_matrix(FIG_I1,3);
+             break;
+             case 4:
+             copy_matrix(FIG_I1,4);
+             break;
+             case 5:
+             copy_matrix(FIG_I1,5);
+             break;
+             case 6:
+             copy_matrix(FIG_I1,6);
+             break;
+             case 7:
+             copy_matrix(FIG_I1,7);
+             break;
+             case 8:
+             copy_matrix(FIG_I1,8);
+             break;
+            }
             break;
             case ZERO:
-            copy_matrix(FIG_I,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_I,1);
+             break;
+             case 2:
+             copy_matrix(FIG_I,2);
+             break;
+             case 3:
+             copy_matrix(FIG_I,3);
+             break;
+             case 4:
+             copy_matrix(FIG_I,4);
+             break;
+             case 5:
+             copy_matrix(FIG_I,5);
+             break;
+             case 6:
+             copy_matrix(FIG_I,6);
+             break;
+             case 7:
+             copy_matrix(FIG_I,7);
+             break;
+             case 8:
+             copy_matrix(FIG_I,8);
+             break;
+            }
         break ; 
         case PII:
-            copy_matrix(FIG_I2,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_I2,1);
+             break;
+             case 2:
+             copy_matrix(FIG_I2,2);
+             break;
+             case 3:
+             copy_matrix(FIG_I2,3);
+             break;
+             case 4:
+             copy_matrix(FIG_I2,4);
+             break;
+             case 5:
+             copy_matrix(FIG_I2,5);
+             break;
+             case 6:
+             copy_matrix(FIG_I2,6);
+             break;
+             case 7:
+             copy_matrix(FIG_I2,7);
+             break;
+             case 8:
+             copy_matrix(FIG_I2,8);
+             break;
+            }
             break;
             case DOSSE:
-            copy_matrix(FIG_I3,1);
-            break; 
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_I3,1);
+             break;
+             case 2:
+             copy_matrix(FIG_I3,2);
+             break;
+             case 3:
+             copy_matrix(FIG_I3,3);
+             break;
+             case 4:
+             copy_matrix(FIG_I3,4);
+             break;
+             case 5:
+             copy_matrix(FIG_I3,5);
+             break;
+             case 6:
+             copy_matrix(FIG_I3,6);
+             break;
+             case 7:
+             copy_matrix(FIG_I3,7);
+             break;
+             case 8:
+             copy_matrix(FIG_I3,8);
+             break;
+            }
+            break;
         }
         break ;     
     case  C_TYPE: 
-        copy_matrix(FIG_C,1);
+        switch(col)
+             {case 1:
+             copy_matrix(FIG_C,1);
+             break;
+             case 2:
+             copy_matrix(FIG_C,2);
+             break;
+             case 3:
+             copy_matrix(FIG_C,3);
+             break;
+             case 4:
+             copy_matrix(FIG_C,4);
+             break;
+             case 5:
+             copy_matrix(FIG_C,5);
+             break;
+             case 6:
+             copy_matrix(FIG_C,6);
+             break;
+             case 7:
+             copy_matrix(FIG_C,7);
+             break;
+             case 8:
+             copy_matrix(FIG_C,8);
+             break;
+            }
         break ; 
     case  T_TYPE:
          switch (ang)
          {  case NOVEN:
-            copy_matrix(FIG_T1,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_T1,1);
+             break;
+             case 2:
+             copy_matrix(FIG_T1,2);
+             break;
+             case 3:
+             copy_matrix(FIG_T1,3);
+             break;
+             case 4:
+             copy_matrix(FIG_T1,4);
+             break;
+             case 5:
+             copy_matrix(FIG_T1,5);
+             break;
+             case 6:
+             copy_matrix(FIG_T1,6);
+             break;
+             case 7:
+             copy_matrix(FIG_T1,7);
+             break;
+             case 8:
+             copy_matrix(FIG_T1,8);
+             break;
+            }
             break;
             case ZERO:
-            copy_matrix(FIG_T,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_T,1);
+             break;
+             case 2:
+             copy_matrix(FIG_T,2);
+             break;
+             case 3:
+             copy_matrix(FIG_T,3);
+             break;
+             case 4:
+             copy_matrix(FIG_T,4);
+             break;
+             case 5:
+             copy_matrix(FIG_T,5);
+             break;
+             case 6:
+             copy_matrix(FIG_T,6);
+             break;
+             case 7:
+             copy_matrix(FIG_T,7);
+             break;
+             case 8:
+             copy_matrix(FIG_T,8);
+             break;
+            }
         break ; 
         case PII:
-            copy_matrix(FIG_T2,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_T2,1);
+             break;
+             case 2:
+             copy_matrix(FIG_T2,2);
+             break;
+             case 3:
+             copy_matrix(FIG_T2,3);
+             break;
+             case 4:
+             copy_matrix(FIG_T2,4);
+             break;
+             case 5:
+             copy_matrix(FIG_T2,5);
+             break;
+             case 6:
+             copy_matrix(FIG_T2,6);
+             break;
+             case 7:
+             copy_matrix(FIG_T2,7);
+             break;
+             case 8:
+             copy_matrix(FIG_T2,8);
+             break;
+            }
             break;
             case DOSSE:
-            copy_matrix(FIG_T3,1);
+            switch(col)
+             {case 1:
+             copy_matrix(FIG_T3,1);
+             break;
+             case 2:
+             copy_matrix(FIG_T3,2);
+             break;
+             case 3:
+             copy_matrix(FIG_T3,3);
+             break;
+             case 4:
+             copy_matrix(FIG_T3,4);
+             break;
+             case 5:
+             copy_matrix(FIG_T3,5);
+             break;
+             case 6:
+             copy_matrix(FIG_T3,6);
+             break;
+             case 7:
+             copy_matrix(FIG_T3,7);
+             break;
+             case 8:
+             copy_matrix(FIG_T3,8);
+             break;
+            }
             break; 
         }
         break;
@@ -194,22 +606,16 @@
     
     }
 
-
 int main() {
     init_display();
     while(1){
        new_read();
            for(int i=0;i<8;i++){
             act_matrix(matrix_tmp);
-            printMatrix(matrix_act);
-            for (int j=0;j<8;j++){
-             matrix_act[j+3]=matrix_act[j+2];
-             matrix_act[j+2]=matrix_act[j+1];
-             matrix_act[j]=0;
-        
+            imp_fig();
+            //printMatrix(matrix_act);
             //desplazar_fila();
-            wait_ms(VELOCITY);
-       }  
+            
        
         }   
        }