Knight Rider PIO sample for teckBASIC, konashi.js

Dependencies:   BLE_API_Native_IRC mbed

Fork of BLE_konashi_PIO_test by Michio Ono

konashi.js mbed HRM1017でもナイトライダー!: http://jsdo.it/micutil/g1Hn

サンプル動画: https://www.youtube.com/watch?v=HSLdzS3sGLw

techBASICサンプル: https://www.dropbox.com/s/c1k25jlen7x3vqo/KnightRider.txt

Files at this revision

API Documentation at this revision

Comitter:
micono
Date:
Sun Jul 27 00:02:25 2014 +0000
Parent:
1:6b1c4adfe165
Commit message:
PIO sample for teckBASIC, konashi.js

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6b1c4adfe165 -r 6a3257fffa8c main.cpp
--- a/main.cpp	Sun Jul 13 01:36:46 2014 +0000
+++ b/main.cpp	Sun Jul 27 00:02:25 2014 +0000
@@ -8,30 +8,20 @@
 /* LEDs for indication: */
 DigitalOut knsPio[]={P0_0,P0_1,P0_2,P0_3,P0_4,P0_5,P0_6,P0_7};
 DigitalOut  ConnectStateLed(LED1);
-//PwmOut  ControllerStateLed(LED2);
 
 static const uint16_t KONASHI_SERVICE_UUID = 0xFF00;
-//static const uint16_t KONASHI_PIO_SETTING_UUID = 0x3000;
-static const uint16_t KONASHI_PIO_OUTPUT_UUID = 0x3002;
+GattService         knsService (KONASHI_SERVICE_UUID);
 
-GattService         knsService (KONASHI_SERVICE_UUID);
 /*
+static const uint16_t KONASHI_PIO_SETTING_UUID = 0x3000;
 GattCharacteristic  knsPioSetting (KONASHI_PIO_SETTING_UUID,1, 1,
-								GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | 
-								GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE); */
+	GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | 
+	GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE);
+*/
+static const uint16_t KONASHI_PIO_OUTPUT_UUID = 0x3002;
 GattCharacteristic  knsPioOut (KONASHI_PIO_OUTPUT_UUID,1, 1,
-								GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | 
-								GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE);
-
-/* RCBController Service */
-/*
-static const uint16_t RCBController_service_uuid = 0xFFF0;
-static const uint16_t RCBController_Characteristic_uuid = 0xFFF1;
-GattService         RCBControllerService (RCBController_service_uuid);
-GattCharacteristic  Controller (RCBController_Characteristic_uuid,10, 10,
-								GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | 
-								GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE);
-*/
+	GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | 
+	GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE);
 
 /* Advertising data and parameters */
 GapAdvertisingData   advData;
@@ -39,7 +29,8 @@
 GapAdvertisingParams advParams ( GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED );
 
 uint16_t	uuid16_list[] = { KONASHI_SERVICE_UUID };
-//RCBController controller;
+
+//==================================
 uint8_t pioSetting=0xFF;
 uint8_t pioOut=0;
 
@@ -52,6 +43,7 @@
 		b=(b<<1);
 	}
 }
+//==================================
 
 // GapEvent
 class GapEventHandler : public GapEvents
@@ -93,7 +85,8 @@
 	        	pioSetting=getPioSetting;
 	        }
 	        
-		} else */ if (charHandle == knsPioOut.handle) {
+		} else */
+		if (charHandle == knsPioOut.handle) {
 	        uint8_t getPioOut;
 	        nrf.getGattServer().readValue(knsPioOut.handle, &getPioOut, 1);
 	        #if DBG
@@ -103,18 +96,7 @@
 	        	pioOut=getPioOut;
 	        	DoPio();
 	        }
-		}
-/*
-   		if (charHandle == Controller.handle) {
-	        nrf.getGattServer().readValue(Controller.handle, &controller.data[0], sizeof(controller));
-#if DBG
-			pc.printf("DATA:%d %d %d %d %d %d %d %d %d %d\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;;
-			
-		}
-*/		 
+		} 
 	}
 };
 
@@ -153,9 +135,6 @@
     /* Start advertising (make sure you've added all your data first) */
     nrf.getGap().startAdvertising(advParams);
     ConnectStateLed = 1;
-		knsPio[0]=1;
-		knsPio[1]=1;
-    //ControllerStateLed = 1;
 
     for (;;)
     {