 void dof_setup() {
   if(!lsm.begin()) { while(1); }
 
-  /* Setup the sensor gain and integration time */
+  // Setup the sensor gain and integration time
   configureSensor();
   
   // Set a max and min value to not do anything
   // calibrate(accel.acceleration.x, accel.acceleration.y);
-  
   sensors_event_t accel, mag, gyro, temp;
   lsm.getEvent(&accel, &mag, &gyro, &temp);  
 }

void dof_loop() {
  /* Get a new sensor event */
  sensors_event_t accel, mag, gyro, temp;

  lsm.getEvent(&accel, &mag, &gyro, &temp);

  float mx, my = 0.0;
  float accel_x = clamp(accel.acceleration.x, -20, 20);
  float accel_y = clamp(accel.acceleration.y, -20, 20);

  if (accel.acceleration.x > xRange[1] || accel.acceleration.x < xRange[0]) {
    my = map(accel_x - xNormal, -20, 20, 200, -200);
    mx = map(accel_y - yNormal, -20, 20, 200, -200);
  }
  else if (accel.acceleration.y > yRange[1] || accel.acceleration.y < yRange[0]) {
    my = map(accel_x - xNormal, -20, 20, 200, -200);
    mx = map(accel_y - yNormal, -20, 20, 200, -200);
  }
  Mouse.move(mx, my, 0);
  delay(10);
}

void mpr_loop() {
 // Get the currently touched pads
  currtouched = cap.touched();
  
  for (uint8_t i=0; i < 12; i++) {
    // it if *is* touched and *wasnt* touched before, alert!
    if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
      Serial.print(i); Serial.println(" touched");
    }
    // if it *was* touched and now *isnt*, alert!
    if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
      Serial.print(i); Serial.println(" released");
    }
  }

  // reset our state
  lasttouched = currtouched;

  // comment out this line for detailed data from the sensor!
  return;
  
  // debugging info, what
  Serial.print("\t\t\t\t\t\t\t\t\t\t\t\t\t 0x"); Serial.println(cap.touched(), HEX);
  Serial.print("Filt: ");
  for (uint8_t i=0; i < 12; i++) {
    Serial.print(cap.filteredData(i)); Serial.print("\t");
  }
  Serial.println();
  Serial.print("Base: ");
  for (uint8_t i=0; i < 12; i++) {
    Serial.print(cap.baselineData(i)); Serial.print("\t");
  }
  Serial.println();
  
  // put a delay so it isn't overwhelming
  delay(100); 
}

void calibrate(float x, float y) {

}

float clamp(float value, float min_, float max_) {
  return (value < min_) ? min_ : (value > max_) ? max_ : value;
}

void displaySensorDetails(void) {
