ProjectBattleShip_FRA221 / WolfWarp
Revision:
2:777a5a5dadca
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EnterTheGame.cpp	Sun Dec 04 11:58:33 2016 +0000
@@ -0,0 +1,331 @@
+#include "mbed.h"
+//************************ Complete to Interface ***************************
+// configure library with this code ****************************************
+SPI dot_matrix(D11,NC,D13); //mosi miso sclk
+DigitalOut lat(PA_12); //6
+DigitalOut sb(PA_11); //7
+DigitalOut rst(D10);
+BusOut open_line(D2,D3,D4,D5,D6,D7,D8,D9);
+              //c0 c1 c2 c3 c4 c5 c6 c7 dont foget d7
+Serial pc(D1, D0);
+Timer t;
+
+int counter;
+int click = 0;
+int swap = 0;
+int downter = 60;
+uint8_t rgb[3] = {0,0,0};
+
+
+int main(){
+
+  dot_matrix.frequency(1000000);
+  // dot_matrix.format(6,0);
+  uint8_t wb[3] = {255,255,255};
+  uint8_t pic[130][8] = {
+  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00},
+  {0xff,0x80,0x80,0x00,0x00,0x00,0x00,0x00},
+  {0xff,0x80,0x80,0x00,0x00,0x00,0x00,0x00},
+  {0xff,0x80,0x80,0x80,0x00,0x00,0x00,0x00},
+  {0xff,0x80,0x80,0x80,0x00,0x00,0x00,0x00},
+  {0xff,0x80,0x80,0x80,0x80,0x00,0x00,0x00},
+  {0xff,0x80,0x80,0x80,0x80,0x00,0x00,0x00},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x00,0x00},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x00},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x00},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xc0},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xc0},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xe0},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xe0},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf0},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf0},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf8},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf8},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfc},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfc},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfe},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfe},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xff},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xff},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x81,0xff},
+  {0xff,0x80,0x80,0x80,0x80,0x80,0x81,0xff},
+  {0xff,0x80,0x80,0x80,0x80,0x81,0x81,0xff},
+  {0xff,0x80,0x80,0x80,0x80,0x81,0x81,0xff},
+  {0xff,0x80,0x80,0x80,0x81,0x81,0x81,0xff},
+  {0xff,0x80,0x80,0x80,0x81,0x81,0x81,0xff},
+  {0xff,0x80,0x80,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x80,0x80,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x80,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x80,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x83,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x83,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x87,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x87,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x8f,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x8f,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x9f,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0x9f,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0xbf,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0xbf,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0xff,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0xff,0x81,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0xff,0xc1,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0xff,0xc1,0x81,0x81,0x81,0x81,0xff},
+  {0xff,0xff,0xc1,0xc1,0x81,0x81,0x81,0xff},
+  {0xff,0xff,0xc1,0xc1,0x81,0x81,0x81,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0x81,0x81,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0x81,0x81,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0x81,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0x81,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xc1,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xc1,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xe1,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xe1,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf1,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf1,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf9,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf9,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xfd,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xfd,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xff,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xff,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc3,0xff,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc1,0xc3,0xff,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xc1,0xc1,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xc1,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xc1,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xc7,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xc7,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xcf,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xcf,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xdf,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xdf,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xff,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xff,0xc3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xc3,0xc3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xc3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xc3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xe3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xe3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xf3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xf3,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xfb,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xfb,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe3,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xe3,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xe7,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xe7,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xef,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xef,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},
+  {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}
+  };
+  uint8_t temp;
+  int line[8] = {1,2,4,8,16,32,64,128};
+
+  rst = 1;
+  wait(0.5);
+  rst = 0;
+  wait(0.5);
+  rst = 1;
+  wait(0.5);
+
+  //dot_matrix.format(6,0);
+  sb = 0; // 6 bit
+  for(int i = 0; i<8; i++){
+    dot_matrix.write(wb[0]);
+    dot_matrix.write(wb[1]);
+    dot_matrix.write(wb[2]);
+
+  open_line = 0;
+  // dot_matrix.format(8,0);
+  sb = 1; // 8 bit
+  t.start();
+  while (1) {
+
+      for(int j=0;j<=130;j++){
+        swap = swap + 1;
+        for(int a=0;a<=8;a++){
+          temp = pic[j][a];
+          counter = counter+1;
+          if( counter == 60 ){
+            click = click+1;
+            counter=0;
+          }
+            if(click == 0){
+              rgb[0] = 0;
+              rgb[1] = 0;
+              rgb[2] = counter;
+            }
+            else if(click == 1){
+              rgb[0] = 0;
+              rgb[1] = counter;
+              rgb[2] = 60;
+            }
+            else if(click == 2){
+              rgb[0] = 0;
+              rgb[1] = 60;
+              rgb[2] = 60 - counter;
+              }
+            else if(click == 3){
+              rgb[0] = counter;
+              rgb[1] = 60;
+              rgb[2] = 0;
+            }
+            else if(click == 4){
+              rgb[0] = 60;
+              rgb[1] = 60 - counter;
+              rgb[2] = 0;
+            }
+            else if(click == 5){
+              rgb[0] = 60;
+              rgb[1] = 0;
+              rgb[2] = counter;
+            }
+            else if(click == 6){
+              rgb[0] = 60 - counter;
+              rgb[1] = 0;
+              rgb[2] = 60;
+            }
+            else if(click == 7){
+              rgb[0] = 0;
+              rgb[1] = 0;
+              rgb[2] = 60;
+              click = 1;
+            }
+            wait(0.001);
+        for(int i = 0; i<8; i++){
+
+          if(temp & 0x80){
+            dot_matrix.write(rgb[0]);
+            dot_matrix.write(rgb[1]);
+            dot_matrix.write(rgb[2]);
+          }
+          else{
+            dot_matrix.write(0);
+            dot_matrix.write(0);
+            dot_matrix.write(0);
+          }
+          temp = temp << 1;
+        }
+        lat = 1;
+        lat = 0;
+        open_line = line[a];
+        wait(0.001);
+      }
+    }
+
+      for(int j=129 ; j>=0;j--){
+        swap = swap + 1;
+        for(int a=0;a<=8;a++){
+          temp = pic[j][a];
+          counter = counter+1;
+          if( counter == 60 ){
+            click = click+1;
+            counter=0;
+          }
+            if(click == 0){
+              rgb[0] = 0;
+              rgb[1] = 0;
+              rgb[2] = counter;
+            }
+            else if(click == 1){
+              rgb[0] = 0;
+              rgb[1] = counter;
+              rgb[2] = 60;
+            }
+            else if(click == 2){
+              rgb[0] = 0;
+              rgb[1] = 60;
+              rgb[2] = 60 - counter;
+              }
+            else if(click == 3){
+              rgb[0] = counter;
+              rgb[1] = 60;
+              rgb[2] = 0;
+            }
+            else if(click == 4){
+              rgb[0] = 60;
+              rgb[1] = 60 - counter;
+              rgb[2] = 0;
+            }
+            else if(click == 5){
+              rgb[0] = 60;
+              rgb[1] = 0;
+              rgb[2] = counter;
+            }
+            else if(click == 6){
+              rgb[0] = 60 - counter;
+              rgb[1] = 0;
+              rgb[2] = 60;
+            }
+            else if(click == 7){
+              rgb[0] = 0;
+              rgb[1] = 0;
+              rgb[2] = 60;
+              click = 1;
+            }
+            wait(0.001);
+
+
+
+        for(int i = 0; i<8; i++){
+
+          if(temp & 0x80){
+            dot_matrix.write(rgb[0]);
+            dot_matrix.write(rgb[1]);
+            dot_matrix.write(rgb[2]);
+          }
+          else{
+            dot_matrix.write(0);
+            dot_matrix.write(0);
+            dot_matrix.write(0);
+          }
+          temp = temp << 1;
+        }
+        lat = 1;
+        lat = 0;
+        open_line = line[a];
+        wait(0.001);
+      }
+    }
+
+        //open_line = 0;
+
+      }
+    }
+  }