![](/media/cache/profiles/Chris_Profile_Pic_kyGJjzP.jpg.50x50_q85.jpg)
test program for apps shield
Dependencies: C12832_lcd_fork LM75B MMA7660 mbed C027
Diff: main.cpp
- Revision:
- 2:134ff7c6ed07
- Parent:
- 1:c409f3abab09
diff -r c409f3abab09 -r 134ff7c6ed07 main.cpp --- a/main.cpp Fri Jan 03 22:48:18 2014 +0000 +++ b/main.cpp Thu Feb 06 21:06:51 2014 +0000 @@ -1,32 +1,40 @@ #include "mbed.h" +#include "C027.h" -#define PLATFORM_C027 -#include "arduino.h" +#include "C12832_lcd.h" +C12832_LCD lcd(D11, D13, D12, D7, D10); #include "LM75B.h" +LM75B sensor(D14, D15); + #include "MMA7660.h" -#include "C12832_lcd.h" - -C12832_LCD lcd(ARD_D11,ARD_D13, ARD_D12, ARD_D7, ARD_D10); +MMA7660 MMA(D14, D15); -DigitalOut redled(ARD_D5); -DigitalOut blueled(ARD_D8); -DigitalOut greenled(ARD_D9); +PwmOut spkr(D6); -LM75B sensor(ARD_SDA,ARD_SCL); -MMA7660 MMA(ARD_SDA,ARD_SCL); +AnalogIn pot1 (A0); +AnalogIn pot2 (A1); -//DigitalOut spk(ARD_D6); +DigitalIn up(A2); +DigitalIn down(A3); +DigitalIn left(A4); +AnalogIn right(A5); +DigitalIn center(D4); -AnalogIn pot1 (ARD_A0); -AnalogIn pot2 (ARD_A1); +DigitalOut redled(D5); +DigitalOut blueled(D8); +DigitalOut greenled(D9); -DigitalIn up(ARD_A2); -DigitalIn down(ARD_A3); -DigitalIn left(ARD_A4); -AnalogIn right(ARD_A5); -DigitalIn center(ARD_D4); +Serial pc(USBTX, USBRX); +void clearConsole() +{ + lcd.cls(); + lcd.locate(0,3); + while(pc.readable()) { + int c = pc.getc(); + } +} int main() { @@ -35,59 +43,76 @@ blueled =1; greenled=1; int i=0; + + puts("LCD Test"); -while (1) { - lcd.cls(); - lcd.locate(0,3); - lcd.printf("woot! %d!",i); - i++; - redled = !redled; - wait(1.0); + while (!pc.readable()) { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("woot! %d!",i); + i++; + redled = !redled; + wait(1.0); + } + + clearConsole(); + puts("Joystick Test"); + + while (!pc.readable()) { + redled = !up && ! down; + blueled = !center; + greenled= !left && !right; + } + + clearConsole(); + puts("Pot Test"); + + while (!pc.readable()) { + redled = 1; + wait(pot1.read()); + redled = 0; + wait(pot2.read()); + } + + clearConsole(); + puts("Pot Test 2"); + + while (!pc.readable()) { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("%.3f %.3f %.3f", pot1.read(),pot2.read(), right.read()); + wait(0.2); + } + + clearConsole(); + puts("Accel / Temp Test"); + + while (!pc.readable()) { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Temp = %.3f", (float)sensor); + lcd.locate(0,14); + lcd.printf("x=%.2f y=%.2f z=%.2f",MMA.x(), MMA.y(), MMA.z()); + blueled = !blueled; + greenled = !greenled; + wait(1.0); + i++; + } + + clearConsole(); + puts("Speaker Test"); + + for(int j=0; j<3; j++) { + for (float i=2000.0; i<4000.0; i+=100) { + spkr.period(1.0/i); + spkr=0.5; + wait(0.1); + } + spkr=0.0; + wait(2.0f); + } + + puts("Test Complete"); } - -/* - while (1) { - redled = !up && ! center; - blueled = !down; - greenled= !left && !right; - } -*/ - - /* - while (1) { - redled = 1; - wait(pot2.read()); - redled = 0; - wait(pot2.read()); - - } - - - while(1) { - lcd.cls(); - lcd.locate(0,3); - lcd.printf("%.3f %.3f %.3f", pot1.read(),pot2.read(), right.read()); - wait(0.2); - } - - - while(1) { - lcd.cls(); - lcd.locate(0,3); - lcd.printf("Temp = %.3f", (float)sensor); - lcd.locate(0,14); - lcd.printf("x=%.2f y=%.2f z=%.2f",MMA.x(), MMA.y(), MMA.z()); - blueled = !blueled; - greenled = !greenled; - wait(1.0); - i++; - - } - - */ - -} - -