Back to project page HRCF--Hermes-RC-Framework-.
The source code is released under:
GNU Lesser General Public License
If you think the Android project HRCF--Hermes-RC-Framework- listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.rclibtest1; //from w ww . ja v a 2 s .c om import com.hoho.android.usbserial.driver.UsbSerialDriver; import com.hoho.android.usbserial.driver.UsbSerialProber; import android.app.Activity; import android.content.Context; import android.hardware.usb.UsbManager; import android.os.Bundle; import android.util.Log; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { UDP_server mUDP = new UDP_server(); Thread nt = new network_thread(); TextView gx,gy,gz; USB_Serial mSerial; SensorBox sg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); gx = (TextView)findViewById(R.id.gyroX); //link text_view - layout. gy = (TextView)findViewById(R.id.gyroY); //link text_view - layout. gz = (TextView)findViewById(R.id.gyroZ); //link text_view - layout. sg = new SensorBox(this); new test().start(); nt.start(); } @Override protected void onResume() { super.onResume(); sg.start(); } public class network_thread extends Thread { public void run() { mUDP.setUDP(55554); } } public class test extends Thread { public void run() { while(true) { Log.v("DD",String.format("%f %f %f", sg.X, sg.Y, sg.Z)); runOnUiThread(new Runnable() { public void run() { gx.setText(String.format("%f %f %f", sg.X, sg.Y, sg.Z)); } }); try { Thread.sleep(100); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }