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: CircularBuffer Servo Terminal mbed Radio
utility.h@18:8806d24809c2, 2013-05-27 (annotated)
- Committer:
- pclary
- Date:
- Mon May 27 20:08:03 2013 +0000
- Revision:
- 18:8806d24809c2
- Parent:
- 17:4ec59e8b52a6
Added logic to keep balance, currently doesn't work
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pclary | 9:a6d1502f0f20 | 1 | inline float min(float a, float b) |
pclary | 9:a6d1502f0f20 | 2 | { |
pclary | 9:a6d1502f0f20 | 3 | return (a < b ? a : b); |
pclary | 17:4ec59e8b52a6 | 4 | } |
pclary | 17:4ec59e8b52a6 | 5 | |
pclary | 17:4ec59e8b52a6 | 6 | |
pclary | 17:4ec59e8b52a6 | 7 | |
pclary | 17:4ec59e8b52a6 | 8 | inline float pos(float f) |
pclary | 17:4ec59e8b52a6 | 9 | { |
pclary | 17:4ec59e8b52a6 | 10 | return f > 0.0f ? f : 0.0f; |
pclary | 18:8806d24809c2 | 11 | } |
pclary | 18:8806d24809c2 | 12 | |
pclary | 18:8806d24809c2 | 13 | |
pclary | 18:8806d24809c2 | 14 | |
pclary | 18:8806d24809c2 | 15 | inline int deadzone(int input, int zone) |
pclary | 18:8806d24809c2 | 16 | { |
pclary | 18:8806d24809c2 | 17 | if (input > zone) return input; |
pclary | 18:8806d24809c2 | 18 | else if (input < -zone) return input; |
pclary | 18:8806d24809c2 | 19 | else return 0; |
pclary | 18:8806d24809c2 | 20 | } |
pclary | 18:8806d24809c2 | 21 | |
pclary | 18:8806d24809c2 | 22 | |
pclary | 18:8806d24809c2 | 23 | |
pclary | 18:8806d24809c2 | 24 | inline int least(float f1, float f2, float f3, float f4) |
pclary | 18:8806d24809c2 | 25 | { |
pclary | 18:8806d24809c2 | 26 | int value = 0; |
pclary | 18:8806d24809c2 | 27 | float temp = f1; |
pclary | 18:8806d24809c2 | 28 | |
pclary | 18:8806d24809c2 | 29 | if (f2 < temp) |
pclary | 18:8806d24809c2 | 30 | { |
pclary | 18:8806d24809c2 | 31 | value = 1; |
pclary | 18:8806d24809c2 | 32 | temp = f2; |
pclary | 18:8806d24809c2 | 33 | } |
pclary | 18:8806d24809c2 | 34 | |
pclary | 18:8806d24809c2 | 35 | if (f3 < temp) |
pclary | 18:8806d24809c2 | 36 | { |
pclary | 18:8806d24809c2 | 37 | value = 2; |
pclary | 18:8806d24809c2 | 38 | temp = f3; |
pclary | 18:8806d24809c2 | 39 | } |
pclary | 18:8806d24809c2 | 40 | |
pclary | 18:8806d24809c2 | 41 | if (f4 < temp) |
pclary | 18:8806d24809c2 | 42 | { |
pclary | 18:8806d24809c2 | 43 | value = 3; |
pclary | 18:8806d24809c2 | 44 | } |
pclary | 18:8806d24809c2 | 45 | |
pclary | 18:8806d24809c2 | 46 | return value; |
pclary | 9:a6d1502f0f20 | 47 | } |