import android.widget.Toast;
import android.os.Bundle;
-
-import com.google.android.gms.maps.MapView;
+
+import com.google.android.gms.maps.*;
+import com.google.android.gms.maps.model.*;
public class Main extends Activity
{
private LinearLayout state;
private TextView debug;
private ScrollView scroll;
+ private Button rstHdBttn;
+ private Button rstDstBttn;
/* Private helper methods */
private void notice(String text)
/* Private handler methods */
private void onRegister(Task task)
{
- Util.debug("Main: onRegister");
+ Util.debug("Main: onRegister_task");
this.task = task;
}
this.toast.show();
}
+ private void onShowData(float[] data){
+ TextView textView1 = null;
+ TextView textView2 = null;
+ TextView textView3 = null;
+ int displayNum = 3;
+ int dataId = (int)(data[0]+0.5);
+ CMD.Data dataType = CMD.Data.values()[dataId];
+ switch (dataType){
+ case ACC:
+ textView1 = (TextView)findViewById(R.id.accText1);
+ textView2 = (TextView)findViewById(R.id.accText2);
+ textView3 = (TextView)findViewById(R.id.accText3);
+ break;
+ case MAG:
+ return;
+ /*textView1 = (TextView)findViewById(R.id.magText1);
+ textView2 = (TextView)findViewById(R.id.magText2);
+ textView3 = (TextView)findViewById(R.id.magText3);
+ break;*/
+ case GYR:
+ textView1 = (TextView)findViewById(R.id.gyrText1);
+ textView2 = (TextView)findViewById(R.id.gyrText2);
+ textView3 = (TextView)findViewById(R.id.gyrText3);
+ break;
+ case GYR1HZ:
+ textView1 = (TextView)findViewById(R.id.gyr1hzx);
+ textView2 = (TextView)findViewById(R.id.gyr1hzy);
+ textView3 = (TextView)findViewById(R.id.gyr1hzz);
+ break;
+ case ORIENT:
+ textView1 = (TextView)findViewById(R.id.orientText1);
+ textView2 = (TextView)findViewById(R.id.orientText2);
+ textView3 = (TextView)findViewById(R.id.orientText3);
+ break;
+ case WRDACC:
+ textView1 = (TextView)findViewById(R.id.wrdAccText1);
+ textView2 = (TextView)findViewById(R.id.wrdAccText2);
+ textView3 = (TextView)findViewById(R.id.wrdAccText3);
+ break;
+ case STPCNT:
+ textView1 = (TextView)findViewById(R.id.stepCntText);
+ textView2 = (TextView)findViewById(R.id.calGrvText);
+ displayNum = 2;
+ break;
+ case POSITION:
+ textView1 = (TextView)findViewById(R.id.curPosXText);
+ textView2 = (TextView)findViewById(R.id.curPosYText);
+ displayNum = 2;
+ break;
+ case ROTATION:
+ textView1 = (TextView)findViewById(R.id.roll);
+ textView2 = (TextView)findViewById(R.id.pitch);
+ textView3 = (TextView)findViewById(R.id.yaw);
+ break;
+ case HEADING:
+ textView1 = (TextView)findViewById(R.id.headingText);
+ displayNum = 1;
+ break;
+ case WRDGYR:
+ textView1 = (TextView)findViewById(R.id.wrdGyrText1);
+ displayNum = 1;
+ break;
+ case STABLE:
+ textView1 = (TextView)findViewById(R.id.stableText);
+ displayNum = 1;
+ break;
+ case BEACON:
+ textView1 = (TextView)findViewById(R.id.ibLatText);
+ textView2 = (TextView)findViewById(R.id.ibLonText);
+ textView3 = (TextView)findViewById(R.id.ibDistText);
+ displayNum = 3;
+ break;
+ default:
+ Util.debug("Main: Nothing Matches");
+ }
+
+ switch (displayNum) {
+ case 3: textView3.setText(Float.toString(data[3]));
+ case 2: textView2.setText(Float.toString(data[2]));
+ case 1: textView1.setText(Float.toString(data[1]));
+ }
+ }
+
/* Private service methods */
private void register()
{
Util.debug("Main: register");
startService(new Intent(this, Task.class)
- .putExtra("Command", Task.Command.REGISTER)
+ .putExtra("Command", CMD.Command.REGISTER)
.putExtra("Messenger", this.messenger));
}
{
Util.debug("Main: connect");
startService(new Intent(this, Task.class)
- .putExtra("Command", Task.Command.CONNECT));
+ .putExtra("Command", CMD.Command.CONNECT));
}
private void disconnect()
{
Util.debug("Main: disconnect");
startService(new Intent(this, Task.class)
- .putExtra("Command", Task.Command.DISCONNECT));
+ .putExtra("Command", CMD.Command.DISCONNECT));
}
private void quit()
this.state = (LinearLayout) findViewById(R.id.state);
this.debug = (TextView) findViewById(R.id.debug);
this.scroll = (ScrollView) findViewById(R.id.debug_scroll);
+ this.rstHdBttn = (Button) findViewById(R.id.rstHdBttn);
+ this.rstDstBttn= (Button) findViewById(R.id.rstDstBttn);
+
+ // TODO - remove these
+ rstHdBttn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ startService(new Intent(Main.this, Task.class)
+ .putExtra("Command", CMD.Command.RSTHEAD));
+ }
+ });
+
+ rstDstBttn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ startService(new Intent(Main.this, Task.class)
+ .putExtra("Command", CMD.Command.RSTDST));
+ }
+ });
// Get a handle to the Map Fragment
- //GoogleMap map = ((MapFragment)getFragmentManager()
- // .findFragmentById(R.id.map_fragment)).getMap();
+ GoogleMap map = ((MapFragment)getFragmentManager()
+ .findFragmentById(R.id.map_fragment)).getMap();
+ Marker mark = map.addMarker(new MarkerOptions()
+ .position(new LatLng(34.0722, -118.4441))
+ .title("UCLA"));
//LatLng sydney = new LatLng(-33.867, 151.206);
// Add window tabs
this.window.setup();
- this.window.addTab(this.window
- .newTabSpec("map")
- .setIndicator("Map")
- .setContent(R.id.map));
this.window.addTab(this.window
.newTabSpec("state")
.setIndicator("State")
.setContent(R.id.state));
+ this.window.addTab(this.window
+ .newTabSpec("map")
+ .setIndicator("Map")
+ .setContent(R.id.map));
this.window.addTab(this.window
.newTabSpec("debug")
.setIndicator("Debug")
/* Handler class */
class MainHandler extends Handler
{
+ @Override
public void handleMessage(android.os.Message msg)
{
- Task.Response resp = Task.Response.values()[msg.what];
+ CMD.Response resp = CMD.Response.values()[msg.what];
switch (resp) {
- case POSITION:
- Main.this.onPosition();
+ case REGISTER:
+ Main.this.onRegister((Task)msg.obj);
break;
case NOTIFY:
Main.this.onNotify((String)msg.obj);
break;
+ case SHOWDATA:
+ Main.this.onShowData((float[])msg.obj);
+ break;
default:
Util.debug("Main: unknown message - " + resp);
break;