aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-08-31 12:35:13 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-08-31 13:06:07 -0400
commitefb47bbab6666945334a478b0fce71f24e699997 (patch)
treec9a94311f1a7e96d30cfd63617d2e651694fc900
parent5478c61a471f0a6b0668aeaecb027609effdee90 (diff)
downloadlibrambutan-efb47bbab6666945334a478b0fce71f24e699997.tar.gz
librambutan-efb47bbab6666945334a478b0fce71f24e699997.zip
test-session.cpp: Measure ADC noise sequentially.
Measure pins one at a time.
-rw-r--r--examples/test-session.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/examples/test-session.cpp b/examples/test-session.cpp
index ea75410..d81fca8 100644
--- a/examples/test-session.cpp
+++ b/examples/test-session.cpp
@@ -301,18 +301,31 @@ void cmd_print_help(void) {
}
void cmd_adc_stats(void) {
- SerialUSB.println("Taking ADC noise stats.");
- digitalWrite(BOARD_LED_PIN, 0);
- for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) {
- delay(5);
+ SerialUSB.println("Taking ADC noise stats. Press ESC to stop, "
+ "'R' to repeat same pin, anything else for next pin.");
+
+ uint32 i = 0;
+ while (i < BOARD_NR_ADC_PINS) {
measure_adc_noise(boardADCPins[i]);
+
+ uint8 c = SerialUSB.read();
+ if (c == ESC) {
+ break;
+ } else if (c != 'r' && c != 'R') {
+ SerialUSB.println("----------");
+ i++;
+ }
}
}
void cmd_stressful_adc_stats(void) {
- SerialUSB.println("Taking ADC noise stats under duress.");
+ SerialUSB.println("Taking ADC noise stats under duress. Press ESC to "
+ "stop, 'R' to repeat same pin, anything else for next "
+ "pin.");
- for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) {
+ uint32 i = 0;
+ while (i < BOARD_NR_ADC_PINS) {
+ // use PWM to create digital noise
for (uint32 j = 0; j < BOARD_NR_PWM_PINS; j++) {
if (boardADCPins[i] != boardPWMPins[j]) {
pinMode(boardPWMPins[j], PWM);
@@ -320,16 +333,23 @@ void cmd_stressful_adc_stats(void) {
}
}
- Serial1.print(dummy_data);
-
measure_adc_noise(boardADCPins[i]);
+ // turn off the noise
for (uint32 j = 0; j < BOARD_NR_PWM_PINS; j++) {
if (boardADCPins[i] != boardPWMPins[j]) {
pinMode(boardPWMPins[j], OUTPUT);
digitalWrite(boardPWMPins[j], LOW);
}
}
+
+ uint8 c = SerialUSB.read();
+ if (c == ESC) {
+ break;
+ } else if (c != 'r' && c != 'R') {
+ SerialUSB.println("----------");
+ i++;
+ }
}
}