first lib
Dependents: 17robo_fuzi 17robo_tokyo_kaede
Revision 0:9665aacf40f0, committed 2017-09-24
- Comitter:
- echo_piyo
- Date:
- Sun Sep 24 05:24:56 2017 +0000
- Commit message:
- ????2??
Changed in this revision
limit.cpp | Show annotated file Show diff for this revision Revisions of this file |
limit.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 9665aacf40f0 limit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/limit.cpp Sun Sep 24 05:24:56 2017 +0000 @@ -0,0 +1,21 @@ + +#include "limit.h" +#include "mbed.h" + +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
diff -r 000000000000 -r 9665aacf40f0 limit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/limit.h Sun Sep 24 05:24:56 2017 +0000 @@ -0,0 +1,17 @@ +/* +dataのmax,minの範囲内の数値を返す関数 + +limiti([int]data, [int]max, [int]min); //int用 +limitf([float]data, [float]max, [float]min); //float用 + +*/ + +#ifndef MBED_LIMIT_H +#define MBED_LIMIT_H + +#include "mbed.h" + +int limiti(int data, int max, int min); +float limitf(float data, float max, float min); + +#endif \ No newline at end of file