Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBHost USBHostXpad mbed-rtos mbed
utils.cpp@3:c1620db50a75, 2014-11-26 (annotated)
- Committer:
- hotwheelharry
- Date:
- Wed Nov 26 22:53:15 2014 +0000
- Revision:
- 3:c1620db50a75
- Parent:
- 0:79485480cd7e
Movement works. Solenoid digital fire signal and rumble added. Still need audio, and fix the bug where the controller doesn't work when not plugged into usb. It has to do with output to the serial port, not sure what else.
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 | } |
