Merge remote-tracking branch 'origin/dev-server-2.1.130-review-retryUsb' into dev-server-2.1.130-review-retryUsb

This commit is contained in:
sathwikcs
2025-01-20 12:31:00 +05:30
parent 0e2d1daaf6
commit f4387871fb
2 changed files with 13 additions and 8 deletions

View File

@@ -42,6 +42,9 @@ class UsbTerminalFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
): View { ): View {
binding = FragmentUsbTerminalBinding.inflate(inflater, container, false) binding = FragmentUsbTerminalBinding.inflate(inflater, container, false)
binding.clearQueueButton.setOnClickListener {
clearQueue()
}
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE) sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
return binding.root return binding.root
} }
@@ -75,9 +78,7 @@ class UsbTerminalFragment : Fragment() {
binding.etCommands.text.clear() binding.etCommands.text.clear()
} }
} }
binding.button.setOnClickListener{
}
listenToHemoCube() listenToHemoCube()
callCommand("I") callCommand("I")
@@ -94,9 +95,7 @@ class UsbTerminalFragment : Fragment() {
} }
private fun addToQueue(commands: List<String>) { private fun addToQueue(commands: List<String>) {
commandQueue.clear() // Append new commands to the queue instead of replacing it
currentCommand = null
commandQueue.addAll(commands) commandQueue.addAll(commands)
// Track commands in the activity // Track commands in the activity
@@ -106,8 +105,14 @@ class UsbTerminalFragment : Fragment() {
} }
} }
appendFormattedMessage("\nNew priority commands: ${commands.joinToString(" ")}") appendFormattedMessage("\nAdded commands to queue: ${commands.joinToString(" ")}")
processNextCommand() processNextCommand() // Start processing if not already in progress
}
fun clearQueue() {
commandQueue.clear()
currentCommand = null
appendFormattedMessage("\nCommand queue cleared")
} }

View File

@@ -18,7 +18,7 @@
android:padding="16dp"> android:padding="16dp">
<Button <Button
android:id="@+id/button" android:id="@+id/clearQueueButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Clar All Commands" /> android:text="Clar All Commands" />