/*
  testSensorRead.cpp

  reads sensor and displays value in centimeters
*/

#include <iostream>
using namespace std;

#include <stdlib.h>

#include "Srf10.h"

int main()
{
  int i2cHandle;

  if((i2cHandle = open("/dev/i2c-0", O_RDWR)) < 0)
  {
    cout << "Open Failed" << endl;
    exit(1);
  }
  
/*
  There are 16 addresses available to the srf10 range sensor (0-15).  The
  changeAddress method will take a number from 0 - 15 and perform the
  necessary commands to change the address of that sensor.
*/
  int i2cAddr;
  char resultType;  // i = inches, c = centimeters, s = micro-seconds
  
  cout << "Enter sensor address (0 - 15): ";
  cin >> i2cAddr;
  i2cAddr += 0x70;
  Srf10 sensor(i2cHandle, i2cAddr, resultType);

  sensor.changeAddress(2);

  return 0;
}
