diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-05-02 14:33:05 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-05-04 13:31:24 -0400 |
commit | 11a0da5c63faffd45bde43da2777a9771cfdf5e9 (patch) | |
tree | 2f4d468a82925de416c1f455c37fad2ffe154836 /examples/test-serialusb.cpp | |
parent | 7caa5711c3f2d03870cba71d175a057e573aff8d (diff) | |
download | librambutan-11a0da5c63faffd45bde43da2777a9771cfdf5e9.tar.gz librambutan-11a0da5c63faffd45bde43da2777a9771cfdf5e9.zip |
/examples/ cleanups.
Diffstat (limited to 'examples/test-serialusb.cpp')
-rw-r--r-- | examples/test-serialusb.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/examples/test-serialusb.cpp b/examples/test-serialusb.cpp index 678c2b9..15ab913 100644 --- a/examples/test-serialusb.cpp +++ b/examples/test-serialusb.cpp @@ -3,27 +3,24 @@ #include "wirish.h" #include "usb.h" -#define LED_PIN BOARD_LED_PIN -#define BUT_PIN BOARD_BUTTON_PIN - -uint32 state = 0; #define QUICKPRINT 0 #define BIGSTUFF 1 #define NUMBERS 2 #define SIMPLE 3 #define ONOFF 4 +uint32 state = 0; + void setup() { /* Set up the LED to blink */ - pinMode(LED_PIN, OUTPUT); - - /* Set up the Button */ - pinMode(BUT_PIN, INPUT); + pinMode(BOARD_LED_PIN, OUTPUT); + /* Set up Serial2 for use as a debug channel */ Serial2.begin(9600); - Serial2.println("This is the debug channel. Press BUT."); - - waitForButtonPress(0); + Serial2.println("This is the debug channel. Press any key."); + while (!Serial2.available()) + ; + Serial2.read(); } uint8 c1 = '-'; @@ -32,14 +29,15 @@ void loop() { toggleLED(); delay(1000); - if(isButtonPressed()) { + if (Serial2.available()) { + Serial2.read(); state++; } - switch(state) { + switch (state) { case QUICKPRINT: - for(int i = 0; i<30; i++) { - usbSendBytes(&c1,1); + for (int i = 0; i < 30; i++) { + usbSendBytes(&c1, 1); SerialUSB.print('.'); SerialUSB.print('|'); } @@ -121,9 +119,8 @@ __attribute__((constructor)) void premain() { int main(void) { setup(); - while (1) { + while (true) { loop(); } return 0; } - |