![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
asdf
Dependencies: Servo mbed mbedConnectorInterface mbedEndpointNetwork
Fork of TempAndDistTest by
resource/ServoResource.cpp@4:20feba0e781b, 2015-05-09 (annotated)
- Committer:
- mnorris
- Date:
- Sat May 09 19:00:40 2015 +0000
- Revision:
- 4:20feba0e781b
- Parent:
- 3:c17adf68862b
Bug fixes, uses PUT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mnorris | 3:c17adf68862b | 1 | #include "ServoResource.h" |
mnorris | 3:c17adf68862b | 2 | |
mnorris | 3:c17adf68862b | 3 | void ServoResource::on() { |
mnorris | 3:c17adf68862b | 4 | servo->Enable(1500, 20000); |
mnorris | 3:c17adf68862b | 5 | while(1) { |
mnorris | 3:c17adf68862b | 6 | for (int pos = 500; pos < 2500; pos += 25) { |
mnorris | 3:c17adf68862b | 7 | servo->SetPosition(pos); |
mnorris | 3:c17adf68862b | 8 | wait_ms(5); |
mnorris | 3:c17adf68862b | 9 | } |
mnorris | 3:c17adf68862b | 10 | for (int pos = 2500; pos > 500; pos -= 25) { |
mnorris | 3:c17adf68862b | 11 | servo->SetPosition(pos); |
mnorris | 3:c17adf68862b | 12 | wait_ms(5); |
mnorris | 3:c17adf68862b | 13 | } |
mnorris | 3:c17adf68862b | 14 | } |
mnorris | 3:c17adf68862b | 15 | } |
mnorris | 3:c17adf68862b | 16 | |
mnorris | 3:c17adf68862b | 17 | void ServoResource::off() { |
mnorris | 3:c17adf68862b | 18 | servo->Disable(); |
mnorris | 3:c17adf68862b | 19 | } |
mnorris | 3:c17adf68862b | 20 | |
mnorris | 3:c17adf68862b | 21 | string ServoResource::get() { |
mnorris | 3:c17adf68862b | 22 | return ""; |
mnorris | 4:20feba0e781b | 23 | } |
mnorris | 4:20feba0e781b | 24 | |
mnorris | 4:20feba0e781b | 25 | void ServoResource::put(const string input) { |
mnorris | 4:20feba0e781b | 26 | if (input == "on") { |
mnorris | 4:20feba0e781b | 27 | on(); |
mnorris | 4:20feba0e781b | 28 | } |
mnorris | 4:20feba0e781b | 29 | else { |
mnorris | 4:20feba0e781b | 30 | off(); |
mnorris | 4:20feba0e781b | 31 | } |
mnorris | 4:20feba0e781b | 32 | } |