LinkNode_SimpleControls

Dependencies:   BLE_API mbed nRF51822

Fork of LinkNode_SimpleControls by Delong Qi

Committer:
RedBearLab
Date:
Fri Oct 31 14:42:08 2014 +0000
Revision:
1:f03072e32ed3
Parent:
0:dfcebc1e442a
Add licence in files

Who changed what in which revision?

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