Hiroaki Matsuda
/
mbed-for-McuComm
this is program for mbed ,to relay MCUcomm data to servo
command/command.cpp
- Committer:
- matsu
- Date:
- 2012-11-28
- Revision:
- 0:09bf8e3091e8
- Child:
- 1:0fe52e356d01
File content as of revision 0:09bf8e3091e8:
#include "command.h" #include "mbed.h" Command::Command(PinName pin) :Servo(pin) { }; void Command::targetPosition(int number ,int receive) { switch(number-3){ case 0: _position = receive<<8; break; case 1: _position += receive; break; case 2: _time = receive<<8; break; case 3: _time += receive; break; } } void Command::homePosition(int number ,int receive) { switch(number-3){ case 0: _position = receive<<8; break; case 1: _position += receive; break; case 2: _homePosition = _position; break; } } int Command::getPosition() { return _position; } int Command::getTime() { return _time; } int Command::getHomeposition() { return _homePosition; } void Command::onOff() { if(_on == false){ _on = true; write(getPosition()/1800); }else if(_on == true){ _on = false; _pwm.pulsewidth(0); } } Command& Command::operator= (float percent) { write(percent); return *this; } Command& Command::operator= (Command& rhs) { write(rhs.read()); return *this; }