Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
219 | ligi | 1 | |
2 | package org.ligi.android; |
||
3 | |||
4 | import android.app.ListActivity; |
||
5 | import android.content.Intent; |
||
6 | import android.content.pm.PackageManager; |
||
7 | import android.content.pm.ResolveInfo; |
||
8 | import android.os.Bundle; |
||
9 | import android.view.View; |
||
10 | import android.widget.ListView; |
||
11 | import android.widget.SimpleAdapter; |
||
12 | |||
13 | |||
14 | import android.util.Log; |
||
15 | |||
16 | import android.app.Activity; |
||
17 | import android.os.Bundle; |
||
18 | |||
19 | |||
20 | import android.view.View; |
||
21 | import android.widget.ListView; |
||
22 | import android.widget.SimpleAdapter; |
||
23 | |||
24 | import java.text.Collator; |
||
25 | import java.util.ArrayList; |
||
26 | import java.util.Collections; |
||
27 | import java.util.Comparator; |
||
28 | import java.util.HashMap; |
||
29 | import java.util.List; |
||
30 | import java.util.Map; |
||
31 | import android.net.Uri; |
||
32 | |||
33 | import java.net.URISyntaxException; |
||
34 | import android.widget.*; |
||
35 | import android.content.DialogInterface; |
||
36 | import android.content.Context.*; |
||
37 | import android.widget.EditText; |
||
38 | import android.text.method.NumberKeyListener; |
||
39 | |||
40 | |||
41 | import com.google.android.maps.MapView; |
||
42 | |||
43 | import android.app.AlertDialog.*; |
||
44 | import android.app.AlertDialog; |
||
45 | |||
46 | import android.content.SharedPreferences; |
||
47 | |||
48 | import org.ligi.ufo.*; |
||
49 | |||
50 | public class MotorTestActivity extends Activity |
||
51 | implements SeekBar.OnSeekBarChangeListener |
||
52 | { |
||
53 | |||
54 | SeekBar seek_right,seek_left,seek_front,seek_back,seek_all; |
||
55 | CheckBox full_speed; |
||
56 | boolean toasted=false; |
||
57 | |||
58 | AndroidMKCommunicator mk; |
||
59 | @Override |
||
60 | public void onCreate(Bundle savedInstanceState) { |
||
61 | super.onCreate(savedInstanceState); |
||
62 | |||
63 | |||
64 | mk= new AndroidMKCommunicator(this); |
||
65 | |||
66 | setContentView(R.layout.motortest); |
||
67 | |||
68 | seek_right=(SeekBar)findViewById( R.id.seek_right); |
||
69 | seek_left=(SeekBar)findViewById( R.id.seek_left); |
||
70 | seek_front=(SeekBar)findViewById( R.id.seek_front); |
||
71 | seek_back=(SeekBar)findViewById( R.id.seek_back); |
||
72 | seek_all=(SeekBar)findViewById( R.id.seek_all); |
||
73 | full_speed=(CheckBox)findViewById( R.id.check_fullspeed); |
||
74 | seek_right.setOnSeekBarChangeListener(this); |
||
75 | seek_left.setOnSeekBarChangeListener(this); |
||
76 | seek_front.setOnSeekBarChangeListener(this); |
||
77 | seek_back.setOnSeekBarChangeListener(this); |
||
78 | seek_all.setOnSeekBarChangeListener(this); |
||
79 | // toast=Toast; |
||
80 | toast=toast.makeText(this, "Value too Dangerous - Clipping! Activate 'Allow Full Speed' to Override" + mk.stats.debug_data_count,Toast.LENGTH_LONG ); |
||
81 | } |
||
82 | @Override |
||
83 | protected void onDestroy() |
||
84 | { |
||
85 | mk.close_connections(true); |
||
86 | mk=null; |
||
87 | super.onDestroy(); |
||
88 | |||
89 | } |
||
90 | |||
91 | Toast toast; |
||
92 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { |
||
93 | // mProgressText.setText(progress + " " + |
||
94 | // getString(R.string.seekbar_from_touch) + "=" + fromTouch); |
||
95 | if (( progress>50)&&(!full_speed.isChecked())) |
||
96 | { |
||
97 | seekBar.setProgress(50); |
||
98 | progress=50; |
||
99 | toast.show (); |
||
100 | } |
||
101 | else |
||
102 | { |
||
103 | toast.cancel(); |
||
104 | } |
||
105 | if (seekBar==seek_all) |
||
106 | { |
||
107 | seek_right.setProgress(progress); |
||
108 | seek_left.setProgress(progress); |
||
109 | seek_front.setProgress(progress); |
||
110 | seek_back.setProgress(progress); |
||
111 | } |
||
112 | |||
113 | |||
114 | int[] params=new int[4]; |
||
115 | params[0] = seek_right.getProgress(); |
||
116 | params[1] = seek_left.getProgress(); |
||
117 | params[2] = seek_front.getProgress(); |
||
118 | params[3] = seek_back.getProgress(); |
||
119 | |||
120 | |||
121 | params[3] = seek_right.getProgress(); |
||
122 | params[2] = seek_left.getProgress(); |
||
123 | params[0] = seek_front.getProgress(); |
||
124 | params[1] = seek_back.getProgress(); |
||
125 | |||
126 | mk.motor_test(params); |
||
127 | } |
||
128 | |||
129 | |||
130 | public void onStartTrackingTouch(SeekBar seekBar) { |
||
131 | //mTrackingText.setText(getString(R.string.seekbar_tracking_on)); |
||
132 | } |
||
133 | |||
134 | public void onStopTrackingTouch(SeekBar seekBar) { |
||
135 | // mTrackingText.setText(getString(R.string.seekbar_tracking_off)); |
||
136 | } |
||
137 | |||
138 | } |