ok

Dependencies:   mbed

Fork of 00_01LAB_matrix8x8_fig_tetris1 by Andres Cano

Files at this revision

API Documentation at this revision

Comitter:
acastiblancoc
Date:
Thu Oct 04 04:34:17 2018 +0000
Parent:
10:ae8cf84c82ca
Commit message:
ok;

Changed in this revision

figuras.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r ae8cf84c82ca -r edb5ee477f00 figuras.h
--- a/figuras.h	Thu Sep 13 20:53:12 2018 +0000
+++ b/figuras.h	Thu Oct 04 04:34:17 2018 +0000
@@ -31,9 +31,9 @@
  uint8_t FIG_L3[11]={0b10000000,0b11100000,0,0,0,0,0,0,0,0,0};
  uint8_t FIG_L2[11]={0b11000000,0b01000000,0b01000000,0,0,0,0,0,0,0};
  uint8_t FIG_I [11]={0b10000000,0b10000000,0b10000000,0,0,0,0,0,0,0};
- uint8_t FIG_I1[11]={0b11100000,0,0,0,0,0,0,0,0,0};
+ uint8_t FIG_I1[11]={0,0b11100000,0,0,0,0,0,0,0,0};
  uint8_t FIG_I2[11]={0b10000000,0b10000000,0b10000000,0,0,0,0,0,0,0};
- uint8_t FIG_I3[11]={0b11100000,0,0,0,0,0,0,0,0,0,0};
+ uint8_t FIG_I3[11]={0,0b11100000,0,0,0,0,0,0,0,0,0};
  uint8_t FIG_S [11]={0b01100000,0b11000000,0,0,0,0,0,0,0,0,0};
  uint8_t FIG_S1[11]={0b10000000,0b11000000,0b01000000,0,0,0,0,0,0,0};
  uint8_t FIG_S3[11]={0b10000000,0b11000000,0b01000000,0,0,0,0,0,0,0};
diff -r ae8cf84c82ca -r edb5ee477f00 main.cpp
--- a/main.cpp	Thu Sep 13 20:53:12 2018 +0000
+++ b/main.cpp	Thu Oct 04 04:34:17 2018 +0000
@@ -14,7 +14,7 @@
 uint8_t matrix_act[8]={0,0,0,0,0,0,0,0};
 uint8_t matrix_tmp[11]={0b00000000,0b00000000,0b00000000,0,0,0,0,0,0,0};
 uint8_t array[3]={0,0,0};
-
+int lim=0;
 void debug_m(char *s , ... ){
     #if DEBUG
     command.printf(s);
@@ -57,7 +57,7 @@
 
 void imp_fig(){
     int i=0;
-    for(i=0;i<=8;i++){
+    for(i=0;i<=lim;i++){
         sendSPI(i-2,0);
         sendSPI(i-1,matrix_tmp[0]);
         sendSPI(i,matrix_tmp[1]);
@@ -96,11 +96,21 @@
 
 
  
-void act_matrix(uint8_t*  mascara){ 
+ 
+void act_matrix(uint8_t*  mascara){
+    int newm[8]={0,0,0,0,0,0,0,0}; 
+        for (int i=0; i<8;i++)
+    {   
+        newm[i]=mascara[i]| matrix_act[i];
+        matrix_act[i]=  ( *(newm+i));
+     }  
     for (int i=0; i<8;i++)
-        matrix_act[i]=  ( *(mascara+i));
+    {   
+        newm[i]=mascara[i]| matrix_act[i];
+     }   
  
  } 
+ 
  void copy_matrix(uint8_t*  m2, char col){
   
     for (int i=0; i<11;i++){
@@ -114,7 +124,8 @@
     switch (array[0]) {
     case  L_TYPE: 
     switch (array[1])
-         {  case NOVEN:
+         {  case NOVEN: 
+         lim=8;
              switch(array[2])
              {case 1:
              copy_matrix(FIG_L1,1);
@@ -135,14 +146,15 @@
              copy_matrix(FIG_L1,6);
              break;
              case 7:
-             copy_matrix(FIG_L1,7);
+             copy_matrix(FIG_L1,6);
              break;
              case 8:
-             copy_matrix(FIG_L1,8);
+             copy_matrix(FIG_L1,6);
              break;
             }
             break;
             case ZERO:
+            lim=7;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_L,1);
@@ -166,13 +178,13 @@
              copy_matrix(FIG_L,7);
              break;
              case 8:
-             copy_matrix(FIG_L,8);
+             copy_matrix(FIG_L,7);
              break;
             }
             
         break ; 
         case PII:
-            
+            lim=7;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_L2,1);
@@ -196,11 +208,12 @@
              copy_matrix(FIG_L2,7);
              break;
              case 8:
-             copy_matrix(FIG_L2,8);
+             copy_matrix(FIG_L2,7);
              break;
             }
             break;
             case DOSSE:
+            lim=8;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_L3,1);
@@ -221,10 +234,10 @@
              copy_matrix(FIG_L3,6);
              break;
              case 7:
-             copy_matrix(FIG_L3,7);
+             copy_matrix(FIG_L3,6);
              break;
              case 8:
-             copy_matrix(FIG_L3,8);
+             copy_matrix(FIG_L3,6);
              break;
             }
             break; 
@@ -233,6 +246,7 @@
     case  S_TYPE: 
         switch (array[1])
          {  case NOVEN:
+         lim=7;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_S1,1);
@@ -256,11 +270,12 @@
              copy_matrix(FIG_S1,7);
              break;
              case 8:
-             copy_matrix(FIG_S1,8);
+             copy_matrix(FIG_S1,7);
              break;
             }
             break;
             case ZERO:
+            lim=8;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_S,1);
@@ -281,14 +296,15 @@
              copy_matrix(FIG_S,6);
              break;
              case 7:
-             copy_matrix(FIG_S,7);
+             copy_matrix(FIG_S,6);
              break;
              case 8:
-             copy_matrix(FIG_S,8);
+             copy_matrix(FIG_S,6);
              break;
             }
         break ; 
         case PII:
+        lim=8;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_S2,1);
@@ -309,14 +325,15 @@
              copy_matrix(FIG_S2,6);
              break;
              case 7:
