3タイプのコントロールに対応
Dependencies: BLE_API TB6612FNG mbed nRF51822
Fork of BLE_WALLBOT_BLE by
Diff: main.cpp
- Revision:
- 4:ca2ee032bc5a
- Parent:
- 2:dd85fdc18224
- Child:
- 5:88d466dea486
--- a/main.cpp Wed Aug 20 13:37:04 2014 +0000 +++ b/main.cpp Fri Aug 29 04:40:46 2014 +0000 @@ -1,15 +1,19 @@ #include "mbed.h" #include "BLEDevice.h" #include "RCBController.h" +#include "TB6612.h" #define DBG 1 BLEDevice ble; Serial pc(USBTX, USBRX); /* LEDs for indication: */ -DigitalOut ConnectStateLed(LED1); -PwmOut ControllerStateLed(LED2); +DigitalOut ConnectStateLed(P0_18); +DigitalOut outlow(P0_20); +//PwmOut ControllerStateLed(LED2); +TB6612 left(P0_29,P0_24,P0_23); +TB6612 right(P0_28,P0_30,P0_0); /* RCBController Service */ static const uint16_t RCBController_service_uuid = 0xFFF0; @@ -54,7 +58,9 @@ pc.printf("DATA:%02X %02X %d %d %d %d %d %d %d %02X\n\r",controller.data[0],controller.data[1],controller.data[2],controller.data[3],controller.data[4], controller.data[5],controller.data[6],controller.data[7],controller.data[8],controller.data[9]); #endif - ControllerStateLed = (float)controller.status.LeftAnalogLR / 255.0; + left = ((float)((int)controller.status.LeftAnalogUD -128) / 128.0); + right = ((float)((int)controller.status.RightAnalogUD -128) / 128.0); + //ControllerStateLed = (float)controller.status.LeftAnalogLR / 255.0; } } @@ -66,9 +72,14 @@ /**************************************************************************/ int main(void) { + pc.baud(921600); + + + ConnectStateLed = 1; #if DBG pc.printf("Start\n\r"); #endif + outlow = 0; ble.init(); ble.onConnection(onConnected); @@ -79,7 +90,7 @@ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED); ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, - (const uint8_t *)"mbed HRM1017", sizeof("mbed HRM1017") - 1); + (const uint8_t *)"mbed WallbotBLE", sizeof("mbed WallbotBLE") - 1); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (const uint8_t *)RCBController_service_uuid, sizeof(RCBController_service_uuid)); @@ -87,6 +98,7 @@ ble.startAdvertising(); ble.addService(RCBControllerService); + while (true) { ble.waitForEvent();