Nicolas Gonzalez gil
/
Debug_ejemplo
Ejemplo de uso de "DEBUG" n\
Diff: main.cpp
- Revision:
- 0:6d24223c84c7
diff -r 000000000000 -r 6d24223c84c7 main.cpp --- /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); + + +} + } +