Yet another implementation of wave function generator

Dependencies:   mbed vt100

Embed: (wiki syntax)

« Back to documentation index

sqrwave Class Reference

sqrwave square wave class More...

#include <sqrwave.h>

Inherits wave.

Inherited by triwave.

Public Member Functions

 sqrwave (float v, int f, int d=50, int p=0)
 constructor
 ~sqrwave (void)
 destructor
virtual int value (void)
 inspector for the value at _pos
void volt (float newvalue)
 mutator for _amp but in float voltage
float volt (void)
 inspector for _amp but in float voltage
void amp (int newvalue)
 mutator for _amp in int value
int amp (void)
 inspector for _amp
void cycle (int newvalue)
 mutator for _cycle
int cycle (void)
 inspector for _cycle
void phase (int newvalue)
 mutator for _phase
int phase (void)
 inspector for _phase
void freq (int newvalue)
 mutator for _cycle but in frequency (Hz)
int freq (void)
 inspector for _cycle but in frequency (Hz)
void pos (int newvalue)
 mutator for _pos current positon in _cycle
int pos (void)
 insepector for _pos
virtual void duty (int newvalue)
 mutator for _duty the percentage of positive value part
virtual int duty (void)
 inspector for _duty
virtual void update (void)
 update internal value consistancy
virtual void advance (int s=1)
 advance position to be accessed through value()
virtual const char * name (void)
 inspector to return class name

Protected Member Functions

int phase2pos (int p)
 utility function to convert phase to position
int pos2phase (int p)
 utility function to convert position to phase

Detailed Description

sqrwave square wave class

Definition at line 18 of file sqrwave.h.


Constructor & Destructor Documentation

sqrwave ( float  v,
int  f,
int  d = 50,
int  p = 0 
)

constructor

sqrwave class Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab

Parameters:
floatv amplitude in voltage (0.0 ~ 3.28V for FRDM-KL25Z)
intf frequency in Hz (1 ~ 10000Hz)
intd duty in percent (0 ~ 100%) 0% for DC 0V, 100% for DC Vref volt
intp phase in degree (0 ~ 359 degree)
Returns:
sqrwave class instance

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 15 of file sqrwave.cpp.

~sqrwave ( void   )

destructor

Definition at line 20 of file sqrwave.cpp.


Member Function Documentation

void advance ( int  s = 1 ) [virtual, inherited]

advance position to be accessed through value()

Parameters:
ints steps to advance, 1 for default

Definition at line 150 of file wave.cpp.

void amp ( int  newvalue ) [inherited]

mutator for _amp in int value

Parameters:
intnewvalue value for amplitude (0x0000 ~ 0xFFFF)

Definition at line 71 of file wave.cpp.

int amp ( void   ) [inherited]

inspector for _amp

Returns:
amplitude in unsigned short (0x0000 ~ 0xFFFF)

Definition at line 76 of file wave.cpp.

void cycle ( int  newvalue ) [inherited]

mutator for _cycle

Parameters:
intnewvalue length of 1 cycle of the wave

Definition at line 81 of file wave.cpp.

int cycle ( void   ) [inherited]

inspector for _cycle

Returns:
int length of 1 cycle in sample time unit

Definition at line 91 of file wave.cpp.

void duty ( int  newvalue ) [virtual, inherited]

mutator for _duty the percentage of positive value part

Parameters:
intnewvalue new duty value in percent (0~100%)

Reimplemented in sawwave, and sinwave.

Definition at line 140 of file wave.cpp.

int duty ( void   ) [virtual, inherited]

inspector for _duty

Returns:
int duty (0~100%)

Reimplemented in sawwave, and sinwave.

Definition at line 145 of file wave.cpp.

void freq ( int  newvalue ) [inherited]

mutator for _cycle but in frequency (Hz)

Parameters:
intnewvalue frequcney (1 ~ 10000Hz)

Definition at line 112 of file wave.cpp.

int freq ( void   ) [inherited]

inspector for _cycle but in frequency (Hz)

Returns:
int current frequency in Hz (1~10000Hz)

Definition at line 122 of file wave.cpp.

const char * name ( void   ) [virtual, inherited]

inspector to return class name

Definition at line 167 of file wave.cpp.

void phase ( int  newvalue ) [inherited]

mutator for _phase

Parameters:
intnewvalue value for _phase in degree (0 ~ 359 degree)

Definition at line 96 of file wave.cpp.

int phase ( void   ) [inherited]

inspector for _phase

Returns:
int phase in degree (0 ~ 359 degree)

Definition at line 107 of file wave.cpp.

int phase2pos ( int  p ) [protected, inherited]

utility function to convert phase to position

Parameters:
pphase value to be converted to the position
Returns:
position of specified phase

Definition at line 36 of file wave.cpp.

void pos ( int  newvalue ) [inherited]

mutator for _pos current positon in _cycle

Parameters:
intnewvalue (0 ~ _cycle-1)

Definition at line 127 of file wave.cpp.

int pos ( void   ) [inherited]

insepector for _pos

Returns:
int _pos current position in the _cycle

Definition at line 135 of file wave.cpp.

int pos2phase ( int  p ) [protected, inherited]

utility function to convert position to phase

Parameters:
pposition to be converted to the phase
Returns:
phase of specified position

Definition at line 45 of file wave.cpp.

void update ( void   ) [virtual, inherited]

update internal value consistancy

Definition at line 54 of file wave.cpp.

int value ( void   ) [virtual]

inspector for the value at _pos

Returns:
int value at current position

Reimplemented from wave.

Reimplemented in triwave.

Definition at line 22 of file sqrwave.cpp.

float volt ( void   ) [inherited]

inspector for _amp but in float voltage

Returns:
float amplitude in vlot (0.0 ~ 3.28V for FRDM-KL25Z)

Definition at line 66 of file wave.cpp.

void volt ( float  newvalue ) [inherited]

mutator for _amp but in float voltage

Parameters:
floatnewvalue vlotage to assign (0.0 ~ 3.28V for FRDM-KL25Z)

Definition at line 61 of file wave.cpp.