David Wynn
/
mbed_max2719
ECE Project
Diff: main.cpp
- Revision:
- 3:ee4b3ea36ec7
- Parent:
- 2:577acf73d01f
diff -r 577acf73d01f -r ee4b3ea36ec7 main.cpp --- a/main.cpp Sun Apr 10 19:41:30 2016 +0000 +++ b/main.cpp Sun Apr 10 20:06:28 2016 +0000 @@ -75,19 +75,20 @@ spi.frequency(1000000); // SCLK = 1 MHz Init_MAX7219(); // Initialize the LED controller MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); + unsigned char row = 0x03; unsigned char position[] = { - 0x03, 0x80 + 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00 }; for(int i=1; i<9; i++) // Write first character (8 rows) SPI_Write2(i,led1[i-1]); while (1) { - float x, y, z; + float x, y; x = acc.getAccX(); y = acc.getAccY(); - z = acc.getAccZ(); + if(x > 0.5){ printf("Left \n"); position[1] = position[1]*2; @@ -96,23 +97,23 @@ position[1] = position[1]/2; }else if(y > 0.5){ printf("Up \n"); - position[0] = position[1]-1; + position[0] = position[0]-1; + row--; }else if(y < -0.5){ printf("Down \n"); - position[0] = position[1]+2; + position[0] = position[0]+1; + row++; } - /* - rled = 1.0f - abs(x); - gled = 1.0f - abs(y); - bled = 1.0f - abs(z); - */ - direction(x,y); - //wait(0.5f); - - + + wait(1); // 1 sec delay SPI_Write2(position[0], position[1]); + for(int i=1; i<9; i++){ // Write first character (8 rows) + if(i != row){ + SPI_Write2(i,led1[i-1]); + } + } }