2012-11-03 14:04:45 +01:00
|
|
|
/*
|
|
|
|
|
Motor.h - Motor library
|
|
|
|
|
Copyright (c) 2012 Copenhagen Institute of Interaction Design.
|
|
|
|
|
All right reserved.
|
|
|
|
|
|
|
|
|
|
This library is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Lesser Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Lesser Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser Public License
|
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
+ author: dviid
|
|
|
|
|
+ contact: dviid@labs.ciid.dk
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
enum MOTOR{
|
|
|
|
|
MOTORA = 0,
|
|
|
|
|
MOTORB = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum DIRECTION {
|
|
|
|
|
FORWARD,
|
|
|
|
|
BACKWARD
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class MMotor {
|
|
|
|
|
|
2012-11-26 15:22:39 +01:00
|
|
|
public:
|
2012-11-03 14:04:45 +01:00
|
|
|
|
|
|
|
|
MMotor(MOTOR m);
|
|
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
|
|
|
|
|
void torque(int value);
|
|
|
|
|
int torque();
|
|
|
|
|
|
|
|
|
|
void direction(DIRECTION d);
|
|
|
|
|
DIRECTION direction();
|
|
|
|
|
|
|
|
|
|
void stop();
|
|
|
|
|
void start();
|
|
|
|
|
void restart();
|
|
|
|
|
|
2012-11-26 15:22:39 +01:00
|
|
|
protected:
|
2012-11-03 14:04:45 +01:00
|
|
|
|
|
|
|
|
MOTOR _m;
|
|
|
|
|
DIRECTION _d;
|
|
|
|
|
int _t;
|
|
|
|
|
long _p;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern MMotor MotorA;
|
|
|
|
|
extern MMotor MotorB;
|