ProjectBattleShip_FRA221 / WolfWarp
Revision:
0:d8f79bc0aebe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WaitOtherPlayer.cpp	Sun Dec 04 10:29:30 2016 +0000
@@ -0,0 +1,197 @@
+#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[63][8] ={
+  {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x42,0x24,0x24,0x42,0x81,0xff},
+
+  {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x24,0x24,0x42,0x81,0xff},
+
+  {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
+  {0xff,0xff,0x7e,0x3c,0x24,0x42,0x81,0xff},
+
+  {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
+  {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
+  {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
+  {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
+  {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
+  {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
+  {0xff,0x81,0x7e,0x3c,0x3c,0x42,0x81,0xff},
+
+  {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
+  {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
+  {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
+  {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
+  {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
+  {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
+  {0xff,0x81,0x42,0x3c,0x3c,0x7e,0x81,0xff},
+
+  {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x3c,0x7e,0xff,0xff},
+
+  {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x7e,0xff,0xff},
+
+  {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0xff,0xff},
+
+  {0xff,0x81,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0x81,0xff},
+  {0xff,0x81,0x42,0x24,0x24,0x42,0x81,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<=62;j++){
+        swap = swap + 1;
+        for(int a=0;a<=7;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.0001);
+      }
+    }
+
+        //open_line = 0;
+
+      }
+    }
+  }