un triangle sympathique

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
GabGabyz
Date:
Fri Jan 06 08:20:24 2017 +0000
Commit message:
Un triangle

Changed in this revision

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 06 08:20:24 2017 +0000
@@ -0,0 +1,78 @@
+
+#include "mbed.h"
+
+AnalogOut my_output(PA_4);
+
+#define PI        (3.141592653589793238462)
+#define AMPLITUDE (1.0)    // x * 3.3V
+#define PHASE     (PI * 1) // 2*pi is one period
+#define RANGE     (0x7FFF)
+#define OFFSET    (0x7FFF)
+
+// Configuration for sinewave output
+#define BUFFER_SIZE (360)
+//uint16_t buffer[BUFFER_SIZE];
+
+int i;
+/*
+int main() {
+    while(1) {      
+        // triangle output
+        for (i = 0; i < 1000; i++) {
+            i=0*i;
+            my_output.write_u16(i);
+            wait_us(100);
+            i=2*i;
+            my_output.write_u16(2*i);
+            wait_us(100);
+        }*/
+        
+        /*
+        for (i = 65535; i>0; i--) {
+            my_output.write_u16(i);
+            //wait_us(10);
+    }*/
+
+
+
+int main() {
+    while(1) {      
+        // triangle output
+        for (i = 0; i < 65536; i++) {
+            my_output.write_u16(i);
+           // wait_us(10);
+        }
+        
+        for (i = 65535; i>0; i--) {
+            my_output.write_u16(i);
+            //wait_us(10);
+    }
+}
+}
+
+
+
+
+
+/*
+//void calculate_sinewave(void);
+int main() {
+    printf("Sinewave example\n");
+    calculate_sinewave();
+    while(1) {      
+        // sinewave output
+        for (int i = 0; i < BUFFER_SIZE; i++) {
+            my_output.write_u16(buffer[i]);
+            wait_us(10);
+        }
+    }
+}
+
+// Create the sinewave buffer
+void calculate_sinewave(void){
+  for (int i = 0; i < BUFFER_SIZE; i++) {
+     double rads = (PI * i)/180.0; // Convert degree in radian
+     buffer[i] = (uint16_t)(AMPLITUDE * (RANGE * (cos(rads + PHASE))) + OFFSET);
+  }
+}
+*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 06 08:20:24 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file