Niet van mijzelf

Dependencies:   USBHost USBHostXpad mbed-rtos mbed

Fork of x4180_Tank by C K

utils.cpp

Committer:
hotwheelharry
Date:
2014-11-26
Revision:
3:c1620db50a75
Parent:
0:79485480cd7e

File content as of revision 3:c1620db50a75:

#include "utils.h"

double ghettoFloor(double d){
    return double((long long)d);
}
double round(double d)
{
  return ghettoFloor(d + 0.5);
}

float xpadNormalizeAnalog(int x){
    float res = 0;
    if(x > 0){
        res = (float)x/32767.0;
    }else{
        res = (float)x/32768.0;
    }   
    return res;
}
float xpadNormalizeTrigger(int x){
    float res = (float)x / (float)0xff;
    return res;
}