meter_controller_223_LED

Dependencies:   EthernetInterface mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
junTMUG
Date:
Fri Nov 16 08:34:19 2012 +0000
Parent:
4:1247fae2410a
Commit message:
Motor????????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 1247fae2410a -r 4c120fde3e73 main.cpp
--- a/main.cpp	Fri Nov 16 05:42:17 2012 +0000
+++ b/main.cpp	Fri Nov 16 08:34:19 2012 +0000
@@ -65,7 +65,7 @@
     server.listen();
 
     meter_LED_outside.period_ms (1);
-    
+
     P_range_LED = 0.5;
     wait(0.5);
     P_range_LED = 0.0;
@@ -82,89 +82,84 @@
         char buffer[256];
         while (true) {
             int n = client.receive(buffer, sizeof(buffer));
-            int mode = (buffer[0] - 'A');
             if (n > 0) {
                 int target = (buffer[1] - '0') * 100 + (buffer[2] - '0') * 10 + (buffer[3] - '0');
 
-                switch (mode) {
-                    case 0:
-                        for(float p = 0.0f; p < 0.8f; p += 0.02f) {
-                            meter_LED_outside = p;
-                            wait(0.01);
-                        }
-                        for(float p = 0.0f; p < 0.8f; p += 0.02f) {
-                            meter_LED_inside = p;
-                            wait(0.01);
-                        }
-                        for(float p = 0.0f; p < 0.8f; p += 0.02f) {
-                            P_range_LED = p;
-                            wait(0.01);
-                        }
-                        for(float p = 0.0f; p < 0.8f; p += 0.02f) {
-                            D_range_LED = p;
-                            wait(0.01);
-                        }
-                        for(float p = 0.0f; p < 0.8f; p += 0.02f) {
-                            Other_range_LED = p;
-                            wait(0.01);
-                        }
-                        for(float p = 0.0f; p < 0.8f; p += 0.02f) {
-                            needle_LED = p;
-                            wait(0.01);
-                        }
-                        for(float p = 1.0f; p > 0.0f; p -= 0.02f) {
-                            meter_LED_outside = p;
-                            meter_LED_inside = p;
-                            P_range_LED = p;
-                            D_range_LED = p;
-                            Other_range_LED = p;
-                            needle_LED = p;
-                            wait(0.01);
-                        }
-                        signal_LED_L = 1;
-                        signal_LED_R = 1;
-                        wait (0.5);
-                        signal_LED_L = 0;
-                        signal_LED_R = 0;
-                        wait (0.5);
-                        signal_LED_L = 1;
-                        signal_LED_R = 1;
-                        wait (0.5);
-                        signal_LED_L = 0;
-                        signal_LED_R = 0;
-                        needle_LED = (1.0);
-                        wait (3.5);
+                if (buffer[0] == 'A') {
+                    for(float p = 0.0f; p < 0.8f; p += 0.02f) {
+                        meter_LED_outside = p;
+                        wait(0.01);
+                    }
+                    for(float p = 0.0f; p < 0.8f; p += 0.02f) {
+                        meter_LED_inside = p;
+                        wait(0.01);
+                    }
+                    for(float p = 0.0f; p < 0.8f; p += 0.02f) {
+                        P_range_LED = p;
+                        wait(0.01);
+                    }
+                    for(float p = 0.0f; p < 0.8f; p += 0.02f) {
+                        D_range_LED = p;
+                        wait(0.01);
+                    }
+                    for(float p = 0.0f; p < 0.8f; p += 0.02f) {
+                        Other_range_LED = p;
+                        wait(0.01);
+                    }
+                    for(float p = 0.0f; p < 0.8f; p += 0.02f) {
+                        needle_LED = p;
+                        wait(0.01);
+                    }
+                    for(float p = 1.0f; p > 0.0f; p -= 0.02f) {
+                        meter_LED_outside = p;
+                        meter_LED_inside = p;
+                        P_range_LED = p;
+                        D_range_LED = p;
+                        Other_range_LED = p;
+                        needle_LED = p;
+                        wait(0.01);
+                    }
+                    signal_LED_L = 1;
+                    signal_LED_R = 1;
+                    wait (0.5);
+                    signal_LED_L = 0;
+                    signal_LED_R = 0;
+                    wait (0.5);
+                    signal_LED_L = 1;
+                    signal_LED_R = 1;
+                    wait (0.5);
+                    signal_LED_L = 0;
+                    signal_LED_R = 0;
+                    needle_LED = (1.0);
+                    wait (3.5);
 
-                        for(float p = 0.0f; p < 0.1f; p += 0.01f) {
-                            meter_LED_outside = p;
-                            meter_LED_inside = p;
-                            P_range_LED = p;
-                            wait(0.05);
-                        }
-                        digitalclock = 1;
-                        break;
-
-                    case 1:
-                        digitalclock = 0;
-                        digitalclock_colon = 0;
-                        for(float p = 0.8f; p > 0.0f; p -= 0.01f) {
-                            meter_LED_outside = p;
-                            meter_LED_inside = p;
-                            P_range_LED = p;
-                            D_range_LED = p;
-                            Other_range_LED = p;
-                            needle_LED = p;
-                            wait(0.01);
-                        }
-                        break;
-                }
-                if (buffer[0] == 'P') {
+                    for(float p = 0.0f; p < 0.1f; p += 0.01f) {
+                        meter_LED_outside = p;
+                        meter_LED_inside = p;
+                        P_range_LED = p;
+                        wait(0.05);
+                    }
+                    digitalclock = 1;
+                } else if (buffer[0] == 'B') {
+                    digitalclock = 0;
+                    digitalclock_colon = 0;
+                    for(float p = 0.8f; p > 0.0f; p -= 0.01f) {
+                        meter_LED_outside = p;
+                        meter_LED_inside = p;
+                        P_range_LED = p;
+                        D_range_LED = p;
+                        Other_range_LED = p;
+                        needle_LED = p;
+                        wait(0.01);
+                    }
+                } else if (buffer[0] == 'P') {
                     meter_LED_outside = ((target / 10.0));
                 } else if (buffer[0] == 'Q') {
                     meter_LED_inside = ((target / 10.0));
                 } else if (buffer[0] == 'R') {
                     needle_LED = ((target / 10.0));
                 } else if (buffer[0] == 'C') {
+                    /*
                     int count_1 = 0;
                     int t = 0;
                     P_range_LED = 0;
@@ -202,76 +197,49 @@
                         t++;
                         count_1++;
                     }
+                    */
+                    switch (target) {
+                        case 0:
+                            D_range_LED = 0.1;
+                            P_range_LED = 0;
+                            break;
+
+                        case 1:
+                            meter_LED_outside_flashing2();
+                            break;
+                            
+                        case 2:
+                            meter_LED_outside_flashing2();
+                            break;
+                            
+                        default:
+                            D_range_LED = 0;
+                            P_range_LED = 0.1;
+                            break;
+                    }
                 } else if (buffer[0] == 'K') {
-                    signal_LED_L = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
+                    for (int i = 0; i < 5; i++) {
+                        signal_LED_L = 1;
+                        wait (0.5);
+                        signal_LED_L = 0;
+                        if (i < 4) wait (0.5);
+                    }
                 } else if (buffer[0] == 'L') {
-                    signal_LED_L = 1;
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_L = 1;
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_L = 0;
-                    signal_LED_R = 0;
+                    for (int i = 0; i < 5; i++) {
+                        signal_LED_L = 1;
+                        signal_LED_R = 1;
+                        wait (0.5);
+                        signal_LED_L = 0;
+                        signal_LED_R = 0;
+                        if (i < 4) wait (0.5);
+                    }
                 } else if (buffer[0] == 'M') {
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_R = 0;
-                    wait (0.5);
-                    signal_LED_R = 1;
-                    wait (0.5);
-                    signal_LED_R = 0;
+                    for (int i = 0; i < 5; i++) {
+                        signal_LED_R = 1;
+                        wait (0.5);
+                        signal_LED_R = 0;
+                        if (i < 4) wait (0.5);
+                    }
                 } else if (buffer[0] == 'S') {
                     meter_LED_outside = 0.1;
                     meter_LED_inside = 0.1;