Skip to content

Commit

Permalink
address spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
hehopmajieh committed Oct 25, 2012
1 parent ef7eecf commit e6e05f8
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 25 deletions.
Binary file modified bin/axon.test.testJNI.TestJNIActivity.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/R$attr.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/R$drawable.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/R$id.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/R$layout.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/R$string.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/R.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/TestJNIActivity$1$1$1.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/TestJNIActivity$1$1$2.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/TestJNIActivity$1$1$3.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/TestJNIActivity$1$1$4.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/TestJNIActivity$1$1.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/TestJNIActivity$1.class
Binary file not shown.
Binary file modified bin/classes/axon/test/testJNI/TestJNIActivity.class
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
34 changes: 19 additions & 15 deletions gen/axon/test/testJNI/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
package axon.test.testJNI;

public final class R {
public static final class array {
public static final int addresses=0x7f050000;
}
public static final class attr {
}
public static final class drawable {
Expand All @@ -16,21 +19,22 @@ public static final class drawable {
public static final int ic_launcher2=0x7f020002;
}
public static final class id {
public static final int button1=0x7f050000;
public static final int button2=0x7f050001;
public static final int button3=0x7f050002;
public static final int button4=0x7f050003;
public static final int button5=0x7f050004;
public static final int textView1=0x7f050005;
public static final int textView10=0x7f05000e;
public static final int textView2=0x7f050006;
public static final int textView3=0x7f050007;
public static final int textView4=0x7f050008;
public static final int textView5=0x7f050009;
public static final int textView6=0x7f05000a;
public static final int textView7=0x7f05000b;
public static final int textView8=0x7f05000c;
public static final int textView9=0x7f05000d;
public static final int button1=0x7f060001;
public static final int button2=0x7f060002;
public static final int button3=0x7f060003;
public static final int button4=0x7f060004;
public static final int button5=0x7f060005;
public static final int spinner1=0x7f060000;
public static final int textView1=0x7f060006;
public static final int textView10=0x7f06000f;
public static final int textView2=0x7f060007;
public static final int textView3=0x7f060008;
public static final int textView4=0x7f060009;
public static final int textView5=0x7f06000a;
public static final int textView6=0x7f06000b;
public static final int textView7=0x7f06000c;
public static final int textView8=0x7f06000d;
public static final int textView9=0x7f06000e;
}
public static final class layout {
public static final int main=0x7f030000;
Expand Down
10 changes: 8 additions & 2 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
android:orientation="vertical"
tools:context=".TestJNIActivity" >

<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/addresses" />

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
Expand Down Expand Up @@ -82,8 +88,8 @@
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AN1:" />

android:text="AN1:"/>
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
Expand Down
9 changes: 9 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@

<string name="hello">Hello World, TestJNIActivity!</string>
<string name="app_name">TestJNI</string>
<string-array name="addresses">
<item>0x58</item>
<item>0x59</item>
<item>0x60</item>
<item>0x61</item>



</string-array>

</resources>
28 changes: 20 additions & 8 deletions src/axon/test/testJNI/TestJNIActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

public class TestJNIActivity extends Activity {
Expand All @@ -19,14 +23,17 @@ public class TestJNIActivity extends Activity {
int bits;
double adc1,adc2,adc3,adc4;
TextView DPort1,DPort2,DPort3,DPort4,APort1,APort2,APort3,APort4;


private Spinner spinner1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Spinner spinner = (Spinner) findViewById(R.id.spinner1);

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.addresses, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);


i2c = new axonI2C();
Expand All @@ -35,6 +42,8 @@ public void onCreate(Bundle savedInstanceState) {
state[2] = 0;
state[3] = 0; //save restore/state
//toDo : States @!


new Thread() {
@Override
public void run() {
Expand All @@ -54,17 +63,22 @@ public void run() {
APort2 = (TextView)findViewById(R.id.textView8);
APort3 = (TextView)findViewById(R.id.textView9);
APort4 = (TextView)findViewById(R.id.textView10);


String[] hin1 = { "su", "-c","chmod 777 /dev/i2c-2" }; //gain root access
try {
Runtime.getRuntime().exec(hin1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

final Button button = (Button) findViewById(R.id.button1);


final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {


public void onClick(View v) {


WriteI2C(slaveAddr, 1); //ToDo: check port
Expand Down Expand Up @@ -178,7 +192,6 @@ int ReadI2CDigital(int slaveAddr, int register)
Log.w(TAG, "Could not open I2C interface");
}
buf[0] = register;
//buf[1] = 1;
i2c.write(fileHandle, 0x58, 0, buf, 1);


Expand All @@ -195,7 +208,6 @@ int ReadI2CDigital(int slaveAddr, int register)
int ReadI2CAnalog(int slaveAddr, int register)
{
int fileHandle = 0;
int Bits = 0;
int[] buf = new int[4];

try
Expand Down

0 comments on commit e6e05f8

Please sign in to comment.