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.
Fork of ProcVisDemo by
FunkGen.cpp
00001 00002 #include "FunkGen.h" 00003 00004 SignedRampGen::SignedRampGen() 00005 { 00006 val = 0; 00007 SetPointsPerPeriod(10); // Default ist 10Pts/Periode 00008 } 00009 00010 void SignedRampGen::SetPointsPerPeriod(float aPoints) 00011 { 00012 _inc = 2.0/aPoints; 00013 } 00014 00015 void SignedRampGen::SetFrequ(float aFrequ) 00016 { 00017 SetPointsPerPeriod(1.0/aFrequ); 00018 } 00019 00020 void SignedRampGen::CalcOneStep() 00021 { 00022 val = val + _inc; 00023 if( val>1.0 ) 00024 val = -1 + (val - 1.0); 00025 } 00026 00027 00028 00029 TriangleGen::TriangleGen() 00030 { 00031 val=_phase=0; 00032 SetPointsPerPeriod(100); 00033 } 00034 00035 void TriangleGen::SetPointsPerPeriod(float aPoints) 00036 { 00037 _inc = 4.0/aPoints; 00038 } 00039 00040 void TriangleGen::SetFrequ(float aFrequ) 00041 { 00042 SetPointsPerPeriod(1.0/aFrequ); 00043 } 00044 00045 void TriangleGen::CalcOneStep() 00046 { 00047 _phase = _phase + _inc; 00048 if( _phase>1.0 ) { 00049 _phase = -1 + (_phase - 1.0); 00050 if( _state==1 ) 00051 _state=2; 00052 else 00053 _state=1; 00054 } 00055 if( _state==1 ) 00056 val = _phase; 00057 else 00058 val = -_phase; 00059 } 00060 00061 00062 00063 RectGen::RectGen() 00064 { 00065 val=0; _phase=0; _thrs=0; 00066 SetPointsPerPeriod(10); // Default ist 10Pts/Periode 00067 } 00068 00069 void RectGen::SetPointsPerPeriod(float aPoints) 00070 { 00071 _inc = 2.0/aPoints; 00072 } 00073 00074 void RectGen::SetFrequ(float aFrequ) 00075 { 00076 SetPointsPerPeriod(1.0/aFrequ); 00077 } 00078 00079 void RectGen::SetPulsWidth(float aPercent) 00080 { 00081 _thrs = 1.0-aPercent; 00082 } 00083 00084 void RectGen::CalcOneStep() 00085 { 00086 _phase = _phase + _inc; 00087 if( _phase>1.0 ) 00088 _phase = -1 + (_phase - 1.0); 00089 if( _phase>_thrs ) 00090 val = 1.0; 00091 else 00092 val = -1.0; 00093 } 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111
Generated on Sat Jul 30 2022 21:10:34 by
