Measured results of an XBee wireless sensor device are displayed a LCD on Nucleo board with an XBee coordinator which is in API mode.

Dependencies:   TextLCD mbed xbee sample04_sens

Dependents:   sample04_sens

Please refer to the following site for the details:

Files at this revision

API Documentation at this revision

Comitter:
bokunimowakaru
Date:
Thu Sep 25 12:13:11 2014 +0000
Parent:
4:09c0f8f67e63
Child:
6:916f9273d61f
Commit message:
Release Version 1.91 (passed all of tests; examples, aging)

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
xbee.lib Show annotated file Show diff for this revision Revisions of this file
--- a/TextLCD.lib	Tue Sep 23 14:06:57 2014 +0000
+++ b/TextLCD.lib	Thu Sep 25 12:13:11 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- a/main.cpp	Tue Sep 23 14:06:57 2014 +0000
+++ b/main.cpp	Thu Sep 25 12:13:11 2014 +0000
@@ -53,46 +53,48 @@
 	}else{
 		lcd.cls(); lcd.printf("Failed:no dev.");
 	}
-	wait(0.5);
+	wait(1);
+	lcd.cls();
 	
 	// メイン処理
 	while(1){							// 永久に受信する
 		if(dev_en){	
 			if(trig<=0){
-				if(xbee_force(dev_sens)){		// デバイスdev_sensへデータ要求
-					lcd.locate(12,0);
-					lcd.printf("Trig");
-					wait(0.1);
-					lcd.locate(12,0);
-					lcd.printf("    ");
-				}else{
+				lcd.locate(12,0);
+				lcd.printf("Trig");
+				wait(0.1);
+				if(xbee_force(dev_sens)==0){		// デバイスdev_sensへデータ要求
 					lcd.locate(10,0);
 					lcd.printf("Error");
 					lcd.locate(14,1);
 					lcd.printf("%02X",(byte)trig);
 				}
 				trig = FORCE_INTERVAL;
+				lcd.locate(12,0);
+				lcd.printf("    ");
 			}
 		}else{
 			lcd.cls();
 			lcd.printf("Waiting for XBee");
-			wait(.5);
+			wait(1);
+			lcd.cls();
 		}
 		trig--;
 
 		/* データ受信(待ち受けて受信する) */
-		xbee_rx_call( &xbee_result );
-										// データを受信します。
+		lcd.locate(14,1); lcd.printf("RX");
+		xbee_rx_call( &xbee_result );	// データを受信します。
+		lcd.locate(14,1); lcd.printf("  ");
 		switch( xbee_result.MODE ){		// 受信したデータの内容(MODE値)に応じて
 			case MODE_RESP:				// sensorからの応答の場合に照度と温度を表示
 			case MODE_GPIN:				// 周期方式でデータ受信した場合も想定
 				if( bytecmp( dev_sens , &(xbee_result.FROM[0]) ,8 ) == 0 && xbee_result.STATUS == STATUS_OK ){
 					// 照度測定結果
 					value = xbee_sensor_result( &xbee_result, LIGHT);
-					lcd.cls(); lcd.printf( "%.1f",value );	lcd.printf(" Lux ");
+					lcd.locate(0,0); lcd.printf( "%.1f Lux   ",value);
 					// 温度測定結果
 					value = xbee_sensor_result( &xbee_result, TEMP);
-					lcd.locate(0,1); lcd.printf( "%.1f",value ); lcd.printf(" C");
+					lcd.locate(0,1); lcd.printf( "%.1f C   ",value);
 				}
 				break;
 			case MODE_IDNT:				// 新しいデバイスを発見
@@ -103,6 +105,7 @@
 				trig = 0;
 				xbee_gpio_config( dev_sens, 1 , AIN ); // 接続相手のポート1をAIN入力へ
 				xbee_gpio_config( dev_sens, 2 , AIN ); // 接続相手のポート2をAIN入力へ
+				lcd.cls();
 				break;
 			default:
 				break;
--- a/xbee.lib	Tue Sep 23 14:06:57 2014 +0000
+++ b/xbee.lib	Thu Sep 25 12:13:11 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/bokunimowakaru/code/xbee/#d72830877d98
+http://mbed.org/users/bokunimowakaru/code/xbee/#5dbdfe0ca04f