aboutsummaryrefslogtreecommitdiffstats
path: root/examples/test-session.cpp
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-04-11 12:32:09 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-04-11 12:32:09 -0400
commit33f8df7aabe627f0343c5aa30c0147a8b567652c (patch)
tree60f1dc148c9ff1a24d1fc6a8d57822efd5862180 /examples/test-session.cpp
parentbe4f7904584da06a5971616034dd3839e433edf8 (diff)
downloadlibrambutan-33f8df7aabe627f0343c5aa30c0147a8b567652c.tar.gz
librambutan-33f8df7aabe627f0343c5aa30c0147a8b567652c.zip
Adding button test to examples/test-session.cpp.
Diffstat (limited to 'examples/test-session.cpp')
-rw-r--r--examples/test-session.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/examples/test-session.cpp b/examples/test-session.cpp
index 01d0fe9..03fb248 100644
--- a/examples/test-session.cpp
+++ b/examples/test-session.cpp
@@ -29,6 +29,7 @@ void cmd_sequential_adc_reads(void);
void cmd_gpio_qa(void);
void cmd_sequential_gpio_writes(void);
void cmd_gpio_toggling(void);
+void cmd_but_test(void);
void cmd_sequential_pwm_test(void);
void cmd_servo_sweep(void);
void cmd_board_info(void);
@@ -73,7 +74,7 @@ void setup() {
void loop () {
toggleLED();
- delay(100);
+ delay(250);
while (SerialUSB.available()) {
uint8 input = SerialUSB.read();
@@ -154,6 +155,10 @@ void loop () {
cmd_gpio_toggling();
break;
+ case 'B':
+ cmd_but_test();
+ break;
+
case 'f':
SerialUSB.println("Wiggling D4 as fast as possible in bursts. "
"Press any key.");
@@ -261,6 +266,7 @@ void cmd_print_help(void) {
SerialUSB.println("\tU: dump data as fast as possible on USB");
SerialUSB.println("\tg: toggle GPIOs sequentially");
SerialUSB.println("\tG: toggle GPIOs at the same time");
+ SerialUSB.println("\tB: test the built-in button");
SerialUSB.println("\tf: toggle pin 4 as fast as possible in bursts");
SerialUSB.println("\tr: monitor and print GPIO status changes");
SerialUSB.println("\ts: output a sweeping servo PWM on all PWM channels");
@@ -577,6 +583,20 @@ void cmd_gpio_toggling(void) {
}
}
+void cmd_but_test(void) {
+ SerialUSB.println("Press the button to test. Press any key to stop.");
+ pinMode(BOARD_BUTTON_PIN, INPUT);
+
+ while (!SerialUSB.available()) {
+ if (isButtonPressed()) {
+ uint32 tstamp = millis();
+ SerialUSB.print("Button press detected, timestamp: ");
+ SerialUSB.println(tstamp);
+ }
+ }
+ SerialUSB.read();
+}
+
void cmd_sequential_pwm_test(void) {
SerialUSB.println("Sequentially testing PWM on all unused pins. "
"Press any key for next pin, ESC to stop.");