Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 4:a091b8f8216d
- Parent:
- 3:da30c350c339
- Child:
- 5:e4ed6c5baf89
--- a/main.cpp Fri May 02 18:26:40 2014 +0000
+++ b/main.cpp Sun May 04 20:41:10 2014 +0000
@@ -4,84 +4,42 @@
#include "LedCube.h"
#include "rtos.h"
-int counter1 = 0;
-int counter2 = 0;
-int counter3 = 0;
-char ledbuffer[8][8][8];
-const int frames = 400;
-bool printed = false;
-bool testprinted = false;
-char layer = 1;
-bool first = true;
-int success = 1;
-char databuffer[512];
-const int spifreq = 10000000; //frequency of SPI interface
-const char address = 0xA0; //address van I2C interface
+const int FRAMES = 700;
+const int SPIFREQ = 10000000; //frequency of SPI interface
+const char ADDRESS = 0xA0; //address van I2C interface
LedCube* ledcube = new LedCube();
-SPIDriver* spidriver = new SPIDriver(p5, NC, p7, p8, p10, spifreq);
-I2CDriver* i2cdriver = new I2CDriver(p28, p27, address);
+SPIDriver* spidriver = new SPIDriver(p5, NC, p7, p8, p10, SPIFREQ);
+I2CDriver* i2cdriver = new I2CDriver(p28, p27, ADDRESS);
//DigitalOut blank(p9);
-Serial pc(USBTX, USBRX);
-uint8_t reverse_byte(uint8_t byte);
-void initialtest1();
-void initialtest2();
-void sendbuffer();
-void modifybuffer();
-void streamthread(const void* args);
+void streamThread(void const* args);
+void inputThread(void const* args);
int main()
{
- spidriver->testPhase(frames);
-
+ spidriver->testPhase(FRAMES);
+
+ printf("Initiating stream from following matrices\n\r");
+ ledcube->printAll();
+ printf("Streaming...\n\r");
+
+ Thread thread1(streamThread);
+ Thread thread2(inputThread);
- Thread thread(streamthread);
- /*while(true) {
- if (i2cdriver->receive() == I2CDriver::WriteAddressed) {
- pc.printf("Waarde ontvangen!\n\r");
- modifybuffer();
- printed = false;
- }
- spidriver->sendFrame(ledcube);
- }//while loop*/
+ while(true){}
}//end main
-void streamthread(const void* args){
- spidriver->stream(ledcube);
+void streamThread(void const* args)
+{
+ while(true) {
+ spidriver->sendFrame(ledcube);
+ }
}
-void modifybuffer()
+void inputThread(void const* args)
{
- unsigned char ledcolor;
- while(!((counter1 == 8) && (counter2 == 0) && (counter3 == 1))) {
- ledcolor = i2cdriver->read();
- if (ledcolor == 8) {
- counter1 = 0;
- counter2 = 0;
- counter3 = 0;
- } else {
- if (ledcolor == 9) {
- ledcube->setData(databuffer);
- break;
- } else {
- ledbuffer[counter1][counter2][counter3] = ledcolor;
-
- if (counter3 < 7) {
- counter3++;
- } else {
- if (counter2 < 7) {
- counter2++;
- counter3 = 0;
- } else {
- if (counter1 < 7) {
- counter1++;
- counter2 = 0;
- counter3 = 0;
- }
- }
- }
- }
- }
+ while(true) {
+ i2cdriver->pollForInput(ledcube);
}
}
\ No newline at end of file