Move some stuff around
This commit is contained in:
parent
df5ab05dff
commit
b742a050c2
|
@ -20,7 +20,7 @@
|
|||
android:theme="@style/Theme.HC05AC"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".DeviceListActivity"
|
||||
android:name=".live.DeviceListActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="landscape">
|
||||
<intent-filter>
|
||||
|
@ -29,8 +29,8 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".BasicInputActivity"/>
|
||||
<activity android:name=".BtInputActivity"/>
|
||||
<activity android:name=".unused.BasicInputActivity"/>
|
||||
<activity android:name=".live.BtInputActivity"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -3,6 +3,10 @@ package io.gitlab.jfronny.hc05ac
|
|||
import android.os.Bundle
|
||||
import android.view.MotionEvent
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
import io.gitlab.jfronny.hc05ac.util.Action
|
||||
import io.gitlab.jfronny.hc05ac.util.BaseActivity
|
||||
import io.gitlab.jfronny.hc05ac.util.clamp
|
||||
import io.gitlab.jfronny.hc05ac.util.jAction
|
||||
|
||||
/**
|
||||
* Activity that divides the screen into two halves, each serving as an input controller.
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package io.gitlab.jfronny.hc05ac;
|
||||
|
||||
/**
|
||||
* Utilities for packing bytes
|
||||
* Uses bit-shifting, which is unsupported in kotlin (for good reason), so it is written in Java
|
||||
*/
|
||||
public class Pack {
|
||||
public static byte pack(byte left, byte right) {
|
||||
return (byte) ((left & 0xF0) | ((right & 0xF0) >> 4));
|
||||
}
|
||||
|
||||
public static byte unpackLeft(byte packed) {
|
||||
return (byte) (packed & 0xF0);
|
||||
}
|
||||
|
||||
public static byte unpackRight(byte packed) {
|
||||
return (byte) ((packed & 0x0F) << 4);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
package io.gitlab.jfronny.hc05ac
|
||||
package io.gitlab.jfronny.hc05ac.demo
|
||||
|
||||
import io.gitlab.jfronny.hc05ac.InputActivity
|
||||
import io.gitlab.jfronny.hc05ac.util.logI
|
||||
|
||||
class DemoActivity : InputActivity() {
|
||||
override fun send(left: Byte, right: Byte) {
|
|
@ -1,7 +1,10 @@
|
|||
package io.gitlab.jfronny.hc05ac
|
||||
package io.gitlab.jfronny.hc05ac.live
|
||||
|
||||
import android.bluetooth.BluetoothSocket
|
||||
import android.os.Bundle
|
||||
import io.gitlab.jfronny.hc05ac.InputActivity
|
||||
import io.gitlab.jfronny.hc05ac.util.logE
|
||||
import io.gitlab.jfronny.hc05ac.util.toast
|
||||
import java.io.IOException
|
||||
|
||||
class BtInputActivity : InputActivity(), ConnectBtTask.Ctx {
|
||||
|
@ -19,7 +22,7 @@ class BtInputActivity : InputActivity(), ConnectBtTask.Ctx {
|
|||
override fun send(left: Byte, right: Byte) {
|
||||
if (btSocket != null) {
|
||||
try {
|
||||
btSocket!!.outputStream.write(byteArrayOf(left, right)) // byteArrayOf(Pack.pack(left, right))
|
||||
btSocket!!.outputStream.write(byteArrayOf(left, right)) // byteArrayOf(pack(left, right))
|
||||
} catch (e: IOException) {
|
||||
logE("Could not send signal", e)
|
||||
toast("Error")
|
|
@ -1,10 +1,13 @@
|
|||
package io.gitlab.jfronny.hc05ac
|
||||
package io.gitlab.jfronny.hc05ac.live
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.ProgressDialog
|
||||
import android.bluetooth.BluetoothSocket
|
||||
import android.os.AsyncTask
|
||||
import io.gitlab.jfronny.hc05ac.util.btAdapter
|
||||
import io.gitlab.jfronny.hc05ac.util.logE
|
||||
import io.gitlab.jfronny.hc05ac.util.toast
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package io.gitlab.jfronny.hc05ac
|
||||
package io.gitlab.jfronny.hc05ac.live
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
|
@ -7,6 +7,10 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import android.widget.*
|
||||
import android.widget.AdapterView.OnItemClickListener
|
||||
import io.gitlab.jfronny.hc05ac.R
|
||||
import io.gitlab.jfronny.hc05ac.util.BaseActivity
|
||||
import io.gitlab.jfronny.hc05ac.util.btAdapter
|
||||
import io.gitlab.jfronny.hc05ac.util.toast
|
||||
|
||||
class DeviceListActivity : BaseActivity() {
|
||||
private var deviceList: ListView? = null
|
||||
|
@ -53,7 +57,6 @@ class DeviceListActivity : BaseActivity() {
|
|||
OnItemClickListener { _: AdapterView<*>?, view: View, _: Int, _: Long ->
|
||||
val info = (view as TextView).text.toString()
|
||||
val address = info.substring(info.length - 17)
|
||||
// val i = Intent(this@DeviceListActivity, BasicInputActivity::class.java)
|
||||
val i = Intent(this@DeviceListActivity, BtInputActivity::class.java)
|
||||
i.putExtra(EXTRA_ADDRESS, address)
|
||||
startActivity(i)
|
|
@ -1,9 +1,15 @@
|
|||
package io.gitlab.jfronny.hc05ac
|
||||
package io.gitlab.jfronny.hc05ac.unused
|
||||
|
||||
import android.bluetooth.BluetoothSocket
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import io.gitlab.jfronny.hc05ac.live.ConnectBtTask
|
||||
import io.gitlab.jfronny.hc05ac.live.DeviceListActivity
|
||||
import io.gitlab.jfronny.hc05ac.R
|
||||
import io.gitlab.jfronny.hc05ac.util.BaseActivity
|
||||
import io.gitlab.jfronny.hc05ac.util.logE
|
||||
import io.gitlab.jfronny.hc05ac.util.toast
|
||||
import java.io.IOException
|
||||
|
||||
class BasicInputActivity : BaseActivity(), ConnectBtTask.Ctx {
|
|
@ -1,4 +1,4 @@
|
|||
package io.gitlab.jfronny.hc05ac
|
||||
package io.gitlab.jfronny.hc05ac.util
|
||||
|
||||
import android.Manifest
|
||||
import android.os.Build
|
|
@ -0,0 +1,8 @@
|
|||
package io.gitlab.jfronny.hc05ac.util
|
||||
|
||||
private val Byte.u get() = toUByte()
|
||||
private val UByte.s get() = toByte()
|
||||
|
||||
fun pack(left: Byte, right: Byte): Byte = ((left.u and 0xF0u) or ((right.u and 0xF0u).div(16u)).toUByte()).s
|
||||
fun Byte.unpackLeft(): Byte = (this.u and 0xF0u).s
|
||||
fun Byte.unpackRight(): Byte = ((this.u and 0x0Fu) * 16u).toByte()
|
|
@ -1,4 +1,4 @@
|
|||
package io.gitlab.jfronny.hc05ac
|
||||
package io.gitlab.jfronny.hc05ac.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.bluetooth.BluetoothAdapter
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".DeviceListActivity">
|
||||
tools:context=".live.DeviceListActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".BasicInputActivity">
|
||||
tools:context=".unused.BasicInputActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue