Skip to content

Commit 3f6dd1d

Browse files
author
Kajetan Jonak
committed
Added settings page
1 parent cfeda5a commit 3f6dd1d

File tree

21 files changed

+310
-32
lines changed

21 files changed

+310
-32
lines changed

Controller/KeyboardController.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public override void StartController(Action<int[]> callback)
3232
x = new Thread(() => ControlLoop(callback));
3333
var directInput = new DirectInput();
3434
keyboard = new Keyboard(directInput);
35+
keyboard.Acquire();
3536
x.Start();
3637

3738
}
@@ -51,7 +52,9 @@ private void ControlLoop(Action<int[]> callback)
5152
LoopActive = true;
5253
DateTime last = DateTime.Now;
5354
int freq = controlSettings.ControllerInterval;
54-
keyboard.Acquire();
55+
56+
57+
5558
while (LoopActive)
5659
{
5760
if ((DateTime.Now - last).Milliseconds >= freq)

GUI_v2.Model/CameraStreamClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public bool IsRunning()
6565
{
6666
return LoopActive;
6767
}
68-
public void StartStream(NewFrameCallback callback, Notifyier connectionErrorCb, double fps = 45)
68+
public void StartStream(NewFrameCallback callback, Notifyier connectionErrorCb, double fps = 60)
6969
{
7070
connectionDownCb = connectionErrorCb;
7171
if (stream != null && LoopActive == false)

GUI_v2.Model/JetsonClient/Protocol.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public enum CONTROL_MSG : byte
3131
STOP_AUTONOMY =0x04,
3232
START_TELEMETRY = 0x05,
3333
START_DETECTOR = 0x06,
34-
STOP_DETECTOR = 0x07
34+
STOP_DETECTOR = 0x07,
35+
SET_MOTORS = 0x08,
36+
DISABLE_MOTORS = 0x09
3537
}
3638
public enum SETTINGS_MSG : byte
3739
{

GUI_v2.View/ControlView/ControlPage.xaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@
4848
</Grid.RowDefinitions>
4949
<StackPanel Grid.Row="0" Orientation="Horizontal" Width="Auto">
5050
<Label Content="Control:"/>
51-
<ComboBox x:Name="ControlBox" Width="120"
51+
<ComboBox x:Name="ControlBox" Width="120"
52+
5253
SelectedItem="Keyboard"
5354
ItemsSource="{Binding AvailableControllers}"
54-
HorizontalAlignment="Center" VerticalAlignment="Center">
55+
HorizontalAlignment="Center" VerticalAlignment="Center" SelectionChanged="ControlBox_SelectionChanged">
5556

5657
</ComboBox>
5758
<Button Width="80" Margin="5 0" Height="{Binding ActualHeight, ElementName=ControlBox}"
@@ -85,7 +86,13 @@
8586
Visibility="{Binding Armed, Converter={StaticResource VisibilityConverter}}"
8687
Orientation="Horizontal" Grid.Row="0" Background="{StaticResource ControlSettingsSurfaceBrush}">
8788
<Label Content="Mode: " Margin="0" Padding="0 7 0 0"/>
88-
<ComboBox Width="120" Margin="5" Name="ModeSelector" IsTextSearchEnabled="False">
89+
<ComboBox Width="120" Margin="5" Name="ModeSelector"
90+
KeyDown="ControlBox_KeyDown"
91+
KeyUp="ControlBox_KeyUp"
92+
IsManipulationEnabled="False"
93+
Focusable="False"
94+
95+
IsTextSearchEnabled="False">
8996
<i:Interaction.Triggers>
9097
<i:EventTrigger EventName="SelectionChanged">
9198
<i:InvokeCommandAction Command="{Binding ModeChangedCommand}" CommandParameter="{Binding SelectedValue, ElementName=ModeSelector}"/>

GUI_v2.View/ControlView/ControlPage.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ private void FullscreenWindow_Closing(object sender, System.ComponentModel.Cance
119119

120120
}
121121

122+
private void ControlBox_KeyDown(object sender, KeyEventArgs e)
123+
{
124+
e.Handled = true;
125+
}
126+
127+
private void ControlBox_KeyUp(object sender, KeyEventArgs e)
128+
{
129+
e.Handled = true;
130+
}
131+
132+
private void ControlBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
133+
{
122134

135+
}
123136
}
124137
}

GUI_v2.View/GUI_v2.View.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@
276276
<Compile Include="StatusView\Boat3DView.xaml.cs">
277277
<DependentUpon>Boat3DView.xaml</DependentUpon>
278278
</Compile>
279+
<Compile Include="StatusView\IMUSettings.xaml.cs">
280+
<DependentUpon>IMUSettings.xaml</DependentUpon>
281+
</Compile>
279282
<Compile Include="StatusView\MotorSlider.xaml.cs">
280283
<DependentUpon>MotorSlider.xaml</DependentUpon>
281284
</Compile>
@@ -445,6 +448,10 @@
445448
<Generator>MSBuild:Compile</Generator>
446449
<SubType>Designer</SubType>
447450
</Page>
451+
<Page Include="StatusView\IMUSettings.xaml">
452+
<SubType>Designer</SubType>
453+
<Generator>MSBuild:Compile</Generator>
454+
</Page>
448455
<Page Include="StatusView\MotorSlider.xaml">
449456
<SubType>Designer</SubType>
450457
<Generator>MSBuild:Compile</Generator>

