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
Diff: limit.h
- Revision:
- 0:bf96e953cdb8
diff -r 000000000000 -r bf96e953cdb8 limit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/limit.h Mon Jun 26 09:59:14 2017 +0000 @@ -0,0 +1,24 @@ +/* +dataのmax,minの範囲内の数値を返す関数 + +limiti([int]data, [int]max, [int]min); //int用 +limitf([float]data, [float]max, [float]min); //float用 + +*/ +int limiti(int data, int max, int min){ + if (data > max) { + return max; + } else if (data < min) { + return min; + } + return data; +} + +float limitf(float data, float max, float min){ + if (data > max) { + return max; + } else if (data < min) { + return min; + } + return data; +} \ No newline at end of file