X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=main.cpp;fp=main.cpp;h=071126130d626f74cf4c04ec010de796226da829;hb=4ed3a2c7224fe2866f3f732f9a0c9a8c8bc5b493;hp=7645d2c1ff45b18e51b9897c6de182b1ac7bc7fe;hpb=7cc1ef62597aac91cb73bf1b1671ddf719329e7b;p=tondenhei%2Fet2013.git diff --git a/main.cpp b/main.cpp index 7645d2c..0711261 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ // ECRobot++ API #include "Lcd.h" #include "Bluetooth.h" +#include "BTConnection.h" #include "Clock.h" #include "GyroSensor.h" #include "LightSensor.h" @@ -23,7 +24,7 @@ using namespace ecrobot; /* sample_c4ƒ}ƒNƒ */ #define DEVICE_NAME "ET277" /* Bluetooth’ʐM—pƒfƒoƒCƒX–¼ */ /* ƒ`[ƒ€ID‚ɕύX‚µ‚Ä‚­‚¾‚³‚¢ */ -#define PASS_KEY "2345" /* Bluetooth’ʐM—pƒpƒXƒL[ */ /* ŒÅ—L‚̃pƒXƒL[‚ðÝ’肵‚Ä‚­‚¾‚³‚¢ */ +#define PASS_KEY "1234" /* Bluetooth’ʐM—pƒpƒXƒL[ */ /* ŒÅ—L‚̃pƒXƒL[‚ðÝ’肵‚Ä‚­‚¾‚³‚¢ */ #define CMD_START '1' /* ƒŠƒ‚[ƒgƒXƒ^[ƒgƒRƒ}ƒ“ƒh */ #define CMD_STOP '9' /* ƒŠƒ‚[ƒgƒXƒgƒbƒvƒRƒ}ƒ“ƒh */ @@ -57,18 +58,6 @@ ETLineTracer tracer(linepos,runner); ETTailControl tailcontroler(motorT,0); ContextStuff::Context context; -/* ƒfƒoƒCƒX‰Šú‰»—pƒtƒbƒNŠÖ” */ -/* ‚±‚̊֐”‚ÍnxtOSEK‹N“®Žž‚ÉŽÀs‚³‚ê‚Ü‚·B */ -void ecrobot_device_initialize() -{ - /* ƒZƒ“ƒTAƒ‚[ƒ^‚È‚Ç‚ÌŠeƒfƒoƒCƒX‚̏‰Šú‰»ŠÖ”‚ð - * ‚±‚±‚ÅŽÀ‘•‚·‚邱‚Æ‚ª‚Å‚«‚Ü‚· - * Ë@ŒõƒZƒ“ƒTÔFLED‚ðON‚É‚·‚é - */ - //ecrobot_set_light_sensor_active(SENSOR_LIGHT); - ecrobot_init_bt_slave(PASS_KEY); /* Bluetooth’ʐM‰Šú‰» */ //ex4 -} - /* ƒfƒoƒCƒXI—¹—pƒtƒbƒNŠÖ” */ /* ‚±‚̊֐”‚ÍSTOP‚Ü‚½‚ÍEXITƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ꂽŽž‚ÉŽÀs‚³‚ê‚Ü‚·B */ void ecrobot_device_terminate() @@ -130,10 +119,39 @@ BOOL Bluetooth_isReceived(char cmd) return (BOOL)come; } +bool is_touched(TouchSensor& touch,ETTailControl& tailcontroler) +{ + tailcontroler.Control(); + if(touch.isPressed()){ + systick_wait_ms(30); + while(touch.isPressed()){ + tailcontroler.Control(); + } + systick_wait_ms(30); + return true; + } + return false; +} + + +void waitstart(TouchSensor& touch,ETTailControl& tailcontroler,char cmd) +{ + /* ƒ^ƒbƒ`ƒZƒ“ƒT‚ª‰Ÿ‚³‚ê‚é‚܂ŁA‘Ò‚¿‘±‚¯‚é */ + while(1){ + if (is_touched(touch,tailcontroler)){ + break; + } + if (Bluetooth_isReceived(CMD_START)){ + break; + } + } +} TASK(TaskMain) { - bt.setFriendlyName(DEVICE_NAME); + //bt.setFriendlyName(DEVICE_NAME); + BTConnection btConnection(bt, lcd, nxt); + btConnection.connect(PASS_KEY); lcd.clear(); lcd.putf("s", "Hello World"); lcd.disp(); @@ -146,11 +164,7 @@ TASK(TaskMain) unsigned long sum = 0; char str[16+1]; // ƒWƒƒƒCƒ - while(!touch.isPressed()){ - tailcontroler.Control(); - } - while(touch.isPressed()){ - } + while(!is_touched(touch,tailcontroler)) {} for(int i=0;i