-

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Pumipachpro
Date:
Tue Nov 17 02:51:37 2015 +0000
Commit message:
-

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 17 02:51:37 2015 +0000
@@ -0,0 +1,178 @@
+#include "mbed.h"
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+DigitalOut led0(D2);
+DigitalOut led1(D3);
+DigitalOut led2(D4);
+DigitalOut led3(D5);
+DigitalOut led4(D6);
+DigitalOut led5(D7);
+DigitalOut led6(D8);
+DigitalOut led7(D9);
+
+int main()
+{
+
+    uint8_t state_menu=0;
+    uint8_t state_show=0;
+    uint8_t state_exit =0;
+    uint8_t data;
+
+    led0=0;
+    led1=0;
+    led2=0;
+    led3=0;
+    led4=0;
+    led5=0;
+    led6=0;
+    led7=0;
+
+    while(1) {
+        if(state_show == 0) {
+            pc.printf("Menu\n");
+            pc.printf("1.Play with LED\n");
+            pc.printf("2.Check Statement\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("Select Pattern\n");
+                            pc.printf("a.LED No.1\n");
+                            pc.printf("d.LED No.2\n");
+                            pc.printf("s.Exit\n");
+                            state_menu = 1;
+                        }
+                        if(pc.readable()) {
+                            data = pc.getc();
+                            pc.printf("\n");
+                            state_menu=0;
+
+                            switch(data) {
+
+                                case 'a':
+                                    while(1) {
+                                        if(pc.readable()) {
+                                            data = pc.getc();
+                                        } else if(data=='a') {
+                                            led0=1;
+                                            led1=0;
+                                            led2=1;
+                                            led3=0;
+                                            led4=1;
+                                            led5=0;
+                                            led6=1;
+                                            led7=0;
+                                            wait(0.3);
+                                            led0=0;
+                                            led1=1;
+                                            led2=0;
+                                            led3=1;
+                                            led4=0;
+                                            led5=1;
+                                            led6=0;
+                                            led7=1;
+                                            wait(0.3);
+                                        } else if(data != 'a') {
+                                            break;
+                                        }
+                                    }
+
+                                case 's':
+                                    led0 =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;
+            }
+        }
+
+
+
+
+
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 17 02:51:37 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file