Maiko Matsumoto
/
BLE_WallbotBLE_Challenge_byYUTAKA3
6/18 wallbot
Fork of BLE_WallbotBLE_Challenge_byYUTAKA by
Diff: main.cpp
- Revision:
- 1:a86c84ead24a
- Parent:
- 0:76dfa9657d9d
- Child:
- 2:3c406d25860e
diff -r 76dfa9657d9d -r a86c84ead24a main.cpp --- a/main.cpp Wed Nov 12 02:40:34 2014 +0000 +++ b/main.cpp Tue Nov 18 04:28:02 2014 +0000 @@ -6,7 +6,9 @@ #define DBG 0 BLEDevice ble; +#if DBG Serial pc(USBTX, USBRX); +#endif /* LEDs for indication: */ DigitalOut ModeLed(P0_19); DigitalOut ConnectStateLed(P0_18); @@ -19,7 +21,7 @@ AnalogIn fsen4(P0_5); #if 1 TB6612 left(P0_29,P0_23,P0_24); -TB6612 right(P0_28,P0_0,P0_30); +TB6612 right(P0_28,P0_30,P0_0); #else TB6612 left(P0_29,P0_24,P0_23); TB6612 right(P0_28,P0_0,P0_30); @@ -29,8 +31,10 @@ DigitalIn sw1(P0_16); DigitalIn sw2(P0_17); -DigitalIn pin1(P0_8); -DigitalIn pin2(P0_10); +DigitalIn encl1(P0_6); +DigitalIn encl2(P0_7); +DigitalIn encr1(P0_8); +DigitalIn encr2(P0_10); int base_fsen[4]; @@ -49,7 +53,7 @@ GattCharacteristic ControllerChar (RCBController_Characteristic_uuid,RCBControllerPayload,10, 10, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE); -static uint8_t _bValue = 0x00; +//static uint8_t _bValue = 0x00; static uint8_t _mValue[10] = {0,}; GattCharacteristic b_Char(RCBController_b_Characteristic_uuid, _mValue, sizeof(_mValue), sizeof(_mValue), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY); @@ -69,6 +73,9 @@ void onDisconnected(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) { + left = 0; + right = 0; + ble.startAdvertising(); ConnectStateLed = 1; #if DBG @@ -250,8 +257,9 @@ { base_fsen[i] = base_fsen[i] / 10; } +#if DBG pc.printf("[0]:%05d[1]:%05d[2]:%05d[3]:%05d\n\r",base_fsen[0],base_fsen[1],base_fsen[2],base_fsen[3]); - +#endif } int get_line(int num) @@ -287,6 +295,11 @@ line |= get_line(2) ? 4 : 0; line |= get_line(3) ? 8 : 0; #endif + +#if DBG + pc.printf("line=%02x %04x %04x %04x %04x\n\r",line,base_fsen[0],base_fsen[1],base_fsen[2],base_fsen[3]); +#endif +#if 1 switch(line) { case 1: // ○○○● @@ -322,12 +335,15 @@ right = 1.0; break; } +#endif } ModeLed = 1; left = 0.0; right = 0.0; wait(1); } + +#if 0 int counter1 = 0; void p1_rise() { @@ -340,6 +356,8 @@ counter1--; } } +#endif + /**************************************************************************/ /*! @brief Program entry point @@ -349,7 +367,12 @@ { sw1.mode(PullUp); sw2.mode(PullUp); - + + encl1.mode(PullNone); + encl2.mode(PullNone); + encr1.mode(PullNone); + encr2.mode(PullNone); + ModeLed = 1; ConnectStateLed = 1; #if DBG @@ -361,7 +384,7 @@ if(sw2 == 0) { - pin1.mode(PullDown); +// pin1.mode(PullDown); // pin1.rise(&p1_rise); while(1) {