LPC824

Dependencies:   mbed

Fork of CubeFine by wu le

Revision:
1:54a2d380f8c7
Parent:
0:362c1482232c
Child:
2:7964622fb5a5
diff -r 362c1482232c -r 54a2d380f8c7 main.cpp
--- a/main.cpp	Thu Jun 02 04:03:31 2016 +0000
+++ b/main.cpp	Fri Jul 01 09:41:15 2016 +0000
@@ -5,8 +5,10 @@
 #include "Protocol.h"
 #include "Microduino_Motor.h"
 
+DigitalOut led_red(D5);
+
 Timer g_cubeTimer;
-Timeout g_cubeTimeout;
+//Timeout g_cubeTimeout;
 #if 1
 Motor MotorLeft(motor_pin0A, motor_pin0B);
 Motor MotorRight(motor_pin1A, motor_pin1B);
@@ -25,28 +27,38 @@
     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
 }
 
+/*
 static void wake_up(void)
 {
     //myled = 0;
 }
+*/
 
 int main()
 {
-#if 1// To test wake up from deepsleep(), failed....but wake up from sleep() work. sleep() will reduce 2mA.
+#if 0// To test wake up from deepsleep(), failed....but wake up from sleep() work. sleep() will reduce 2mA.
     wkp.fall(wake_up);
     wkp.rise(&wake_up);
     wkp1.fall(&wake_up);
     wkp1.rise(&wake_up);
 #endif
+    led_red = 0;
     //myled = 1;
-    g_cubeTimer.start();
+    //g_cubeTimer.start();
 
     mode = protocolSetup();  //遥控接收器初始化
 
     MotorLeft.Fix(motor_fixL);
     MotorRight.Fix(motor_fixR);
+    
+    MotorLeft.Driver(255);
+    MotorRight.Driver(255);
+    
+    wait(0.5);
     //mypc.baud(115200);
+    
     while (1) {
+        
         if (protocolRead(channalData, mode)) { //判断是否接收到遥控信号
             throttle = map(channalData[CHANNEL_THROTTLE], 1000, 2000, -MAX_THROTTLE, MAX_THROTTLE);
             steering = map(channalData[CHANNEL_STEERING], 1000, 2000, -MAX_STEERING, MAX_STEERING);
@@ -54,17 +66,6 @@
             MotorLeft.Driver(MotorLeft.GetData(throttle, steering, CHAN_LEFT));
             MotorRight.Driver(MotorRight.GetData(throttle, steering, CHAN_RIGHT));
 
-#ifdef _DEBUG
-            Serial.print("DATA OK :[");
-            for (int a = 0; a < CHANNEL_NUM; a++) {
-                Serial.print(channalData[a]);
-                Serial.print(" ");
-            }
-            Serial.print("],throttle:");
-            Serial.print(throttle);
-            Serial.print(",steering:");
-            Serial.println(steering);
-#endif
             safe_ms = g_cubeTimer.read_ms();
         }
 
@@ -74,11 +75,13 @@
         if (g_cubeTimer.read_ms() - safe_ms > SAFE_TIME_OUT) {
             MotorLeft.Free();
             MotorRight.Free();
-            sleep();//待机待机电流可减少4mA左右
+            //sleep();//待机待机电流可减少4mA左右
             //deepsleep();
         }
+        
     } // while
 }
+
 #else
 DigitalOut myled(D13);
 PwmOut PWM_A(motor_pin0A);