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

Manual controls now work from the users side (need to lock multiple users).

parent ade3da7e
No related branches found
No related tags found
1 merge request!2Manual control user interface
......@@ -4,7 +4,7 @@
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
<DefaultDevice>pixel_5_-_api_34</DefaultDevice>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
......
......@@ -37,8 +37,6 @@
HorizontalOptions="Center" />
</HorizontalStackLayout>
<sides:SideBox HeaderTitle="Queue:" />
<sides:SideBox HeaderTitle="Status:" />
</VerticalStackLayout>
<!-- Main Drawable Area with specific HeightRequest to ensure visibility -->
......
......@@ -86,6 +86,56 @@
CornerRadius="5" />
</VerticalStackLayout>
<!-- WASD Button Layout -->
<VerticalStackLayout Spacing="5" Padding="5">
<Label Text="Control Pad:"
FontAttributes="Bold"
HorizontalOptions="Center" />
<Grid RowDefinitions="Auto, Auto, Auto"
ColumnDefinitions="Auto, Auto, Auto"
HorizontalOptions="Center">
<!-- W Button -->
<Button Text="W"
Clicked="OnWClicked"
Grid.Row="0"
Grid.Column="1"
WidthRequest="50"
HeightRequest="50"
CornerRadius="5"
BackgroundColor="LightGrey"/>
<!-- A Button -->
<Button Text="A"
Clicked="OnAClicked"
Grid.Row="1"
Grid.Column="0"
WidthRequest="50"
HeightRequest="50"
CornerRadius="5"
BackgroundColor="LightGrey"/>
<!-- S Button -->
<Button Text="S"
Clicked="OnSClicked"
Grid.Row="1"
Grid.Column="1"
WidthRequest="50"
HeightRequest="50"
CornerRadius="5"
BackgroundColor="LightGrey"/>
<!-- D Button -->
<Button Text="D"
Clicked="OnDClicked"
Grid.Row="1"
Grid.Column="2"
WidthRequest="50"
HeightRequest="50"
CornerRadius="5"
BackgroundColor="LightGrey"/>
</Grid>
</VerticalStackLayout>
</VerticalStackLayout>
</ScrollView>
</VerticalStackLayout>
......
......@@ -22,13 +22,11 @@ namespace RobobinApp.Views.Sides
{
InitializeComponent();
App.WifiManager.OnMessageReceived += UpdateLatestMessage;
}
private void UpdateLatestMessage(string message)
{
MainThread.BeginInvokeOnMainThread(() =>
{
LatestMessageLabel.Text = message;
......@@ -37,15 +35,11 @@ namespace RobobinApp.Views.Sides
private async void OnSendMessageClicked(object sender, EventArgs e)
{
string messageToSend = TcpMessageEntry.Text;
if (!string.IsNullOrWhiteSpace(messageToSend))
{
await App.WifiManager.SendMessageAsync(messageToSend);
TcpMessageEntry.Text = string.Empty;
}
else
......@@ -69,6 +63,41 @@ namespace RobobinApp.Views.Sides
await App.WifiManager.SendMessageAsync("SETMODE Follow");
}
// WASD Button Handlers
private async void OnWClicked(object sender, EventArgs e)
{
await SendManualControlMessage("W");
}
private async void OnAClicked(object sender, EventArgs e)
{
await SendManualControlMessage("A");
}
private async void OnSClicked(object sender, EventArgs e)
{
await SendManualControlMessage("S");
}
private async void OnDClicked(object sender, EventArgs e)
{
await SendManualControlMessage("D");
}
// Helper Method for Manual Control Messages
private async Task SendManualControlMessage(string direction)
{
if (App.WifiManager.Mode == "Manual")
{
string message = $"MANUALCTRL {direction}";
await App.WifiManager.SendMessageAsync(message);
}
else
{
await Application.Current.MainPage.DisplayAlert("Error", "App is not in Manual mode.", "OK");
}
}
protected static void OnHeaderTitleChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (AdminBox)bindable;
......@@ -87,7 +116,5 @@ namespace RobobinApp.Views.Sides
App.WifiManager.OnMessageReceived -= UpdateLatestMessage;
}
}
}
}
......@@ -35,7 +35,7 @@ class MessageHandler:
else:
client_socket.sendall(response)
self.api_node.mode = message
return "mode", message
return None
def handle_time_request(self, client_socket, _):
"""Sends the current server time."""
response = time.ctime().encode()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment