![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
sampleProgram
Dependencies: QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo
Fork of 17robo_fuzi by
headerfile_unuse/limit_.h@66:1664ee92539d, 2017-09-24 (annotated)
- Committer:
- echo_piyo
- Date:
- Sun Sep 24 05:25:03 2017 +0000
- Revision:
- 66:1664ee92539d
- Parent:
- limit.h@0:bf96e953cdb8
????2??
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
echo_piyo | 0:bf96e953cdb8 | 1 | /* |
echo_piyo | 0:bf96e953cdb8 | 2 | dataのmax,minの範囲内の数値を返す関数 |
echo_piyo | 0:bf96e953cdb8 | 3 | |
echo_piyo | 0:bf96e953cdb8 | 4 | limiti([int]data, [int]max, [int]min); //int用 |
echo_piyo | 0:bf96e953cdb8 | 5 | limitf([float]data, [float]max, [float]min); //float用 |
echo_piyo | 0:bf96e953cdb8 | 6 | |
echo_piyo | 0:bf96e953cdb8 | 7 | */ |
echo_piyo | 0:bf96e953cdb8 | 8 | int limiti(int data, int max, int min){ |
echo_piyo | 0:bf96e953cdb8 | 9 | if (data > max) { |
echo_piyo | 0:bf96e953cdb8 | 10 | return max; |
echo_piyo | 0:bf96e953cdb8 | 11 | } else if (data < min) { |
echo_piyo | 0:bf96e953cdb8 | 12 | return min; |
echo_piyo | 0:bf96e953cdb8 | 13 | } |
echo_piyo | 0:bf96e953cdb8 | 14 | return data; |
echo_piyo | 0:bf96e953cdb8 | 15 | } |
echo_piyo | 0:bf96e953cdb8 | 16 | |
echo_piyo | 0:bf96e953cdb8 | 17 | float limitf(float data, float max, float min){ |
echo_piyo | 0:bf96e953cdb8 | 18 | if (data > max) { |
echo_piyo | 0:bf96e953cdb8 | 19 | return max; |
echo_piyo | 0:bf96e953cdb8 | 20 | } else if (data < min) { |
echo_piyo | 0:bf96e953cdb8 | 21 | return min; |
echo_piyo | 0:bf96e953cdb8 | 22 | } |
echo_piyo | 0:bf96e953cdb8 | 23 | return data; |
echo_piyo | 0:bf96e953cdb8 | 24 | } |