=3=

Dependencies:   mbed

Fork of Nucleo_serial_menu by FRA221_2015

Revision:
0:f4e546303b4e
Child:
1:59178970c02b
diff -r 000000000000 -r f4e546303b4e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Oct 18 10:09:46 2015 +0000
@@ -0,0 +1,145 @@
+#include "mbed.h"
+
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+DigitalOut myled(LED1);
+
+int main()
+{
+
+    uint8_t state_menu=0;
+    uint8_t state_show=0;
+    uint8_t state_exit =0;
+    uint8_t data;
+
+    myled = 0;
+    pc.printf("Hello World !\n");
+    while(1) {
+        if(state_show == 0) {
+            pc.printf("Menu\n");
+            pc.printf("1.LED Test\n");
+            pc.printf("2.Print Test\n");
+            state_show =1;
+        }
+        if(pc.readable()) {
+            data = pc.getc();
+            pc.printf("\n");
+            state_show =0;
+            state_exit =0;
+
+            switch(data) {
+                case '1':
+                    do {
+                        if(state_menu == 0) {
+                            pc.printf("LED Test\n");
+                            pc.printf("a.LED ON\n");
+                            pc.printf("s.LED OFF\n");
+                            pc.printf("x.Exit\n");
+                            state_menu = 1;
+                        }
+                        if(pc.readable()) {
+                            data = pc.getc();
+                            pc.printf("\n");
+                            state_menu=0;
+
+                            switch(data) {
+
+                                case 'a':
+                                    myled = 1;                                    
+                                    break;
+
+                                case 's':
+                                    myled =0;
+                                   
+                                    break;
+
+                                case 'x':
+                                    state_exit =1;
+                                   
+                                    break;
+
+                                default:
+                                    pc.printf("plz select a or s\n");
+                                    pc.printf("\n\n");
+                                    break;
+
+                            }
+                        }
+
+
+
+                    } while(state_exit ==0);
+                    pc.printf("\n\n");
+                    break;
+
+                case '2':
+
+                    do {
+                        if(state_menu == 0) {
+                            pc.printf("LED Test\n");
+                            pc.printf("a.Menu 2 TEST\n");
+                            pc.printf("s.Run\n");
+                            pc.printf("x.Exit\n");
+                            state_menu = 1;
+                        }
+                        if(pc.readable()) {
+                            data = pc.getc();
+                            pc.printf("\n");
+                            state_menu=0;
+
+                            switch(data) {
+
+                                case 'a':
+                                    pc.printf("Menu 2 TEST\n");
+                                    
+                                    break;
+
+                                case 's':
+                                    pc.printf("Run\n");
+                                    
+                                    break;
+
+                                case 'x':
+                                    state_exit =1;
+                                  
+                                    
+                                    break;
+
+                                default:
+                                    pc.printf("plz select a or s\n");
+                                    pc.printf("\n\n");
+                                    break;
+
+                            }
+                        }
+
+
+
+                    } while(state_exit ==0);
+                    pc.printf("\n\n");
+                    break;
+
+
+                case 0x00:
+
+                    break;
+
+                default:
+                    pc.printf("plz select 1 or 2 only\n");
+                    pc.printf("\n\n");
+                    break;
+            }
+        }
+
+
+
+
+
+
+    }
+}