Ejemplo de uso de "DEBUG" n\

Dependencies:   mbed

Revision:
0:6d24223c84c7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 17 12:43:16 2018 +0000
@@ -0,0 +1,66 @@
+#include "mbed.h"
+#define DEBUG 1
+Serial a(USBTX,USBRX);
+int op1;
+int op2;
+int tp;
+float  r;
+
+void Debugm(char *s,...){
+  #if DEBUG
+    a.printf(">>>>DEBUG \t ");
+    a.printf(s);
+    #endif
+    }
+    
+int main() {
+   a.baud(9600);
+   Debugm("inniciando programa en modo DEBUG\n");
+   while(1)
+   {    
+         #if DEBUG
+         Debugm("ingresa N1:\n");
+        #endif
+         op1=a.getc();
+        #if DEBUG
+         Debugm("ingresa N2:\n");
+        #endif 
+         op2=a.getc();
+        #if DEBUG
+         Debugm("ingresa OP:\n");
+        #endif 
+         tp=a.getc();
+       switch(tp){
+          case 1:r=op1*op2;
+                #if DEBUG
+                Debugm("Respuesta =:%f\n",r);
+               
+               #endif
+              break;
+          case 2:r=op1/op2;
+               #if DEBUG
+                Debugm("Respuesta =:%f \n",r);
+                #endif 
+                break;
+          case 3:r=op1+op2;
+                #if DEBUG            
+                Debugm("Respuesta =:%f\n",r);
+                #endif 
+                break;
+          case 4:r=op1-op2;
+                #if DEBUG
+                Debugm("Respuesta =:%f\n",r);
+                #endif
+                break;
+          default: 
+              #if DEBUG
+                Debugm("error de operación =:%f\n",tp);
+                #endif 
+                break;
+       }
+        a.printf("%f \n", r);
+       
+
+}
+   }
+