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.
sqrwave.cpp
00001 /** sqrwave 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 00013 #include "sqrwave.h" 00014 00015 sqrwave::sqrwave(float v, int f, int d, int p ) : wave(v, f, d, p) 00016 { 00017 _name = "sqr" ; 00018 } 00019 00020 sqrwave::~sqrwave(void) { } 00021 00022 int sqrwave::value(void) 00023 { 00024 int result = 0 ; 00025 if (_duty == 100) { 00026 result = _amp ; 00027 } else if (_duty == 0) { 00028 result = 0 ; 00029 } else if (_pos < (int)((_duty * _cycle)/100)) { 00030 result = _amp ; 00031 } 00032 return( result ) ; 00033 }
Generated on Wed Jul 13 2022 01:58:56 by
1.7.2