Updated version number for test installation
This commit is contained in:
@@ -11,7 +11,7 @@ android {
|
|||||||
applicationId = "net.mmanningau.speechtokeyboard"
|
applicationId = "net.mmanningau.speechtokeyboard"
|
||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 4
|
versionCode = 5
|
||||||
versionName = "1.0"
|
versionName = "1.0"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|||||||
@@ -54,46 +54,47 @@ class TestModelActivity : AppCompatActivity(), RecognitionListener {
|
|||||||
toggleListening()
|
toggleListening()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun connectToPico() {
|
|
||||||
val usbManager = getSystemService(Context.USB_SERVICE) as UsbManager
|
|
||||||
|
|
||||||
// 1. Find the Device
|
|
||||||
// (This probes specifically for devices listed in your device_filter.xml)
|
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)
|
|
||||||
if (availableDrivers.isEmpty()) {
|
|
||||||
outputText.append("\n> No USB device found.")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assume the first device found is the Pico
|
|
||||||
val driver = availableDrivers[0]
|
|
||||||
val connection = usbManager.openDevice(driver.device)
|
|
||||||
|
|
||||||
if (connection == null) {
|
|
||||||
outputText.append("\n> Permission denied. Re-plug device?")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Open the Port
|
|
||||||
// Most Picos use port 0.
|
|
||||||
usbPort = driver.ports[0]
|
|
||||||
|
|
||||||
try {
|
|
||||||
usbPort?.open(connection)
|
|
||||||
// 3. Set Parameters (Must match your Pico's C/Python code!)
|
|
||||||
// 115200 Baud, 8 Data bits, 1 Stop bit, No Parity
|
|
||||||
usbPort?.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
|
||||||
|
|
||||||
outputText.append("\n> USB Connected to Pico!")
|
|
||||||
} catch (e: Exception) {
|
|
||||||
outputText.append("\n> USB Error: ${e.message}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the model in background
|
// Initialize the model in background
|
||||||
initModel()
|
initModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun connectToPico() {
|
||||||
|
val usbManager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
|
|
||||||
|
// 1. Find the Device
|
||||||
|
// (This probes specifically for devices listed in your device_filter.xml)
|
||||||
|
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(usbManager)
|
||||||
|
if (availableDrivers.isEmpty()) {
|
||||||
|
outputText.append("\n> No USB device found.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume the first device found is the Pico
|
||||||
|
val driver = availableDrivers[0]
|
||||||
|
val connection = usbManager.openDevice(driver.device)
|
||||||
|
|
||||||
|
if (connection == null) {
|
||||||
|
outputText.append("\n> Permission denied. Re-plug device?")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Open the Port
|
||||||
|
// Most Picos use port 0.
|
||||||
|
usbPort = driver.ports[0]
|
||||||
|
|
||||||
|
try {
|
||||||
|
usbPort?.open(connection)
|
||||||
|
// 3. Set Parameters (Must match your Pico's C/Python code!)
|
||||||
|
// 115200 Baud, 8 Data bits, 1 Stop bit, No Parity
|
||||||
|
usbPort?.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||||
|
|
||||||
|
outputText.append("\n> USB Connected to Pico!")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
outputText.append("\n> USB Error: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun initModel() {
|
private fun initModel() {
|
||||||
// We look for the folder inside private storage (same logic as MainActivity)
|
// We look for the folder inside private storage (same logic as MainActivity)
|
||||||
val modelPath = File(filesDir, "vosk-model")
|
val modelPath = File(filesDir, "vosk-model")
|
||||||
|
|||||||
Reference in New Issue
Block a user