Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
command.cpp
00001 #include "command.h" 00002 #include "mbed.h" 00003 00004 00005 00006 00007 00008 Command::Command(PinName pin) :Servo(pin) 00009 { 00010 _power = true; 00011 }; 00012 00013 void Command::targetPosition(int number ,int receive) 00014 { 00015 switch(number-3){ 00016 case 0: 00017 _position = receive<<8; 00018 break; 00019 case 1: 00020 _position += receive; 00021 break; 00022 case 2: 00023 _time = receive<<8; 00024 break; 00025 case 3: 00026 _time += receive; 00027 break; 00028 } 00029 00030 } 00031 00032 void Command::homePosition(int number ,int receive) 00033 { 00034 switch(number-3){ 00035 case 0: 00036 _position = receive<<8; 00037 break; 00038 case 1: 00039 _position += receive; 00040 break; 00041 case 2: 00042 _homePosition = _position; 00043 break; 00044 } 00045 } 00046 00047 00048 int Command::getPosition() 00049 { 00050 return _position; 00051 } 00052 00053 int Command::getTime() 00054 { 00055 return _time; 00056 } 00057 00058 int Command::getHomeposition() 00059 { 00060 return _homePosition; 00061 } 00062 00063 bool Command::getPower() 00064 { 00065 return _power; 00066 } 00067 00068 void Command::on() 00069 { 00070 write(getPosition()/1800); 00071 _power = true; 00072 } 00073 00074 void Command::off() 00075 { 00076 _pwm.pulsewidth(0); 00077 _power = false; 00078 } 00079 00080 Command& Command::operator= (float percent) { 00081 if(getPower() == true) 00082 write(percent); 00083 return *this; 00084 } 00085 00086 Command& Command::operator= (Command& rhs) { 00087 if(getPower() == true) 00088 write(rhs.read()); 00089 return *this; 00090 } 00091
Generated on Tue Jul 19 2022 02:08:10 by
1.7.2