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.
Revision 1:95120e07b458, committed 2014-03-31
- Comitter:
- tim008
- Date:
- Mon Mar 31 09:44:51 2014 +0000
- Parent:
- 0:51c364223e27
- Commit message:
- lv5_pai_grupa2_tim008
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 51c364223e27 -r 95120e07b458 main.cpp --- a/main.cpp Mon Mar 31 08:00:48 2014 +0000 +++ b/main.cpp Mon Mar 31 09:44:51 2014 +0000 @@ -1,41 +1,35 @@ -#include "mbed.h" -#include "math.h" -#define freq 1000 +#include <vector> +#include <cmath> -AnalogOut aout(PTE30); +#include "mbed.h" -Ticker tick; +#define STEP_SIZE 50 // in ms +#define STEP_HEIGHT 1/10. +#define PI 3.14 -double step=0.05f; -double value=0.5; -int i=0; -bool m=true; -void triangleFunc() -{ - if(m == true){ - aout=(1.0/3.3)*(value-step*float(i)); - i++; +AnalogOut osciloscope(PTE30); + +int main() { + + // initialize steps + vector<float> steps; + + float current = 1.; + while(current >= 0.) { + steps.push_back(current); + current -= STEP_HEIGHT; } - if(m== false){ - aout=(1./3.3)*(value-step*float(i)); - i--; - } - - if(i>=10) - { - //step=(-step); - m= false; - + while(current <= 1.) { + steps.push_back(current); + current += STEP_HEIGHT; } - if(i<=0) - { - step = (-step); - m= true; - } - -} -int main() -{ - tick.attach_us(&triangleFunc,50); - while(1) { } -} + + int current_step = 0; + while(true) { + osciloscope = steps[current_step++ % steps.size()] / 3.3; + //osciloscope = 1.; + wait_us(STEP_SIZE); + } + + return 0; // redundant +} \ No newline at end of file