yuhang zhu / Mbed 2 deprecated ADAM_menu

Dependencies:   mbed

Revision:
8:f0c3d5911b87
Parent:
7:c268547fb6c8
Child:
9:3eaacc1ad758
--- a/main.cpp	Sat Jul 13 22:16:27 2013 +0000
+++ b/main.cpp	Sat Jul 13 23:16:29 2013 +0000
@@ -2,6 +2,7 @@
 #include "menu.h"
 #include "parameters.h"
 #include "handlers.h"
+//#define DEBUG
 
 Serial pc(USBTX, USBRX);
 
@@ -66,9 +67,11 @@
                             line_buf[3] = LINEBUF_TOOLONG;
                         else
                             line_buf[3] = LINEBUF_OK;
-                            
-                        //pc.printf("decimal output : %d %d %d %d", line_buf[3], line_buf[2], line_buf[1], line_buf[0]);
-                        //pc.printf("char output: %c %c %c %c", line_buf[3], line_buf[2], line_buf[1], line_buf[0]);   
+                        #ifdef DEBUG    
+                        pc.printf("decimal output : %d %d %d %d", line_buf[3], line_buf[2], line_buf[1], line_buf[0]);
+                        pc.printf("char output: %c %c %c %c", line_buf[3], line_buf[2], line_buf[1], line_buf[0]);
+                        #endif
+                           
                         break;  
                     }
                     else if(recv == 8)   //backspace is pressed, delete one character both on screen and line buffer
@@ -135,7 +138,9 @@
                    else   //Input is good
                    {    
                         pc.printf("%s", msg_ok);
+                        #ifdef DEBUG
                         pc.printf("%d %d\n", cha1_pha*7, cha2_pha*7);
+                        #endif
                         pc.printf("%s", msg_ret);
                         pc.getc();
                    }
@@ -168,9 +173,9 @@
                    else if(ret == PARSE_ROUNDED) //Input is rounded, show the rounded value
                    {    
                         if(state == MODE_CHA1AMP)
-                            pc.printf("%s %d\n", msg_rounded, cha1_amp*5);
+                            pc.printf("%s %.1f\n", msg_rounded, cha1_amp*5.0/10.0);
                         else if(state == MODE_CHA2AMP)
-                            pc.printf("%s %d\n", msg_rounded, cha2_amp*5);
+                            pc.printf("%s %.1f\n", msg_rounded, cha2_amp*5.0/10.0);
                             
                         pc.printf("%s", msg_ret);
                         pc.getc();
@@ -178,7 +183,9 @@
                    else   //Input is good
                    {    
                         pc.printf("%s", msg_ok);
+                        #ifdef DEBUG
                         pc.printf("%d %d\n", cha1_amp*5, cha2_amp*5);
+                        #endif
                         pc.printf("%s", msg_ret);
                         pc.getc();
                    }
@@ -186,6 +193,16 @@
                 state = MODE_IDLE;  //back to idle state after input
                 break;
             
+            // in display mode
+            case MODE_DISPLAY:
+                pc.printf("Current phase shift value for channel 1 is %d degrees\n", cha1_pha*-7);
+                pc.printf("Current phase shift value for channel 2 is %d degrees\n", cha2_pha*-7);
+                pc.printf("Current attentuation for channel 1 is %.1f dB\n", cha1_amp*5.0/10.0);
+                pc.printf("Current attentuation for channel 2 is %.1f dB\n", cha2_amp*5.0/10.0);
+                pc.printf("%s", msg_ret);
+                pc.getc();
+                state = MODE_IDLE;
+                break;
         }