Skip to content
Snippets Groups Projects
Commit 11313911 authored by Paul-Winpenny's avatar Paul-Winpenny
Browse files

The stop button has been made in record time

parent 913112ca
No related branches found
No related tags found
1 merge request!2Manual control user interface
......@@ -2,8 +2,8 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net8.0-android</ActiveDebugFramework>
<ActiveDebugProfile>Samsung SM-A805F (Android 9.0 - API 28)</ActiveDebugProfile>
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
<DefaultDevice>pixel_5_-_api_34</DefaultDevice>
</PropertyGroup>
......
......@@ -134,6 +134,15 @@
CornerRadius="5"
BackgroundColor="LightGrey"/>
</Grid>
<Button Text="Stop"
Clicked="OnStopClicked"
BackgroundColor="Red"
TextColor="White"
WidthRequest="100"
HeightRequest="50"
HorizontalOptions="Center"
CornerRadius="5"
Margin="0,10,0,0" />
</VerticalStackLayout>
</VerticalStackLayout>
......
......@@ -83,7 +83,14 @@ namespace RobobinApp.Views.Sides
{
await SendManualControlMessage("D");
}
private async void OnStopClicked(object sender, EventArgs e)
{
string stopMessage = "STOP";
await App.WifiManager.SendMessageAsync(stopMessage);
}
// Helper Method for Manual Control Messages
private async Task SendManualControlMessage(string direction)
{
......
......@@ -8,7 +8,8 @@ class MessageHandler:
"PING": self.handle_ping,
"TIME": self.handle_time_request,
"MANUALCTRL": self.handle_manual_control,
"SETMODE": self.handle_set_mode
"SETMODE": self.handle_set_mode,
"STOP": self.handle_stop
}
def handle_message(self, client_socket, raw_message):
......@@ -18,6 +19,15 @@ class MessageHandler:
handler = self.handlers.get(command, self.handle_unknown_message)
return handler(client_socket, data)
def handle_stop(self, client_socket, _):
"""Handles the STOP command."""
response = b"Stopping the robot"
if self.testing:
print(response.decode())
else:
client_socket.sendall(response)
return "cmd_vel", (0, 0)
def handle_ping(self, client_socket, _):
"""Responds with a PONG message."""
response = b"PONG"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment