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

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

parent 7e9a77a8
No related branches found
No related tags found
1 merge request!2Manual control user interface
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen> <IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework> <ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile> <ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup> <SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
<DefaultDevice>pixel_5_-_api_34</DefaultDevice> <DefaultDevice>pixel_5_-_api_34</DefaultDevice>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
HorizontalOptions="Center" /> HorizontalOptions="Center" />
</HorizontalStackLayout> </HorizontalStackLayout>
<sides:SideBox HeaderTitle="Queue:" />
<sides:SideBox HeaderTitle="Status:" />
</VerticalStackLayout> </VerticalStackLayout>
<!-- Main Drawable Area with specific HeightRequest to ensure visibility --> <!-- Main Drawable Area with specific HeightRequest to ensure visibility -->
......
...@@ -86,6 +86,56 @@ ...@@ -86,6 +86,56 @@
CornerRadius="5" /> CornerRadius="5" />
</VerticalStackLayout> </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> </VerticalStackLayout>
</ScrollView> </ScrollView>
</VerticalStackLayout> </VerticalStackLayout>
......
...@@ -22,13 +22,11 @@ namespace RobobinApp.Views.Sides ...@@ -22,13 +22,11 @@ namespace RobobinApp.Views.Sides
{ {
InitializeComponent(); InitializeComponent();
App.WifiManager.OnMessageReceived += UpdateLatestMessage; App.WifiManager.OnMessageReceived += UpdateLatestMessage;
} }
private void UpdateLatestMessage(string message) private void UpdateLatestMessage(string message)
{ {
MainThread.BeginInvokeOnMainThread(() => MainThread.BeginInvokeOnMainThread(() =>
{ {
LatestMessageLabel.Text = message; LatestMessageLabel.Text = message;
...@@ -37,15 +35,11 @@ namespace RobobinApp.Views.Sides ...@@ -37,15 +35,11 @@ namespace RobobinApp.Views.Sides
private async void OnSendMessageClicked(object sender, EventArgs e) private async void OnSendMessageClicked(object sender, EventArgs e)
{ {
string messageToSend = TcpMessageEntry.Text; string messageToSend = TcpMessageEntry.Text;
if (!string.IsNullOrWhiteSpace(messageToSend)) if (!string.IsNullOrWhiteSpace(messageToSend))
{ {
await App.WifiManager.SendMessageAsync(messageToSend); await App.WifiManager.SendMessageAsync(messageToSend);
TcpMessageEntry.Text = string.Empty; TcpMessageEntry.Text = string.Empty;
} }
else else
...@@ -69,6 +63,41 @@ namespace RobobinApp.Views.Sides ...@@ -69,6 +63,41 @@ namespace RobobinApp.Views.Sides
await App.WifiManager.SendMessageAsync("SETMODE Follow"); 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) protected static void OnHeaderTitleChanged(BindableObject bindable, object oldValue, object newValue)
{ {
var control = (AdminBox)bindable; var control = (AdminBox)bindable;
...@@ -87,7 +116,5 @@ namespace RobobinApp.Views.Sides ...@@ -87,7 +116,5 @@ namespace RobobinApp.Views.Sides
App.WifiManager.OnMessageReceived -= UpdateLatestMessage; App.WifiManager.OnMessageReceived -= UpdateLatestMessage;
} }
} }
} }
} }
...@@ -35,7 +35,7 @@ class MessageHandler: ...@@ -35,7 +35,7 @@ class MessageHandler:
else: else:
client_socket.sendall(response) client_socket.sendall(response)
self.api_node.mode = message self.api_node.mode = message
return "mode", message return None
def handle_time_request(self, client_socket, _): def handle_time_request(self, client_socket, _):
"""Sends the current server time.""" """Sends the current server time."""
response = time.ctime().encode() 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