00001
00002
00003
00004
00005
00006
00007 #ifndef MOTOR_H_
00008 #define MOTOR_H_
00009
00010 #include "Port.h"
00011
00012 extern "C"
00013 {
00014 #include "ecrobot_interface.h"
00015 #include "rtoscalls.h"
00016 };
00017
00018 namespace ecrobot
00019 {
00023 class Motor
00024 {
00025 public:
00029 static const S8 PWM_MAX = 100;
00030
00034 static const S8 PWM_MIN = -100;
00035
00045 explicit Motor(ePortM port, bool brake = true);
00046
00052 ~Motor(void);
00053
00059 inline void reset(void)
00060 {
00061 nxt_motor_set_speed(mPort, 0, 1);
00062 nxt_motor_set_count(mPort, 0);
00063 }
00064
00070 inline S32 getCount(void) const { return nxt_motor_get_count(mPort); }
00071
00077 inline void setCount(S32 count) { nxt_motor_set_count(mPort, count); }
00078
00084 void setPWM(S8 pwm);
00085
00091 void setBrake(bool brake);
00092
00093 protected:
00099 inline ePortM getPort(void) const { return mPort; }
00100
00106 inline bool getBrake(void) const { return mBrake; }
00107
00113 inline S8 getPWM(void) const { return mPWM; }
00114
00115 private:
00116 ePortM mPort;
00117 bool mBrake;
00118 S8 mPWM;
00119 };
00120 }
00121
00122 #endif