publishing repo to mbed

Dependencies:   BLE_API mbed nRF51822

Committer:
dgdosen
Date:
Fri Feb 20 21:20:22 2015 +0000
Revision:
0:a7eab842b9e5
stock ble nano starter project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dgdosen 0:a7eab842b9e5 1 /*
dgdosen 0:a7eab842b9e5 2
dgdosen 0:a7eab842b9e5 3 Copyright (c) 2012-2014 RedBearLab
dgdosen 0:a7eab842b9e5 4
dgdosen 0:a7eab842b9e5 5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
dgdosen 0:a7eab842b9e5 6 and associated documentation files (the "Software"), to deal in the Software without restriction,
dgdosen 0:a7eab842b9e5 7 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
dgdosen 0:a7eab842b9e5 8 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
dgdosen 0:a7eab842b9e5 9 subject to the following conditions:
dgdosen 0:a7eab842b9e5 10 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
dgdosen 0:a7eab842b9e5 11
dgdosen 0:a7eab842b9e5 12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
dgdosen 0:a7eab842b9e5 13 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
dgdosen 0:a7eab842b9e5 14 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
dgdosen 0:a7eab842b9e5 15 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
dgdosen 0:a7eab842b9e5 16 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dgdosen 0:a7eab842b9e5 17
dgdosen 0:a7eab842b9e5 18 */
dgdosen 0:a7eab842b9e5 19
dgdosen 0:a7eab842b9e5 20 #include "Servo.h"
dgdosen 0:a7eab842b9e5 21
dgdosen 0:a7eab842b9e5 22 Servo::Servo(PinName pin) : _servo(pin)
dgdosen 0:a7eab842b9e5 23 {
dgdosen 0:a7eab842b9e5 24 _servo.period_ms(20);
dgdosen 0:a7eab842b9e5 25 }
dgdosen 0:a7eab842b9e5 26
dgdosen 0:a7eab842b9e5 27 Servo::~Servo(void)
dgdosen 0:a7eab842b9e5 28 {
dgdosen 0:a7eab842b9e5 29
dgdosen 0:a7eab842b9e5 30 }
dgdosen 0:a7eab842b9e5 31
dgdosen 0:a7eab842b9e5 32 void Servo::write(unsigned char degree)
dgdosen 0:a7eab842b9e5 33 {
dgdosen 0:a7eab842b9e5 34 convert(degree);
dgdosen 0:a7eab842b9e5 35 _servo.pulsewidth_us(pulse);
dgdosen 0:a7eab842b9e5 36 }
dgdosen 0:a7eab842b9e5 37
dgdosen 0:a7eab842b9e5 38 void Servo::convert(unsigned char degree)
dgdosen 0:a7eab842b9e5 39 {
dgdosen 0:a7eab842b9e5 40 // 0~180 degree correspond to 500~2500
dgdosen 0:a7eab842b9e5 41 pulse = degree * 11 + 500;
dgdosen 0:a7eab842b9e5 42 }