X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fsensors%2Fpressure.c;h=29b8d28d3213b6139af1fdca56b5275191ea89cb;hb=7e9d726ccd53626251e56b92c8eec47772bfe0f9;hp=ddb46df039f3e037bcb3fbe48ed0fe79f4024bc2;hpb=f7e1e1e4b7c22ef34702cff9b01025612809aab8;p=matches%2FMCTX3420.git diff --git a/server/sensors/pressure.c b/server/sensors/pressure.c index ddb46df..29b8d28 100644 --- a/server/sensors/pressure.c +++ b/server/sensors/pressure.c @@ -40,13 +40,16 @@ double Pressure_Callibrate(int id, int adc) { //double voltage = ADC_TO_VOLTS(adc); // convert reading to voltage + return (double)adc; + + //TODO: Fix this switch (id) { case PRES_HIGH0: case PRES_HIGH1: { static const double Vs = 5e3; // In mVs - static const double Pmin = 0.0; + static const double Pmin = 0.0 * PSI_TO_KPA; static const double Pmax = 150.0 * PSI_TO_KPA; double Vout = ADC_TO_MVOLTS(adc); return ((Vout - 0.1*Vs)/(0.8*Vs))*(Pmax - Pmin) + Pmin; @@ -93,9 +96,10 @@ bool Pressure_Read(int id, double * value) //static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; //pthread_mutex_lock(&mutex); bool result = false; - if (ADC_Read(Pressure_GetADC(id), value)) + int adc = 0; + if (ADC_Read(Pressure_GetADC(id), &adc)) { - *value = Pressure_Callibrate(id, *value); + *value = Pressure_Callibrate(id, adc); result = true; } //pthread_mutex_unlock(&mutex);