Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Motorfader.h
00001 /* mbed Motorfader Library 00002 * Copyright (c) 2019 abanum 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 */ 00022 00023 #ifndef MBED_Motorfader_H 00024 #define MBED_Motorfader_H 00025 00026 #include "mbed.h" 00027 00028 /** Motorfader control class, based on a PwmOut 00029 * 00030 * Example: 00031 * @code 00032 * // Continuously sweep the servo through it's full range 00033 * #include "mbed.h" 00034 * #include "WT20003M03.h" 00035 * 00036 * WT20003M03 myaudio(p21); 00037 * 00038 * int main() { 00039 mysound.volume(8); 00040 * while(1) { 00041 * myaudio.play(); 00042 * wait(10); 00043 * } 00044 * } 00045 * @endcode 00046 */ 00047 class Motorfader { 00048 00049 public: 00050 /** Create a servo object connected to the specified PwmOut pin 00051 * 00052 * @param pin DigitalOut pin to connect to 00053 */ 00054 Motorfader(PinName analogpin,PinName cwpin,PinName ccwpin); 00055 00056 /** Set position 00057 * 00058 * @param addres 00059 */ 00060 void set(float pos,float vel); 00061 00062 /** Get position 00063 * 00064 * @param Read volume. 00065 */ 00066 float get(); 00067 00068 void update(); 00069 00070 protected: 00071 AnalogIn _faderPos; 00072 PwmOut _cwpwm; 00073 PwmOut _ccwpwm; 00074 float _setPos; 00075 float _setVel; 00076 float _nowPos; 00077 float _oldPos; 00078 // unsigned int _volume; 00079 }; 00080 00081 #endif
Generated on Tue Jul 12 2022 15:40:53 by
1.7.2