#include <application/application.h>
#include <msp430.h>
#include "CAPT_UserConfig.h"
#include "captivate.h"
#include "CAPT_BSP.h"
#include "I2CSlave.h"
#include "CapTIvate.h"
#include "CAPT_Type.h"
#include "lcd.h"

double Height;
double delta_Cap;
double b,c;

void ButtonHandler(tSensor* pSensor);
void Height_Cal(void);

void App_init(void)
{
 	MAP_CAPT_registerCallback(&Sense, &ButtonHandler);

}

void ButtonHandler(tSensor* pSensor)
{
    Height_Cal();
//    if(Sense_E01.pRawCount<100)
//        LCD_showHeight();
//    if(Sense_E01.pRawCount>100);
//        LCD_showWarning();

}

void Height_Cal()
{
//    double delta_Cap;
//    delta_Cap=(1/ Sense_E01.pRawCount[0]-1/ Sense_E01.LTA.ui16Natural )*Sense.ui16ConversionGain;

    b=1.0/Sense_E01.pRawCount[0];
    c=b-1.0/Sense_E01.LTA.ui16Natural;
 //   Sense.ui16ConversionGain=50;
    delta_Cap=c*Sense.ui16ConversionGain;
    Height=227.7*delta_Cap-30.08;
    _no_operation();
}
