Yet another implementation of wave function generator

Dependencies:   mbed vt100

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers triwave.h Source File

triwave.h

00001 /** triwave class
00002  * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab
00003  *
00004  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00005  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00006  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00007  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00008  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00009  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00010  * THE SOFTWARE.
00011  */
00012 #ifndef _TRI_WAVE_H_
00013 #define _TRI_WAVE_H_ included
00014 #include "sqrwave.h"
00015 
00016 /** triwave triangle wave class
00017  */
00018 class triwave : public sqrwave {
00019 public:
00020 /** constructor
00021  *
00022  * @param float v amplitude in voltage (0.0 ~ 3.28V for FRDM-KL25Z)
00023  * @param int f frequency in Hz (1 ~ 10000Hz)
00024  * @param int d duty of rising ramp in percent (0 ~ 100%) 0% for saw wave, 100% for reversed saw wave
00025  * @param int p phase in degree (0 ~ 359 degree)
00026  * @returns sqrwave class instance
00027  */
00028 triwave(float v, int c, int d = 50, int p = 0) ;
00029 
00030 /** destructor */
00031 ~triwave(void) ;
00032 
00033 /** inspector for the value at _pos
00034  *
00035  * @returns int value at current position
00036  */
00037 virtual int value(void) ;       // return s current value
00038 } ;
00039 
00040 #endif /* _TRI_WAVE_H_ */