Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_RCBController2 by
Revision 7:505a9a98b776, committed 2015-03-14
- Comitter:
- lipoyang
- Date:
- Sat Mar 14 11:51:38 2015 +0000
- Parent:
- 6:63787b19ec1e
- Commit message:
- - adjust servo center position
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file | 
--- a/main.cpp	Mon Feb 09 12:42:56 2015 +0000
+++ b/main.cpp	Sat Mar 14 11:51:38 2015 +0000
@@ -19,16 +19,6 @@
  * limitations under the License.
  */
 
-/*
- * Library Dependencies:
- * - BLE_API (revision 111)
- * - HRM1017
- *   - HRM1017/projectconfig.h
- *     connection interval constants are modified. (No need?)
- *     CFG_GAP_CONNECTION_MIN_INTERVAL_MS 30 
- *     CFG_GAP_CONNECTION_MAX_INTERVAL_MS 50
- */
-
 #include "mbed.h"
 #include "BLEDevice.h"
 
@@ -103,17 +93,27 @@
         tb6612_pwma = 1;
         tb6612_ain1 = 0;
         tb6612_ain2 = 0;
-//        // break
-//        tb6612_pwma = 1;
-//        tb6612_ain1 = 1;
-//        tb6612_ain2 = 1;
     }
 }
 
+void motor_break()
+{
+    // break
+    tb6612_pwma = 1;
+    tb6612_ain1 = 1;
+    tb6612_ain2 = 1;
+}
+
+// you must adjust center position
+#define RL_ADJ      (0)
+#define RL_CENTER   (1500)
+#define RL_RANGE    (500.0)
+
 // RC servo
-void servo (float deg)
+// rl : -1.0 ? 1.0
+void servo (float rl)
 {
-    servo_pwm.pulsewidth_us(1500 + (int)(500.0 * deg));
+    servo_pwm.pulsewidth_us(RL_CENTER + RL_ADJ + (int)(RL_RANGE * rl));
 }
 
 // BLE onConnection handler
@@ -159,7 +159,7 @@
 #endif
 	// initialize servo & motor
     servo_pwm.period_ms(20);
-    servo(0.5);
+    servo(0);
     motor(0);
 	
 	// initialize BLE
    