first release. It is in the process of creation. Library for Motorfader https://www.switch-science.com/catalog/1285/

Dependents:   nekosensya

Committer:
abanum
Date:
Mon Jul 29 05:42:03 2019 +0000
Revision:
0:6b9fc326f973
first release.; It is in the process of creation.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
abanum 0:6b9fc326f973 1 /* mbed Motorfader Library
abanum 0:6b9fc326f973 2 * Copyright (c) 2019 abanum
abanum 0:6b9fc326f973 3 *
abanum 0:6b9fc326f973 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
abanum 0:6b9fc326f973 5 * of this software and associated documentation files (the "Software"), to deal
abanum 0:6b9fc326f973 6 * in the Software without restriction, including without limitation the rights
abanum 0:6b9fc326f973 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
abanum 0:6b9fc326f973 8 * copies of the Software, and to permit persons to whom the Software is
abanum 0:6b9fc326f973 9 * furnished to do so, subject to the following conditions:
abanum 0:6b9fc326f973 10 *
abanum 0:6b9fc326f973 11 * The above copyright notice and this permission notice shall be included in
abanum 0:6b9fc326f973 12 * all copies or substantial portions of the Software.
abanum 0:6b9fc326f973 13 *
abanum 0:6b9fc326f973 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
abanum 0:6b9fc326f973 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
abanum 0:6b9fc326f973 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
abanum 0:6b9fc326f973 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
abanum 0:6b9fc326f973 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
abanum 0:6b9fc326f973 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
abanum 0:6b9fc326f973 20 * THE SOFTWARE.
abanum 0:6b9fc326f973 21 */
abanum 0:6b9fc326f973 22
abanum 0:6b9fc326f973 23 #ifndef MBED_Motorfader_H
abanum 0:6b9fc326f973 24 #define MBED_Motorfader_H
abanum 0:6b9fc326f973 25
abanum 0:6b9fc326f973 26 #include "mbed.h"
abanum 0:6b9fc326f973 27
abanum 0:6b9fc326f973 28 /** Motorfader control class, based on a PwmOut
abanum 0:6b9fc326f973 29 *
abanum 0:6b9fc326f973 30 * Example:
abanum 0:6b9fc326f973 31 * @code
abanum 0:6b9fc326f973 32 * // Continuously sweep the servo through it's full range
abanum 0:6b9fc326f973 33 * #include "mbed.h"
abanum 0:6b9fc326f973 34 * #include "WT20003M03.h"
abanum 0:6b9fc326f973 35 *
abanum 0:6b9fc326f973 36 * WT20003M03 myaudio(p21);
abanum 0:6b9fc326f973 37 *
abanum 0:6b9fc326f973 38 * int main() {
abanum 0:6b9fc326f973 39 mysound.volume(8);
abanum 0:6b9fc326f973 40 * while(1) {
abanum 0:6b9fc326f973 41 * myaudio.play();
abanum 0:6b9fc326f973 42 * wait(10);
abanum 0:6b9fc326f973 43 * }
abanum 0:6b9fc326f973 44 * }
abanum 0:6b9fc326f973 45 * @endcode
abanum 0:6b9fc326f973 46 */
abanum 0:6b9fc326f973 47 class Motorfader {
abanum 0:6b9fc326f973 48
abanum 0:6b9fc326f973 49 public:
abanum 0:6b9fc326f973 50 /** Create a servo object connected to the specified PwmOut pin
abanum 0:6b9fc326f973 51 *
abanum 0:6b9fc326f973 52 * @param pin DigitalOut pin to connect to
abanum 0:6b9fc326f973 53 */
abanum 0:6b9fc326f973 54 Motorfader(PinName analogpin,PinName cwpin,PinName ccwpin);
abanum 0:6b9fc326f973 55
abanum 0:6b9fc326f973 56 /** Set position
abanum 0:6b9fc326f973 57 *
abanum 0:6b9fc326f973 58 * @param addres
abanum 0:6b9fc326f973 59 */
abanum 0:6b9fc326f973 60 void set(float pos,float vel);
abanum 0:6b9fc326f973 61
abanum 0:6b9fc326f973 62 /** Get position
abanum 0:6b9fc326f973 63 *
abanum 0:6b9fc326f973 64 * @param Read volume.
abanum 0:6b9fc326f973 65 */
abanum 0:6b9fc326f973 66 float get();
abanum 0:6b9fc326f973 67
abanum 0:6b9fc326f973 68 void update();
abanum 0:6b9fc326f973 69
abanum 0:6b9fc326f973 70 protected:
abanum 0:6b9fc326f973 71 AnalogIn _faderPos;
abanum 0:6b9fc326f973 72 PwmOut _cwpwm;
abanum 0:6b9fc326f973 73 PwmOut _ccwpwm;
abanum 0:6b9fc326f973 74 float _setPos;
abanum 0:6b9fc326f973 75 float _setVel;
abanum 0:6b9fc326f973 76 float _nowPos;
abanum 0:6b9fc326f973 77 float _oldPos;
abanum 0:6b9fc326f973 78 // unsigned int _volume;
abanum 0:6b9fc326f973 79 };
abanum 0:6b9fc326f973 80
abanum 0:6b9fc326f973 81 #endif