-             copy_matrix(FIG_S2,7);
+             copy_matrix(FIG_S2,6);
              break;
              case 8:
-             copy_matrix(FIG_S2,8);
+             copy_matrix(FIG_S2,6);
              break;
             }
             break;
             case DOSSE:
+            lim=7;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_S3,1);
@@ -340,7 +357,7 @@
              copy_matrix(FIG_S3,7);
              break;
              case 8:
-             copy_matrix(FIG_S3,8);
+             copy_matrix(FIG_S3,7);
              break;
             }
             break; 
@@ -350,6 +367,7 @@
         switch (array[1])
          {  
          case NOVEN:
+         lim=8;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_I1,1);
@@ -370,14 +388,15 @@
              copy_matrix(FIG_I1,6);
              break;
              case 7:
-             copy_matrix(FIG_I1,7);
+             copy_matrix(FIG_I1,6);
              break;
              case 8:
-             copy_matrix(FIG_I1,8);
+             copy_matrix(FIG_I1,6);
              break;
             }
             break;
             case ZERO:
+            lim=7; 
             switch(array[2])
              {case 1:
              copy_matrix(FIG_I,1);
@@ -406,6 +425,7 @@
             }
         break ; 
         case PII:
+        lim=7;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_I2,1);
@@ -434,6 +454,7 @@
             }
             break;
             case DOSSE:
+            lim=8;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_I3,1);
@@ -454,16 +475,17 @@
              copy_matrix(FIG_I3,6);
              break;
              case 7:
-             copy_matrix(FIG_I3,7);
+             copy_matrix(FIG_I3,6);
              break;
              case 8:
-             copy_matrix(FIG_I3,8);
+             copy_matrix(FIG_I3,6);
              break;
             }
             break;
         }
         break ;     
     case  C_TYPE: 
+        lim=8;
         switch(array[2])
              {case 1:
              copy_matrix(FIG_C,1);
@@ -494,6 +516,7 @@
     case  T_TYPE:
          switch (array[1])
          {  case NOVEN:
+         lim=7;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_T1,1);
@@ -517,11 +540,12 @@
              copy_matrix(FIG_T1,7);
              break;
              case 8:
-             copy_matrix(FIG_T1,8);
+             copy_matrix(FIG_T1,7);
              break;
             }
             break;
             case ZERO:
+            lim=8;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_T,1);
@@ -542,14 +566,15 @@
              copy_matrix(FIG_T,6);
              break;
              case 7:
-             copy_matrix(FIG_T,7);
+             copy_matrix(FIG_T,6);
              break;
              case 8:
-             copy_matrix(FIG_T,8);
+             copy_matrix(FIG_T,6);
              break;
             }
         break ; 
         case PII:
+        lim=8;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_T2,1);
@@ -570,14 +595,15 @@
              copy_matrix(FIG_T2,6);
              break;
              case 7:
-             copy_matrix(FIG_T2,7);
+             copy_matrix(FIG_T2,6);
              break;
              case 8:
-             copy_matrix(FIG_T2,8);
+             copy_matrix(FIG_T2,6);
              break;
             }
             break;
             case DOSSE:
+            lim=7;
             switch(array[2])
              {case 1:
              copy_matrix(FIG_T3,1);
@@ -601,7 +627,7 @@
              copy_matrix(FIG_T3,7);
              break;
              case 8:
-             copy_matrix(FIG_T3,8);
+             copy_matrix(FIG_T3,7);
              break;
             }
             break;