From efb47bbab6666945334a478b0fce71f24e699997 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Wed, 31 Aug 2011 12:35:13 -0400 Subject: test-session.cpp: Measure ADC noise sequentially. Measure pins one at a time. --- examples/test-session.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'examples') 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++; + } } } -- cgit v1.2.3