Niet van mijzelf

Dependencies:   USBHost USBHostXpad mbed-rtos mbed

Fork of x4180_Tank by C K

utils.cpp

Committer:
347467
Date:
2015-02-25
Revision:
10:7e3987c8fa37
Parent:
3:c1620db50a75

File content as of revision 10:7e3987c8fa37:

#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;
}