DIC DAC Beispiel

Dependencies:   mbed

Revision:
1:c8943c51b10d
Parent:
0:2aca3f53fe79
--- a/main.cpp	Mon Jan 13 09:22:46 2020 +0000
+++ b/main.cpp	Mon Jan 13 10:14:10 2020 +0000
@@ -6,7 +6,7 @@
 Ticker valueTicker;
 float voltageValues[100];   // 100 Punkte
 int actualPoint;            // Aktueller Punkt
-int outputMode = 1;         // 1 = Sägezahn, 2 = Rechteck, 3 = Sinus
+int outputMode = 4;         // 1 = Sägezahn, 2 = Rechteck, 3 = Sinus, 4 = Dreieck
 
 void outputToDAC()
 {
@@ -27,7 +27,7 @@
         switch(outputMode)
         {
             case 1:
-                voltageValues[i] = (float)i / 100.0f;;
+                voltageValues[i] = (float)i / 100.f;;
                 break;
             case 2:
                 voltageValues[i] = i <= 49 ? 1 : 0;
@@ -35,12 +35,13 @@
             case 3:
                 voltageValues[i] = 0.5f * sin(((float)i * PI) * 3.6f / 180) + 0.5f; // w = 6283 = 2 * PI * f
                 break;
+            case 4:
+                voltageValues[i] = (i > 50 ? i * 2 - 100.f : 100.f - i * 2 ) / 100.f;
+                break;
         }
     }
     
     valueTicker.attach_us(&outputToDAC, 10);
     
-    while(1)
-    {
-    }
+    while(1);
 }