tankkk
Dependencies: USBHost USBHostXpad mbed-rtos mbed
utils.cpp@9:789350244478, 2014-12-06 (annotated)
- Committer:
- hotwheelharry
- Date:
- Sat Dec 06 05:20:03 2014 +0000
- Revision:
- 9:789350244478
- Parent:
- 3:c1620db50a75
stop at atartup
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hotwheelharry | 0:79485480cd7e | 1 | #include "utils.h" |
hotwheelharry | 0:79485480cd7e | 2 | |
hotwheelharry | 0:79485480cd7e | 3 | double ghettoFloor(double d){ |
hotwheelharry | 0:79485480cd7e | 4 | return double((long long)d); |
hotwheelharry | 0:79485480cd7e | 5 | } |
hotwheelharry | 0:79485480cd7e | 6 | double round(double d) |
hotwheelharry | 0:79485480cd7e | 7 | { |
hotwheelharry | 0:79485480cd7e | 8 | return ghettoFloor(d + 0.5); |
hotwheelharry | 0:79485480cd7e | 9 | } |
hotwheelharry | 3:c1620db50a75 | 10 | |
hotwheelharry | 3:c1620db50a75 | 11 | float xpadNormalizeAnalog(int x){ |
hotwheelharry | 3:c1620db50a75 | 12 | float res = 0; |
hotwheelharry | 3:c1620db50a75 | 13 | if(x > 0){ |
hotwheelharry | 3:c1620db50a75 | 14 | res = (float)x/32767.0; |
hotwheelharry | 3:c1620db50a75 | 15 | }else{ |
hotwheelharry | 3:c1620db50a75 | 16 | res = (float)x/32768.0; |
hotwheelharry | 3:c1620db50a75 | 17 | } |
hotwheelharry | 3:c1620db50a75 | 18 | return res; |
hotwheelharry | 3:c1620db50a75 | 19 | } |
hotwheelharry | 3:c1620db50a75 | 20 | float xpadNormalizeTrigger(int x){ |
hotwheelharry | 3:c1620db50a75 | 21 | float res = (float)x / (float)0xff; |
hotwheelharry | 3:c1620db50a75 | 22 | return res; |
hotwheelharry | 3:c1620db50a75 | 23 | } |