ProjectBattleShip_FRA221 / WolfWarp
Revision:
0:d8f79bc0aebe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examplepacman.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 main(){
+
+  dot_matrix.frequency(1000000);
+  // dot_matrix.format(6,0);
+  uint8_t wb[3] = {255,255,255};
+  uint8_t rgb[3] = {0,0,60};
+  uint8_t pic[8] = {0x3C,0x7E,0xDC,0xF8,0xF8,0xFC,0x7E,0x3C};
+  uint8_t pic2[8] = {0x3C,0x7E,0xDF,0xFF,0xF0,0xFF,0x7E,0x3C};
+  // uint8_t pic[8] = {0x00,0x66,0x99,0x81,0x42,0x24,0x18,0x00};
+  // uint8_t pic2[8] = {0x00,0x66,0xFF,0xFF,0x7E,0x3C,0x18,0x00};
+  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(t.read()<0.2){
+      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(t.read()>0.2 && t.read()<0.4){
+      for(int j = 0;j<8;j++){
+        temp = pic2[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{
+      t.reset();
+    }
+  }
+
+
+}