diff --git a/software/android/app/src/main/AndroidManifest.xml b/software/android/app/src/main/AndroidManifest.xml index 4d3cdfc..f0af214 100644 --- a/software/android/app/src/main/AndroidManifest.xml +++ b/software/android/app/src/main/AndroidManifest.xml @@ -14,7 +14,7 @@ android:name=".ControlActivity" android:exported="false" android:theme="@style/Theme.HexapodFullScreen" - android:screenOrientation="landscape" + android:screenOrientation="sensorLandscape" android:configChanges="orientation|keyboardHidden"/> (R.id.control_image) - val dip = 32f - val r: Resources = resources - this.pxMargin = TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, - dip, - r.displayMetrics - ) - val vto: ViewTreeObserver = controlCircle.viewTreeObserver vto.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { override fun onPreDraw(): Boolean { @@ -132,7 +126,7 @@ class ControlActivity : AppCompatActivity() { currentState = "standby" } } else if (length >= radius / 3 && length < 2 * radius / 3) { - var angle = atan2(coorY, coorX) + val angle = atan2(coorY, coorX) if (angle > -PI / 4 && angle <= PI / 4) { if (currentState != "shiftright") { println("Move right") @@ -159,7 +153,7 @@ class ControlActivity : AppCompatActivity() { } } } else if (length >= 2 * radius / 3 && length < radius) { - var angle = atan2(coorY, coorX) + val angle = atan2(coorY, coorX) if (angle > -PI / 4 && angle <= PI / 4) { if (currentState != "rightturn") { println("Turn right") @@ -190,7 +184,7 @@ class ControlActivity : AppCompatActivity() { } } ) - this.tcpClient = TCPClient(this, "192.168.1.202", 1234, object : OnMessageReceived { + this.tcpClient = TCPClient(this, ip, port, object : OnMessageReceived { override fun messageReceived(message: String?) { if (message == null) { // alertDialog(DISCONNECTED) diff --git a/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt b/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt index 6d5a74e..15b2356 100644 --- a/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt +++ b/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt @@ -24,8 +24,10 @@ class MainActivity : AppCompatActivity() { buttonConnect.setOnClickListener { // your code to perform when the user clicks on the button - Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show() +// Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show() val intent = Intent(this, ControlActivity::class.java).apply { + putExtra("ip", ipInput.text.toString()) + putExtra("port", portInput.text.toString()) } startActivity(intent) } diff --git a/software/android/app/src/main/res/layout/activity_main.xml b/software/android/app/src/main/res/layout/activity_main.xml index a4337e4..257163f 100644 --- a/software/android/app/src/main/res/layout/activity_main.xml +++ b/software/android/app/src/main/res/layout/activity_main.xml @@ -40,7 +40,8 @@ android:layout_height="wrap_content" android:digits="0123456789." android:hint="IP" - android:inputType="number|numberDecimal" /> + android:inputType="number|numberDecimal" + android:text="192.168.1.202" /> + android:inputType="number" + android:text="1234" />