Handle FSR thresholds in the threshold sliders.

master
Glenn Maynard 6 years ago
parent 1c980f24e0
commit 6b58194235
  1. 6
      smx-config/ConfigPresets.cs
  2. 4
      smx-config/MainWindow.xaml
  3. 6
      smx-config/SMX.cs
  4. 62
      smx-config/Widgets.cs

@ -123,6 +123,12 @@ namespace smx_config
// UL = DL = DR = UR (corners) // UL = DL = DR = UR (corners)
config.panelThreshold0Low = config.panelThreshold6Low = config.panelThreshold8Low = config.panelThreshold2Low; config.panelThreshold0Low = config.panelThreshold6Low = config.panelThreshold8Low = config.panelThreshold2Low;
config.panelThreshold0High = config.panelThreshold6High = config.panelThreshold8High = config.panelThreshold2High; config.panelThreshold0High = config.panelThreshold6High = config.panelThreshold8High = config.panelThreshold2High;
// Do the same for FSR thresholds.
config.individualPanelFSRLow[3] = config.individualPanelFSRLow[5] = config.individualPanelFSRLow[7];
config.individualPanelFSRHigh[3] = config.individualPanelFSRHigh[5] = config.individualPanelFSRHigh[7];
config.individualPanelFSRLow[0] = config.individualPanelFSRLow[6] = config.individualPanelFSRLow[8] = config.individualPanelFSRLow[2];
config.individualPanelFSRHigh[0] = config.individualPanelFSRHigh[6] = config.individualPanelFSRHigh[8] = config.individualPanelFSRHigh[2];
} }
// Return true if the panel thresholds are already synced, so SyncUnifiedThresholds would // Return true if the panel thresholds are already synced, so SyncUnifiedThresholds would

@ -146,14 +146,14 @@ Use if the platform is too sensitive.</clr:String>
/> />
<controls:DoubleSlider x:Name="Slider" <controls:DoubleSlider x:Name="Slider"
Margin="32,5,0,0" Margin="32,5,0,0"
Minimum="20" Maximum="200" MinimumDistance="10" MinimumDistance="10"
LowerValue="20" UpperValue="35" LowerValue="20" UpperValue="35"
VerticalAlignment="Top" VerticalAlignment="Top"
Width="240" Width="240"
Focusable="False" Focusable="False"
Style="{DynamicResource DoubleSlider}" Style="{DynamicResource DoubleSlider}"
/> />
<Label Margin="11,0,0,0" x:Name="UpperValue" Content="0" Width="30" HorizontalContentAlignment="Center" <Label Margin="11,0,0,0" x:Name="UpperValue" Content="0" Width="40" HorizontalContentAlignment="Center"
HorizontalAlignment="Left" VerticalAlignment="Top" HorizontalAlignment="Left" VerticalAlignment="Top"
/> />
</StackPanel> </StackPanel>

@ -88,13 +88,13 @@ namespace SMX
// Thresholds when in FSR mode. Note that these are 16-bit thresholds, compared // Thresholds when in FSR mode. Note that these are 16-bit thresholds, compared
// to the 8-bit load cell thresholds. // to the 8-bit load cell thresholds.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
UInt16[] individualPanelFSRLow; public UInt16[] individualPanelFSRLow;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
UInt16[] individualPanelFSRHigh; public UInt16[] individualPanelFSRHigh;
// The default color to set the platform LED strip to. // The default color to set the platform LED strip to.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
Byte[] platformStripColor; public Byte[] platformStripColor;
// Pad this struct to exactly 250 bytes. // Pad this struct to exactly 250 bytes.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 124)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 124)]

@ -140,6 +140,8 @@ namespace smx_config
} }
private void SetValueToConfig(ref SMX.SMXConfig config) private void SetValueToConfig(ref SMX.SMXConfig config)
{
if(config.masterVersion < 4)
{ {
byte lower = (byte) slider.LowerValue; byte lower = (byte) slider.LowerValue;
byte upper = (byte) slider.UpperValue; byte upper = (byte) slider.UpperValue;
@ -158,13 +160,34 @@ namespace smx_config
case "cardinal": config.panelThreshold7Low = lower; config.panelThreshold7High = upper; break; case "cardinal": config.panelThreshold7Low = lower; config.panelThreshold7High = upper; break;
case "corner": config.panelThreshold2Low = lower; config.panelThreshold2High = upper; break; case "corner": config.panelThreshold2Low = lower; config.panelThreshold2High = upper; break;
} }
} else {
UInt16 lower = (UInt16) slider.LowerValue;
UInt16 upper = (UInt16) slider.UpperValue;
switch(Type)
{
case "up-left": config.individualPanelFSRLow[0] = lower; config.individualPanelFSRHigh[0] = upper; break;
case "up": config.individualPanelFSRLow[1] = lower; config.individualPanelFSRHigh[1] = upper; break;
case "up-right": config.individualPanelFSRLow[2] = lower; config.individualPanelFSRHigh[2] = upper; break;
case "left": config.individualPanelFSRLow[3] = lower; config.individualPanelFSRHigh[3] = upper; break;
case "center": config.individualPanelFSRLow[4] = lower; config.individualPanelFSRHigh[4] = upper; break;
case "right": config.individualPanelFSRLow[5] = lower; config.individualPanelFSRHigh[5] = upper; break;
case "down-left": config.individualPanelFSRLow[6] = lower; config.individualPanelFSRHigh[6] = upper; break;
case "down": config.individualPanelFSRLow[7] = lower; config.individualPanelFSRHigh[7] = upper; break;
case "down-right": config.individualPanelFSRLow[8] = lower; config.individualPanelFSRHigh[8] = upper; break;
case "cardinal": config.individualPanelFSRLow[7] = lower; config.individualPanelFSRHigh[7] = upper; break;
case "corner": config.individualPanelFSRLow[2] = lower; config.individualPanelFSRHigh[2] = upper; break;
}
}
// If we're not in advanced mode, sync the cardinal value to each of the panel values. // If we're not in advanced mode, sync the cardinal value to each of the panel values.
if(!AdvancedModeEnabled) if(!AdvancedModeEnabled)
ConfigPresets.SyncUnifiedThresholds(ref config); ConfigPresets.SyncUnifiedThresholds(ref config);
} }
private void GetValueFromConfig(SMX.SMXConfig config, out byte lower, out byte upper) private void GetValueFromConfig(SMX.SMXConfig config, out int lower, out int upper)
{
if(config.masterVersion < 4)
{ {
switch(Type) switch(Type)
{ {
@ -183,6 +206,25 @@ namespace smx_config
lower = upper = 0; lower = upper = 0;
return; return;
} }
} else {
switch(Type)
{
case "up-left": lower = config.individualPanelFSRLow[0]; upper = config.individualPanelFSRHigh[0]; return;
case "up": lower = config.individualPanelFSRLow[1]; upper = config.individualPanelFSRHigh[1]; return;
case "up-right": lower = config.individualPanelFSRLow[2]; upper = config.individualPanelFSRHigh[2]; return;
case "left": lower = config.individualPanelFSRLow[3]; upper = config.individualPanelFSRHigh[3]; return;
case "center": lower = config.individualPanelFSRLow[4]; upper = config.individualPanelFSRHigh[4]; return;
case "right": lower = config.individualPanelFSRLow[5]; upper = config.individualPanelFSRHigh[5]; return;
case "down-left": lower = config.individualPanelFSRLow[6]; upper = config.individualPanelFSRHigh[6]; return;
case "down": lower = config.individualPanelFSRLow[7]; upper = config.individualPanelFSRHigh[7]; return;
case "down-right": lower = config.individualPanelFSRLow[8]; upper = config.individualPanelFSRHigh[8]; return;
case "cardinal": lower = config.individualPanelFSRLow[7]; upper = config.individualPanelFSRHigh[7]; return;
case "corner": lower = config.individualPanelFSRLow[2]; upper = config.individualPanelFSRHigh[2]; return;
default:
lower = upper = 0;
return;
}
}
} }
private void SaveToConfig() private void SaveToConfig()
@ -208,10 +250,24 @@ namespace smx_config
// Make sure SaveToConfig doesn't treat these as the user changing values. // Make sure SaveToConfig doesn't treat these as the user changing values.
UpdatingUI = true; UpdatingUI = true;
byte lower, upper; // Set the range for the slider.
if(config.masterVersion < 4)
{
// 8-bit load cell thresholds
slider.Minimum = 20;
slider.Maximum = 200;
} else {
// 16-bit FSR thresholds
slider.Minimum = 5;
slider.Maximum = 1023;
}
int lower, upper;
GetValueFromConfig(config, out lower, out upper); GetValueFromConfig(config, out lower, out upper);
if(lower == 0xFF) // Firmware versions before 4 allowed 0xFF to be used to disable a threshold.
// This isn't used in newer firmwares.
if(config.masterVersion < 4 && lower == 0xFF)
{ {
LowerLabel.Content = "Off"; LowerLabel.Content = "Off";
UpperLabel.Content = ""; UpperLabel.Content = "";

Loading…
Cancel
Save