田中くんのモタドラを制御する石本さんのやつ
Diff: T_motor.cpp
- Revision:
- 1:5bd161b83ce0
- Parent:
- 0:e10d08530490
- Child:
- 2:f82a7c0b697f
--- a/T_motor.cpp Sun Aug 13 02:08:40 2017 +0000 +++ b/T_motor.cpp Sun Aug 13 03:48:22 2017 +0000 @@ -25,7 +25,7 @@ init(addr); } -T_motor& T_motor::operator=(float fval) +T_motor& T_motor::operator=(float fval)// -1 <= fval <= 1 { if(fabs(fval) < 0.1f)free(); else { @@ -35,6 +35,15 @@ return *this; } +void T_motor::control(float fval)//copy from operator +{ + if(fabs(fval) < 0.1f)free(); + else { + if(fval < 0) run(1,char(-1*fval*255)); + else if(fval > 0) run(0,char(fval*255)); + } +} + bool T_motor::run(char mode,char speed) { bool f = 0;