ProjectBattleShip_FRA221 / WolfWarp
Revision:
0:d8f79bc0aebe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PatternWinLose.cpp	Sun Dec 04 10:29:30 2016 +0000
@@ -0,0 +1,97 @@
+#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 check_win = 0;
+int main(){
+
+  dot_matrix.frequency(1000000);
+  // dot_matrix.format(6,0);
+  uint8_t wb[3] = {255,255,255};
+  uint8_t rgb2[3] = {3,3,60};
+  uint8_t rgb[3] = {3,60,3};
+  uint8_t pic[8] = {0x3c,0x42,0xa5,0x81,0xa5,0x99,0x42,0x3c};
+  uint8_t pic2[8] = {0x3c,0x42,0xa5,0x81,0x99,0xa5,0x42,0x3c};
+
+  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) {
+    if(check_win == 1){
+      for(int j = 0;j<8;j++){
+        temp = pic[j];
+        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[j];
+        wait(0.001);
+        open_line = 0;
+      }
+    }
+    else if(check_win == 0){
+      for(int j = 0;j<8;j++){
+        temp = pic2[j];
+        for(int i = 0; i<8; i++){
+          if(temp & 0x80){
+            dot_matrix.write(rgb2[0]);
+            dot_matrix.write(rgb2[1]);
+            dot_matrix.write(rgb2[2]);
+          }
+          else{
+            dot_matrix.write(0);
+            dot_matrix.write(0);
+            dot_matrix.write(0);
+          }
+          temp = temp << 1;
+        }
+        lat = 1;
+        lat = 0;
+        open_line = line[j];
+        wait(0.001);
+        open_line = 0;
+      }
+    }
+    else{
+      t.reset();
+    }
+  }
+
+
+}