Nicolas Gonzalez gil / Mbed 2 deprecated Debug_ejemplo

Dependencies:   mbed

main.cpp

Committer:
Nicolas_11
Date:
2018-08-17
Revision:
0:6d24223c84c7

File content as of revision 0:6d24223c84c7:

#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);
       

}
   }