當前位置: 首頁>>代碼示例>>Java>>正文


Java AccelerometerEvent類代碼示例

本文整理匯總了Java中motej.event.AccelerometerEvent的典型用法代碼示例。如果您正苦於以下問題:Java AccelerometerEvent類的具體用法?Java AccelerometerEvent怎麽用?Java AccelerometerEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AccelerometerEvent類屬於motej.event包,在下文中一共展示了AccelerometerEvent類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import motej.event.AccelerometerEvent; //導入依賴的package包/類
public static void main(String[] args) throws InterruptedException {
	AccelerometerListener<Mote> listener = new AccelerometerListener<Mote>() {
	
		public void accelerometerChanged(AccelerometerEvent<Mote> evt) {
			System.out.println(evt.getX() + " : " + evt.getY() + " : " + evt.getZ());
		}
	
	};
	
	SimpleMoteFinder simpleMoteFinder = new SimpleMoteFinder();
	Mote mote = simpleMoteFinder.findMote();
	mote.addAccelerometerListener(listener);
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x31);
	
	Thread.sleep(6000000);
	
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x30);
	mote.disconnect();
}
 
開發者ID:fustinoni-net,項目名稱:PiRobotPlatform,代碼行數:20,代碼來源:AccelerometerDemo.java

示例2: accelerometerChanged

import motej.event.AccelerometerEvent; //導入依賴的package包/類
@Override
public void accelerometerChanged(AccelerometerEvent event) {
	synchronized (lock) {
		if (event.getSource() instanceof Nunchuk) {
			this.accelNunX = event.getX();
			this.accelNunY = event.getY();
			this.accelNunZ = event.getZ();
			double x = (this.accelNunX - 128) / 60;
			double y = (this.accelNunY - 128) / 60;
			double z = (this.accelNunZ - 128) / 60;
			this.yawList.add((float) (Math.atan2(y,
					Math.sqrt(x * x + z * z)) * 180 / Math.PI));
			this.pitchList.add((float) (Math.atan2(-x,
					Math.sqrt(y * y + z * z)) * 180 / Math.PI));
		} else {
			this.accelX = event.getX();
			this.accelY = event.getY();
			this.accelZ = event.getZ();
			this.accelZmoved = event.getZ() - 139;
		}
	}
}
 
開發者ID:freundTech,項目名稱:motecraft,代碼行數:23,代碼來源:WiiMoteListener.java

示例3: main

import motej.event.AccelerometerEvent; //導入依賴的package包/類
public static void main(String[] args) throws InterruptedException {
	AccelerometerListener<Mote> listener = new AccelerometerListener<Mote>() {
	
		public void accelerometerChanged(AccelerometerEvent<Mote> evt) {
			System.out.println(evt.getX() + " : " + evt.getY() + " : " + evt.getZ());
		}
	
	};
	
	SimpleMoteFinder simpleMoteFinder = new SimpleMoteFinder();
	Mote mote = simpleMoteFinder.findMote();
	mote.addAccelerometerListener(listener);
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x31);
	
	Thread.sleep(60000l);
	
	mote.setReportMode(ReportModeRequest.DATA_REPORT_0x30);
	mote.disconnect();
}
 
開發者ID:iSchluff,項目名稱:Wii-Gesture,代碼行數:20,代碼來源:AccelerometerDemo.java

示例4: fireAccelerometerEvent

import motej.event.AccelerometerEvent; //導入依賴的package包/類
/**
 * @param data
 */
@SuppressWarnings("unchecked")
protected void fireAccelerometerEvent(byte[] data) {
	AccelerometerListener<Nunchuk>[] listeners = listenerList
			.getListeners(AccelerometerListener.class);
	if (listeners.length == 0) {
		return;
	}

	// remark: I am currently ignoring the LSB as I do with the LSB of the
	// calibration data.
	// if someone comes up with reliable data, we'll add it, i promise.
	int ax = ((data[2] & 0xff)); // << 2) ^ (data[5] & 0x0c);
	int ay = ((data[3] & 0xff)); // << 2) ^ (data[5] & 0x30);
	int az = ((data[4] & 0xff)); // << 2) ^ (data[5] & 0xc0);
	AccelerometerEvent<Nunchuk> evt = new AccelerometerEvent<Nunchuk>(this,
			ax, ay, az);
	for (AccelerometerListener<Nunchuk> l : listeners) {
		l.accelerometerChanged(evt);
	}
}
 
開發者ID:iSchluff,項目名稱:Wii-Gesture,代碼行數:24,代碼來源:Nunchuk.java

示例5: accelerometerChanged

import motej.event.AccelerometerEvent; //導入依賴的package包/類
@Override
public void accelerometerChanged(AccelerometerEvent<Mote> evt) {
	/* Parameter auslesen */
	xAccel=evt.getX();
	yAccel=evt.getY();
	zAccel=evt.getZ();
	
	Vector<Double> accelStep=new Vector<Double>();
	//Log.write(xAccel+" "+yAccel+" "+zAccel,this);
	accelStep.add(xAccel);
	accelStep.add(yAccel);
	accelStep.add(zAccel);
	
	/* Werte filtern */
	if(filter!=null){
		Vector<Double>filtered=filter.filter(xAccel, yAccel, zAccel);
		
		/* Werte in Geste schreiben */
		if(gesture!=null){
			gesture.setAccelStep(filtered);
		}
		graph.setAccel(filtered);
	}else{
		if(gesture!=null){
			gesture.setAccelStep(accelStep);
		}
		graph.setAccel(accelStep);
	}
}
 
開發者ID:iSchluff,項目名稱:Wii-Gesture,代碼行數:30,代碼來源:DataTraceAccelerationListener.java

示例6: fireAccelerometerEvent

import motej.event.AccelerometerEvent; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected void fireAccelerometerEvent(double xAcceleration, double yAcceleration, double zAcceleration) {
    AccelerometerListener<Mote>[] listeners = listenerList.getListeners(AccelerometerListener.class);
    AccelerometerEvent<Mote> evt = new AccelerometerEvent<Mote>(this, xAcceleration, yAcceleration, zAcceleration);
    for (AccelerometerListener<Mote> l : listeners) {
        l.accelerometerChanged(evt);
    }
}
 
開發者ID:iSchluff,項目名稱:Wii-Gesture,代碼行數:9,代碼來源:Mote.java

示例7: accelerometerChanged

import motej.event.AccelerometerEvent; //導入依賴的package包/類
public void accelerometerChanged(AccelerometerEvent<Nunchuk> evt) {
	accelerometerPanel.accelerometerValueChanged(evt.getX() & 0xff, evt.getY() & 0xff, evt.getZ() & 0xff);
}
 
開發者ID:fustinoni-net,項目名稱:PiRobotPlatform,代碼行數:4,代碼來源:NunchukGui.java

示例8: accelerometerChanged

import motej.event.AccelerometerEvent; //導入依賴的package包/類
public void accelerometerChanged(AccelerometerEvent<Nunchuk> evt) {
//		accelerometerPanel.accelerometerValueChanged(evt.getX() & 0xff, evt.getY() & 0xff, evt.getZ() & 0xff);
	}
 
開發者ID:iSchluff,項目名稱:Wii-Gesture,代碼行數:4,代碼來源:NunchukGui.java


注:本文中的motej.event.AccelerometerEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。