Nick Lowyck / Mbed 2 deprecated Ledcube

Dependencies:   mbed mbed-rtos

Revision:
5:e4ed6c5baf89
Parent:
4:a091b8f8216d
diff -r a091b8f8216d -r e4ed6c5baf89 main.cpp
--- a/main.cpp	Sun May 04 20:41:10 2014 +0000
+++ b/main.cpp	Thu May 08 18:59:52 2014 +0000
@@ -5,41 +5,75 @@
 #include "rtos.h"
 
 const int FRAMES = 700;
-const int SPIFREQ = 10000000; //frequency of SPI interface
-const char ADDRESS = 0xA0; //address van I2C interface
+const int SPIFREQ = 1000000; //frequency of SPI interface
+const char ADDRESS = 0x60; //address van I2C interface
+unsigned char buffer[512];
+Mutex valuesmutex;
 
 LedCube* ledcube = new LedCube();
-SPIDriver* spidriver = new SPIDriver(p5, NC, p7, p8, p10, SPIFREQ);
+SPIDriver* spidriver = new SPIDriver(p5, NC, p7, p8, p11, SPIFREQ);
 I2CDriver* i2cdriver = new I2CDriver(p28, p27, ADDRESS);
-//DigitalOut blank(p9);
+DigitalOut blank(p9);
 
 void streamThread(void const* args);
 void inputThread(void const* args);
 
 int main()
 {
-    spidriver->testPhase(FRAMES);
+    /* while(true){
+         spidriver->sendLayer(ledcube);
+         wait(0.5);
+     }  */
+    /*  blank = 1;
+      wait_ms(1);*/
+    blank = 0;
+
+    for(int i = 0; i < 512; i++) buffer[i] = 1;
+
+    ledcube->setData(buffer);
+
+    /* while(1){}*/
 
-    printf("Initiating stream from following matrices\n\r");
-    ledcube->printAll();
-    printf("Streaming...\n\r");
+    /* while(true) {
+          char ledvalue = ledcube->getNextValue();
+          printf("%d ", ledvalue);
+          spidriver->write(ledvalue);
+          wait(0.2);
+      }*/
+
+    //  spidriver->testPhase(FRAMES);
 
+    /*  printf("Initiating stream from following matrices\n\r");
+      ledcube->printAll();
+      printf("Streaming...\n\r");*/
+    /*   spidriver->sendLayer(ledcube);
+       wait(0.00125);    //voor 100 Hz
+       spidriver->pulseLatch();*/
+     
+   /* while(true) {
+        spidriver->sendFrame(ledcube);
+    }*/
+    
     Thread thread1(streamThread);
     Thread thread2(inputThread);
+    while(true){}
     
-    while(true){}
 }//end main
 
 void streamThread(void const* args)
 {
     while(true) {
+        valuesmutex.lock();
         spidriver->sendFrame(ledcube);
+        valuesmutex.unlock();
     }
 }
 
 void inputThread(void const* args)
 {
     while(true) {
+        valuesmutex.lock();
         i2cdriver->pollForInput(ledcube);
+        valuesmutex.unlock();
     }
 }
\ No newline at end of file