Analog Out sine wave

Dependencies:   LSM9DS1_Library mbed

Files at this revision

API Documentation at this revision

Comitter:
CRaslawski
Date:
Mon Feb 27 22:25:09 2017 +0000
Commit message:
initial upload

Changed in this revision

LSM9DS1_Library.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 9d458257852d LSM9DS1_Library.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM9DS1_Library.lib	Mon Feb 27 22:25:09 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/jmar7/code/LSM9DS1_Library/#87d535bf8c53
diff -r 000000000000 -r 9d458257852d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 27 22:25:09 2017 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+
+//double CosineInterpolate(
+//    double y1, double y2,
+//    double mu)
+//{
+//    double mu2;
+//    
+//    mu2 = (1-cos(mu*PI))/2;
+//    return(y1*(1-mu2)+y2*mu2);
+//}
+
+AnalogOut scope(p18);
+
+int main() {
+    
+    //double voltOut;
+//    double logicOut;
+//    
+//    while(1) {
+//        scope = 
+//    }
+
+    const double pi = 3.141592653589793238462;
+    const double amplitude = 0.5f;
+    const double offset = 65535/2;
+    double rad = 0.0;
+    uint16_t sample = 0;
+    
+    while(1) {
+        for(int i = 0; i < 360; i++){
+            rad = (pi * i) / 180.0f;
+            sample = (uint16_t)(amplitude * (offset * (cos(rads + pi))) + offset);
+            aout.write_u16(sample);
+        }    
+    }
+}
diff -r 000000000000 -r 9d458257852d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 27 22:25:09 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/176b8275d35d
\ No newline at end of file