Skip to content

Commit

Permalink
Slider code cleanup
Browse files Browse the repository at this point in the history
Slider code cleanup
also bug fixed.
  • Loading branch information
tcfshcrw authored Dec 24, 2023
1 parent 6f69952 commit 3711aef
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 170 deletions.
126 changes: 0 additions & 126 deletions SimHubPlugin/SettingsControlDemo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -386,132 +386,6 @@
Width="160"
Foreground="White"/>

<Slider x:Name="PedalForceCurve000_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="0,155,0,0"
Grid.Row="9"
Grid.Column="1"
Width="30"
Height="120"
ValueChanged="Slider_Force000"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="5" RenderTransformOrigin="0.508,0.525"
Value="0" Grid.ColumnSpan="2"
Orientation="Vertical" Visibility="Hidden"
>
</Slider>

<Slider x:Name="PedalForceCurve020_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="80,155,0,0"
Grid.Row="9"
Grid.Column="1"
Width="30"
Height="120"
ValueChanged="Slider_Force020"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="5" RenderTransformOrigin="0.508,0.525"
Value="20"
Orientation="Vertical" Visibility="Hidden"
>
</Slider>

<Slider x:Name="PedalForceCurve040_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="160,155,0,0"
Grid.Row="9"
Grid.Column="1"
Width="30"
Height="120"
ValueChanged="Slider_Force040"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="5" RenderTransformOrigin="0.508,0.525"
Value="40"
Orientation="Vertical" Visibility="Hidden"
>
</Slider>

<Slider x:Name="PedalForceCurve060_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="240,155,0,0"
Grid.Row="9"
Grid.Column="1"
Width="30"
Height="120"
ValueChanged="Slider_Force060"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="5" RenderTransformOrigin="0.508,0.525"
Value="60"
Orientation="Vertical" Visibility="Hidden"
>
</Slider>

<Slider x:Name="PedalForceCurve080_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="320,155,0,0"
Grid.Row="9"
Grid.Column="1"
Width="30"
Height="120"
ValueChanged="Slider_Force080"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="5" RenderTransformOrigin="0.508,0.525"
Value="80"
Orientation="Vertical" Visibility="Hidden"
>
</Slider>


<Slider x:Name="PedalForceCurve100_Slider"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="400,155,0,0"
Grid.Row="9"
Grid.Column="1"
Width="30"
Height="120"
ValueChanged="Slider_Force100"
AutoToolTipPlacement="TopLeft"
AutoToolTipPrecision="0"
Minimum="0"
Maximum="100"
TickPlacement="BottomRight"
TickFrequency="5" RenderTransformOrigin="0.508,0.525"
Value="80" Orientation="Vertical" Visibility="Hidden"
>
</Slider>








<!-- PID sliders -->

Expand Down
51 changes: 7 additions & 44 deletions SimHubPlugin/SettingsControlDemo.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,6 @@ private void updateTheGuiFromConfig()

PedalDampening_Slider.Value = dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.dampingPress;

PedalForceCurve000_Slider.Value = dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p000;
PedalForceCurve020_Slider.Value = dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p020;
PedalForceCurve040_Slider.Value = dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p040;
PedalForceCurve060_Slider.Value = dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p060;
PedalForceCurve080_Slider.Value = dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p080;
PedalForceCurve100_Slider.Value = dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p100;


PID_tuning_P_gain_slider.Value = (double)dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.PID_p_gain;
PID_tuning_I_gain_slider.Value = (double)dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.PID_i_gain;
PID_tuning_D_gain_slider.Value = (double)dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.PID_d_gain;
Expand All @@ -468,17 +460,17 @@ private void updateTheGuiFromConfig()
Simulate_ABS_check.IsChecked = false;
}
//set control point position
Canvas.SetTop(rect0, -1 * (PedalForceCurve000_Slider.Value - canvas.Height + rect0.Height / 2));
Canvas.SetTop(rect0, -1 * (dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p000 - canvas.Height + rect0.Height / 2));
Canvas.SetLeft(rect0, 0*canvas.Width/5-rect0.Width/2);
Canvas.SetTop(rect1, -1 * (PedalForceCurve020_Slider.Value - canvas.Height + rect1.Height / 2));
Canvas.SetTop(rect1, -1 * (dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p020 - canvas.Height + rect1.Height / 2));
Canvas.SetLeft(rect1, 1 * canvas.Width / 5 - rect1.Width / 2);
Canvas.SetTop(rect2, -1 * (PedalForceCurve040_Slider.Value - canvas.Height + rect2.Height / 2));
Canvas.SetTop(rect2, -1 * (dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p040 - canvas.Height + rect2.Height / 2));
Canvas.SetLeft(rect2, 2 * canvas.Width / 5 - rect2.Width / 2);
Canvas.SetTop(rect3, -1 * (PedalForceCurve060_Slider.Value - canvas.Height + rect3.Height / 2));
Canvas.SetTop(rect3, -1 * (dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p060 - canvas.Height + rect3.Height / 2));
Canvas.SetLeft(rect3, 3 * canvas.Width / 5 - rect3.Width / 2);
Canvas.SetTop(rect4, -1 * (PedalForceCurve080_Slider.Value - canvas.Height + rect4.Height / 2));
Canvas.SetTop(rect4, -1 * (dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p080 - canvas.Height + rect4.Height / 2));
Canvas.SetLeft(rect4, 4 * canvas.Width / 5 - rect4.Width / 2);
Canvas.SetTop(rect5, -1 * (PedalForceCurve100_Slider.Value - canvas.Height + rect5.Height / 2));
Canvas.SetTop(rect5, -1 * (dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p100 - canvas.Height + rect5.Height / 2));
Canvas.SetLeft(rect5, 5 * canvas.Width / 5 - rect5.Width / 2);

//// Select serial port accordingly
Expand Down Expand Up @@ -710,36 +702,7 @@ public void Slider_Dampening(object sender, RoutedPropertyChangedEventArgs<doubl



public void Slider_Force000(object sender, RoutedPropertyChangedEventArgs<double> e)
{
dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p000 = Convert.ToByte(e.NewValue);
Update_BrakeForceCurve();
}
public void Slider_Force020(object sender, RoutedPropertyChangedEventArgs<double> e)
{
dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p020 = Convert.ToByte(e.NewValue);
Update_BrakeForceCurve();
}
public void Slider_Force040(object sender, RoutedPropertyChangedEventArgs<double> e)
{
dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p040 = Convert.ToByte(e.NewValue);
Update_BrakeForceCurve();
}
public void Slider_Force060(object sender, RoutedPropertyChangedEventArgs<double> e)
{
dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p060 = Convert.ToByte(e.NewValue);
Update_BrakeForceCurve();
}
public void Slider_Force080(object sender, RoutedPropertyChangedEventArgs<double> e)
{
dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p080 = Convert.ToByte(e.NewValue);
Update_BrakeForceCurve();
}
public void Slider_Force100(object sender, RoutedPropertyChangedEventArgs<double> e)
{
dap_config_st[indexOfSelectedPedal_u].payloadPedalConfig_.relativeForce_p100 = Convert.ToByte(e.NewValue);
Update_BrakeForceCurve();
}




Expand Down
Binary file modified SimHubPlugin/bin/DiyActivePedal.dll
Binary file not shown.
Binary file modified SimHubPlugin/bin/DiyActivePedal.g.resources
Binary file not shown.
Binary file modified SimHubPlugin/bin/DiyActivePedal.pdb
Binary file not shown.

0 comments on commit 3711aef

Please sign in to comment.