TestAccelerometer.cpp



/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <accelerometer.hpp>

int main(int argc, char *argv[])
{
  int value=0;
  int valueMax=0;
  int valueMin=0;
  
  if(argc<2)
  {
    puts("\nUSE:\nTestAccelerometer <type>\n");
    puts("types:");
    puts("\tMac <dimension>");
    puts("\tMoko <dimension>\n");
    puts("\t  e.g.");
    puts("\t    TestAccelerometer Mac 0 => Shows the accelerometer value of the MacBook for X dimension.");
    puts("\t    TestAccelerometer Mac 1 => Shows the accelerometer value of the Neo for Y dimension.\n");

    exit(EXIT_SUCCESS);
  }
  
  if (strcmp(argv[1],"Mac") == 0)
  {
    CMAccelerometer accel("/dev/input/event10");
    while(1)
    {
      accel.check();
      value=accel.getValue(atoi(argv[2]));
      printf("\nValue:%d",value);
      // MAX and MIN
      if (valueMax < value)
        valueMax = value;
        
      if (valueMin > value)
        valueMin = value;
        
      printf("\t Max:%d   \tMin:%d\n",valueMax,valueMin);
      usleep(5000);
    }//END while
  }//END Mac
  
  if (strcmp(argv[1],"Moko") == 0)
  {
    CMAccelerometer accel("/dev/input/event3");
    while(1)
    {
      accel.check();
      value=accel.getValue(atoi(argv[2]));
      printf("\nValue:%d",value);
      
      // MAX and MIN
      if (valueMax < value)
      { valueMax = value; }
        
      if (valueMin > value)
      { valueMin = value; }
        
      printf("\t Max:%d   \tMin:%d\n",valueMax,valueMin);
      usleep(5000);
    }//END while
  }//END Moko
      
}//END main
 All Data Structures Functions Variables
Generated on Mon Sep 12 07:59:09 2011 for API MokArdu by  doxygen 1.6.3