       Serial.print(buf[idx+2]);Serial.print(" ");
       Serial.print(buf[idx+3]);Serial.println();
     }
+    Serial.println("END");
   } else if (c != -1) Serial.println("???");
 }
-
-/**
-  Performs nscan number of scans of the 4 ADC channels, storing the results
-  into buf.
-
-  Note that if there is insufficient storage space (_BUF_SIZE), scan will be
-  prematurely terminated.
-  */
-void scan_channels(uint16_t nscans) {
-  // prime the ADS7825 to scan channel 0
-  read_analog(0);
-
-  // reset back to start of buffer
-  writepos = 0;
-
-  // reset trigcnt so we don't trigger prematurely
-  trigcnt = 0;
-
-  while (nscans) {
-    if (trigcnt>=_DIVIDER) {
-      trigcnt -= _DIVIDER;
-      if (writepos < _BUF_SIZE) {
-        buf[writepos+0] = read_analog(1);
-        buf[writepos+1] = read_analog(2);
-        buf[writepos+2] = read_analog(3);
-        buf[writepos+3] = read_analog(0);
-
-        writepos += 4;
-        nscans -= 1;
-      } else return; 
-    }
-  }
-}

    Serial.print(read_analog(3));Serial.print(" ");
    Serial.print(read_analog(0));Serial.println();
  } else if (c == 's') {
    // XXX we don't use parseInt beause it takes a second to complete waiting
    // for more user input
    uint16_t nscans = 0;
    while (c != '.') {
      c = Serial.read();
      if (c >= '0') {
        c -= '0';
        nscans *= 10;
        nscans += c;
      }
    }
    scan_channels(nscans);
  } else if (c == 'p') {
    for (int idx = 0; idx < writepos; idx += 4) {
      Serial.print(idx/4);Serial.print(" ");


  digitalWrite(_RC, HIGH);

  // t4, BUSY LOE, is at most 21 us
  delayMicroseconds(22);

  // select the high byte for reading
  digitalWrite(_BYTE, LOW);
