add command to set DAC values to eprom

This commit is contained in:
Pritimay Sarkar
2024-02-15 23:19:56 +05:30
parent b53e20682d
commit efe60ab172
7 changed files with 33 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package com.example.hpostesting.data.constant
enum class HemoCubeCommands(val command: String) {
START_BUFFER_COMMAND("B\r"),
AUTO_DAC_COMMAND("C\r"),
SET_AUTO_DAC_TO_EPROM_COMMAND("G\r"),
DIAGNOSTICS_COMMAND("D\r"),
FIRMWARE_INFO_COMMAND("F\r"),
START_SAMPLE("S\r"),

View File

@@ -58,7 +58,6 @@ class AutoDacActivity : AppCompatActivity() {
DataHolder.usbConnected.postValue(true)
}
}
}
}

View File

@@ -112,6 +112,20 @@ class AutoDacFragment : Fragment() {
})
}
private fun setAutoDacValuesCommand() {
autoDacViewModel.progressBar.postValue(true)
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
HemoCubeCommands.SET_AUTO_DAC_TO_EPROM_COMMAND,
object : UsbServiceListener {
override fun onUsbRead(data: ByteArray?) {
}
override fun onUsbError(e: Exception?) {
autoDacViewModel.progressBar.postValue(false)
}
})
}
private fun listenToHemoCube() {
val fullReadOutput = StringBuilder()
@@ -143,6 +157,8 @@ class AutoDacFragment : Fragment() {
}
if (resultData.contains("#CC")) {
setAutoDacValuesCommand()
autoDacViewModel.addAutoDacDataToDb(
DiagnosticsData(
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
@@ -169,6 +185,10 @@ class AutoDacFragment : Fragment() {
binding.ivCheck.visibility = View.VISIBLE
}
}
if (resultData.contains("#WS")) {
showToast("DAC Values saved to EPROM")
}
}
override fun onUsbError(e: Exception?) {

View File

@@ -0,0 +1,4 @@
package com.example.hpostesting.presentation.blank
class BlankActivity {
}

View File

@@ -0,0 +1,4 @@
package com.example.hpostesting.presentation.blank
class BlankFragment {
}

View File

@@ -0,0 +1,4 @@
package com.example.hpostesting.presentation.blank
class BlankViewModel {
}

View File

@@ -108,8 +108,6 @@ class DiagnosticsFragment : Fragment() {
HemoCubeCommands.DIAGNOSTICS_COMMAND,
object : UsbServiceListener {
override fun onUsbRead(data: ByteArray?) {
}
override fun onUsbError(e: Exception?) {