![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
BMP180 Digital temperature sensor, BLE, & human body infrared sensor
Dependencies: BLE_API BMP180 mbed nRF51822
Fork of BMP180_example by
Servo.cpp@3:b67c5cc2ac61, 2016-04-28 (annotated)
- Committer:
- geekfamily
- Date:
- Thu Apr 28 06:29:59 2016 +0000
- Revision:
- 3:b67c5cc2ac61
Healthy in Office
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
geekfamily | 3:b67c5cc2ac61 | 1 | /* |
geekfamily | 3:b67c5cc2ac61 | 2 | |
geekfamily | 3:b67c5cc2ac61 | 3 | Copyright (c) 2012-2014 RedBearLab |
geekfamily | 3:b67c5cc2ac61 | 4 | |
geekfamily | 3:b67c5cc2ac61 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
geekfamily | 3:b67c5cc2ac61 | 6 | and associated documentation files (the "Software"), to deal in the Software without restriction, |
geekfamily | 3:b67c5cc2ac61 | 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, |
geekfamily | 3:b67c5cc2ac61 | 8 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, |
geekfamily | 3:b67c5cc2ac61 | 9 | subject to the following conditions: |
geekfamily | 3:b67c5cc2ac61 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
geekfamily | 3:b67c5cc2ac61 | 11 | |
geekfamily | 3:b67c5cc2ac61 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
geekfamily | 3:b67c5cc2ac61 | 13 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
geekfamily | 3:b67c5cc2ac61 | 14 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE |
geekfamily | 3:b67c5cc2ac61 | 15 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
geekfamily | 3:b67c5cc2ac61 | 16 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
geekfamily | 3:b67c5cc2ac61 | 17 | |
geekfamily | 3:b67c5cc2ac61 | 18 | */ |
geekfamily | 3:b67c5cc2ac61 | 19 | |
geekfamily | 3:b67c5cc2ac61 | 20 | #include "Servo.h" |
geekfamily | 3:b67c5cc2ac61 | 21 | |
geekfamily | 3:b67c5cc2ac61 | 22 | Servo::Servo(PinName pin) : _servo(pin) |
geekfamily | 3:b67c5cc2ac61 | 23 | { |
geekfamily | 3:b67c5cc2ac61 | 24 | _servo.period_ms(20); |
geekfamily | 3:b67c5cc2ac61 | 25 | } |
geekfamily | 3:b67c5cc2ac61 | 26 | |
geekfamily | 3:b67c5cc2ac61 | 27 | Servo::~Servo(void) |
geekfamily | 3:b67c5cc2ac61 | 28 | { |
geekfamily | 3:b67c5cc2ac61 | 29 | |
geekfamily | 3:b67c5cc2ac61 | 30 | } |
geekfamily | 3:b67c5cc2ac61 | 31 | |
geekfamily | 3:b67c5cc2ac61 | 32 | void Servo::write(unsigned char degree) |
geekfamily | 3:b67c5cc2ac61 | 33 | { |
geekfamily | 3:b67c5cc2ac61 | 34 | convert(degree); |
geekfamily | 3:b67c5cc2ac61 | 35 | _servo.pulsewidth_us(pulse); |
geekfamily | 3:b67c5cc2ac61 | 36 | } |
geekfamily | 3:b67c5cc2ac61 | 37 | |
geekfamily | 3:b67c5cc2ac61 | 38 | void Servo::convert(unsigned char degree) |
geekfamily | 3:b67c5cc2ac61 | 39 | { |
geekfamily | 3:b67c5cc2ac61 | 40 | // 0~180 degree correspond to 500~2500 |
geekfamily | 3:b67c5cc2ac61 | 41 | pulse = degree * 11 + 500; |
geekfamily | 3:b67c5cc2ac61 | 42 | } |