yuhang zhu / Mbed 2 deprecated ADAM_menu

Dependencies:   mbed

Revision:
14:fb67a8b1d1a5
Parent:
13:8d9c273b607d
Child:
15:3f3560332bc1
--- a/main.cpp	Sun Jul 14 23:21:15 2013 +0000
+++ b/main.cpp	Mon Jul 15 22:09:25 2013 +0000
@@ -52,7 +52,7 @@
             case MODE_IDLE:
                 pc.printf("%s", main_menu);
                 recv = pc.getc();
-                mode_idle_handler(&state, recv);
+                mode_idle_handler(&state, recv);  //change state based on recv input
                 //pc.printf("%d", state);
                 break;
                 
@@ -216,10 +216,10 @@
             // In display mode, show current parameters
             case MODE_DISPLAY:
                 
-                pc.printf("Phase shift value for channel 1 is %d degrees\n", cha1_pha*-7);
-                pc.printf("Attentuation for channel 1 is %.1f dB\n", cha1_amp*5.0/10.0);
-                pc.printf("Phase shift value for channel 2 is %d degrees\n", cha2_pha*-7);
-                pc.printf("Attentuation for channel 2 is %.1f dB\n", cha2_amp*5.0/10.0);
+                pc.printf("Phase shift  for RF out1 is %d degrees\n", cha1_pha*-7);
+                pc.printf("Attentuation for RF out1 is %.1f dB\n", cha1_amp*5.0/10.0);
+                pc.printf("Phase shift  for RF out2 is %d degrees\n", cha2_pha*-7);
+                pc.printf("Attentuation for RF out2 is %.1f dB\n", cha2_amp*5.0/10.0);
                 pc.printf("%s", msg_ret);
                 pc.getc();
                 state = MODE_IDLE;
@@ -235,35 +235,35 @@
                 
             case MODE_SEND:  //In sending mode, display and send through SPI
                 
-                pc.printf("Phase shift value for channel 1 is %d degrees\n", cha1_pha*-7);
-                pc.printf("Attentuation for channel 1 is %.1f dB\n", cha1_amp*5.0/10.0);
-                pc.printf("Phase shift value for channel 2 is %d degrees\n", cha2_pha*-7);
-                pc.printf("Attentuation for channel 2 is %.1f dB\n", cha2_amp*5.0/10.0);
+                pc.printf("Phase shift  for RF out1 is %d degrees\n", cha1_pha*-7);
+                pc.printf("Attentuation for RF out1 is %.1f dB\n", cha1_amp*5.0/10.0);
+                pc.printf("Phase shift  for RF out2 is %d degrees\n", cha2_pha*-7);
+                pc.printf("Attentuation for RF out2 is %.1f dB\n", cha2_amp*5.0/10.0);
                 pc.printf("\nSPI bit stream:\n");
-                for(i=15; i>=0; i--)
-                    pc.printf("Bit%d ", i);
+                for(i=7; i>=0; i--)
+                    pc.printf("b%d ", i);
+                
+                pc.printf("   ");
+                
+                for(i=7; i>=0; i--)
+                    pc.printf("a%d ", i);
                 pc.printf("\n");
                 spi_stream = 0;
                 
                 spi_stream = (cha2_amp << 12) | (cha2_pha << 8) | (cha1_amp << 4) | (cha1_pha);
                 
-                
+                //Output the SPI bit stream for user reference
                 for(i=0; i<=15; i++)
                 {
+                    
                     if(spi_stream >= 0x8000)
-                    {
-                        if(i < 6)
-                            pc.printf("%d     ", 1);
-                        else
-                            pc.printf("%d    ", 1);
-                    }
+                        pc.printf("%d  ", 1);
                     else
-                    {
-                        if(i < 6)
-                            pc.printf("%d     ", 0);
-                        else
-                            pc.printf("%d    ", 0);
-                    }
+                        pc.printf("%d  ", 0);
+                    
+                    if(i == 7)
+                        pc.printf("   ");
+                        
                     spi_stream = spi_stream << 1;
                 }