GUI_v2.View/IMUView/IMUPageStyle.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<SolidColorBrush x:Key="PIDTextBrush" Color="{StaticResource OnSurfaceColor}" Opacity="0.7"/>
1212
<sys:Double x:Key="PIDHeaderFontSize">15</sys:Double>
1313
<Thickness x:Key="PIDBorderThickness">0</Thickness>
14-
14+
<sys:Double x:Key="HeaderFontSize">20</sys:Double>
15+
<sys:Double x:Key="FontSize">15</sys:Double>
1516

1617
<SolidColorBrush x:Key="PloTitleBrush" Color="{StaticResource SurfaceColor}"/>
1718
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{StaticResource PrimaryColor}" Opacity="{StaticResource OnBackgroundOpacity}"/>

GUI_v2.View/MenuBar/MenuBar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
Image="{StaticResource ControlImage}"
111111
-->
112112

113-
<local:MenuBarButton Text="Status" Command="{Binding ChangeViewCommand}" CommandParamater="Status"/>
113+
<local:MenuBarButton Text="Settings" Command="{Binding ChangeViewCommand}" CommandParamater="Status"/>
114114
<local:MenuBarButton Text="IMU" Command="{Binding ChangeViewCommand}" CommandParamater="IMU"/>
115115
<local:MenuBarButton Text="Control" Command="{Binding ChangeViewCommand}" CommandParamater="Control"/>
116116
<local:MenuBarButton Text="Autonomy" Command="{Binding ChangeViewCommand}" CommandParamater="Autonomy"/>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<UserControl x:Class="GUI_v2.View.StatusView.IMUSettings"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:GUI_v2.View.StatusView"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800">
9+
<UserControl.Resources>
10+
<ResourceDictionary>
11+
<ResourceDictionary.MergedDictionaries>
12+
<ResourceDictionary Source="StatusPageStyle.xaml"/>
13+
</ResourceDictionary.MergedDictionaries>
14+
<BooleanToVisibilityConverter x:Key="VisibilityConverter"/>
15+
</ResourceDictionary>
16+
</UserControl.Resources>
17+
<Grid>
18+
<Grid.RowDefinitions>
19+
<RowDefinition Height="Auto"/>
20+
<RowDefinition Height="Auto"/>
21+
<RowDefinition Height="Auto"/>
22+
</Grid.RowDefinitions>
23+
<Label Content="IMU settings" FontSize="{StaticResource HeaderFontSize}"/>
24+
<Grid Grid.Row="1" Background="{StaticResource OnBackgroundBrush}" Margin="5">
25+
<Grid.ColumnDefinitions>
26+
<ColumnDefinition Width="150"/>
27+
<ColumnDefinition Width="*"/>
28+
<ColumnDefinition Width="*"/>
29+
<ColumnDefinition Width="*"/>
30+
<ColumnDefinition Width="*"/>
31+
32+
</Grid.ColumnDefinitions>
33+
<Label Content="Level" FontWeight="Bold" FontSize="{StaticResource FontSize}"/>
34+
<Grid Grid.Column="1">
35+
<Grid.ColumnDefinitions>
36+
<ColumnDefinition Width="Auto"/>
37+
<ColumnDefinition Width="100"/>
38+
</Grid.ColumnDefinitions>
39+
<Label Content="Roll:" FontSize="{StaticResource FontSize}"/>
40+
<TextBox Grid.Column="1" Margin="20 5"/>
41+
</Grid>
42+
<Grid Grid.Column="2">
43+
<Grid.ColumnDefinitions>
44+
<ColumnDefinition Width="Auto"/>
45+
<ColumnDefinition Width="100"/>
46+
</Grid.ColumnDefinitions>
47+
<Label Content="Pitch:" FontSize="{StaticResource FontSize}"/>
48+
<TextBox Grid.Column="1" Margin="20 5"/>
49+
</Grid>
50+
51+
<Button Content="set" Grid.Column="3" Margin="20 5"/>
52+
<Button Content="set current" Grid.Column="4" Margin="20 5"/>
53+
</Grid>
54+
<Grid Grid.Row="2">
55+
<Grid>
56+
<Grid.ColumnDefinitions>
57+
<ColumnDefinition Width="150"/>
58+
<ColumnDefinition Width="*"/>
59+
<ColumnDefinition Width="*"/>
60+
<ColumnDefinition Width="*"/>
61+
</Grid.ColumnDefinitions>
62+
<Label Content="Magnetometer" FontSize="{StaticResource FontSize}" FontWeight="Bold"/>
63+
<RadioButton Grid.Column="1" Content="Enabled" IsChecked="True" FontSize="{StaticResource FontSize}"
64+
Foreground="{StaticResource ForegroundBrush}"
65+
VerticalAlignment="Center"
66+
HorizontalAlignment="Center"/>
67+
<RadioButton Grid.Column="2" Content="Disabled" FontSize="{StaticResource FontSize}"
68+
Foreground="{StaticResource ForegroundBrush}"
69+
VerticalAlignment="Center"
70+
HorizontalAlignment="Center"/>
71+
<Button Grid.Column="3" Content="set" Margin="25 5"/>
72+
</Grid>
73+
</Grid>
74+
</Grid>
75+
</UserControl>
76+
77+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace GUI_v2.View.StatusView
17+
{
18+
/// <summary>
19+
/// Interaction logic for IMUSettings.xaml
20+
/// </summary>
21+
public partial class IMUSettings : UserControl
22+
{
23+
public IMUSettings()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)