From 6d0820f4954619dc4397855b5b9e0d212b66426b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 19 Jan 2019 17:38:05 -0600 Subject: [PATCH] Add the PlatformFlags_FSR config flag. --- sdk/SMX.h | 6 ++++-- smx-config/DiagnosticsWidgets.cs | 2 +- smx-config/MainWindow.xaml.cs | 8 ++++---- smx-config/SMX.cs | 9 ++++++++- smx-config/Widgets.cs | 14 +++++++------- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/sdk/SMX.h b/sdk/SMX.h index d5d6437..d5c06c1 100644 --- a/sdk/SMX.h +++ b/sdk/SMX.h @@ -141,6 +141,9 @@ enum SMXConfigFlags { // is ignored. If unset, panels will be lit solid using stepColor. // masterVersion >= 4. Previous versions always use stepColor. PlatformFlags_AutoLightingUsePressedAnimations = 1 << 0, + + // If set, panels are using FSRs, otherwise load cells. + PlatformFlags_FSR = 1 << 1, }; // The configuration for a connected controller. This can be retrieved with SMX_GetConfig @@ -281,8 +284,7 @@ struct SMXSensorTestModeData int16_t sensorLevel[9][4]; bool bBadSensorInput[9][4]; - // The DIP switch settings on each panel. This is used for diagnostics - // displays. + // The DIP switch settings on each panel. This is used for diagnostics displays. int iDIPSwitchPerPanel[9]; }; diff --git a/smx-config/DiagnosticsWidgets.cs b/smx-config/DiagnosticsWidgets.cs index c8716c8..e108f04 100644 --- a/smx-config/DiagnosticsWidgets.cs +++ b/smx-config/DiagnosticsWidgets.cs @@ -298,7 +298,7 @@ namespace smx_config value = 0; // Scale differently depending on if this is an FSR panel or a load cell panel. - bool isFSR = controllerData.config.masterVersion >= 4 && controllerData.test_data.bFSRPerPanel[PanelIndex*4+sensor]; + bool isFSR = controllerData.config.masterVersion >= 4 && (controllerData.config.configFlags & SMX.SMXConfigFlags.PlatformFlags_FSR) != 0; float maxValue = isFSR? 1023:500; LevelBars[sensor].Value = value / maxValue; LevelBarText[sensor].Content = value; diff --git a/smx-config/MainWindow.xaml.cs b/smx-config/MainWindow.xaml.cs index ffb6ac4..2ef51c9 100644 --- a/smx-config/MainWindow.xaml.cs +++ b/smx-config/MainWindow.xaml.cs @@ -49,7 +49,7 @@ namespace smx_config // If AutoLightingUsePressedAnimations isn't set, the panel is using step // coloring instead of pressed animations. All firmwares support this. // Don't confirm exiting for this mode. - if((config.configFlags & SMX.SMXConfigFlags.SMXConfigFlags_AutoLightingUsePressedAnimations) == 0) + if((config.configFlags & SMX.SMXConfigFlags.AutoLightingUsePressedAnimations) == 0) continue; shouldConfirmExit = true; @@ -139,9 +139,9 @@ namespace smx_config // If we're in panel colors mode, clear the AutoLightingUsePressedAnimations flag. // Otherwise, set it. if(pressedPanelColors) - config.configFlags &= ~SMX.SMXConfigFlags.SMXConfigFlags_AutoLightingUsePressedAnimations; + config.configFlags &= ~SMX.SMXConfigFlags.AutoLightingUsePressedAnimations; else - config.configFlags |= SMX.SMXConfigFlags.SMXConfigFlags_AutoLightingUsePressedAnimations; + config.configFlags |= SMX.SMXConfigFlags.AutoLightingUsePressedAnimations; SMX.SMX.SetConfig(activePad.Item1, config); } @@ -166,7 +166,7 @@ namespace smx_config // If SMXConfigFlags_AutoLightingUsePressedAnimations is set, show the GIF UI. // If it's not set, show the color slider UI. SMX.SMXConfigFlags flags = config.configFlags; - bool usePressedAnimations = (flags & SMX.SMXConfigFlags.SMXConfigFlags_AutoLightingUsePressedAnimations) != 0; + bool usePressedAnimations = (flags & SMX.SMXConfigFlags.AutoLightingUsePressedAnimations) != 0; ColorPickerGroup.Visibility = usePressedAnimations? Visibility.Collapsed:Visibility.Visible; GIFGroup.Visibility = usePressedAnimations? Visibility.Visible:Visibility.Collapsed; diff --git a/smx-config/SMX.cs b/smx-config/SMX.cs index 639890c..8eafe8c 100644 --- a/smx-config/SMX.cs +++ b/smx-config/SMX.cs @@ -23,7 +23,8 @@ namespace SMX // Bits for SMXConfig::flags. public enum SMXConfigFlags { - SMXConfigFlags_AutoLightingUsePressedAnimations = 1 << 0, + AutoLightingUsePressedAnimations = 1 << 0, + PlatformFlags_FSR = 1 << 1, }; [StructLayout(LayoutKind.Sequential, Pack=1)] @@ -85,6 +86,12 @@ namespace SMX } } + // Return true if the platform is using FSRs, or false for load cells. + public bool fsr() + { + return masterVersion >= 4 && (configFlags & SMXConfigFlags.PlatformFlags_FSR) != 0; + } + // Thresholds when in FSR mode. Note that these are 16-bit thresholds, compared // to the 8-bit load cell thresholds. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] diff --git a/smx-config/Widgets.cs b/smx-config/Widgets.cs index 2c6b73a..6b24bf3 100644 --- a/smx-config/Widgets.cs +++ b/smx-config/Widgets.cs @@ -141,7 +141,7 @@ namespace smx_config private void SetValueToConfig(ref SMX.SMXConfig config) { - if(config.masterVersion < 4) + if(!config.fsr()) { byte lower = (byte) slider.LowerValue; byte upper = (byte) slider.UpperValue; @@ -187,7 +187,7 @@ namespace smx_config private void GetValueFromConfig(SMX.SMXConfig config, out int lower, out int upper) { - if(config.masterVersion < 4) + if(!config.fsr()) { switch(Type) { @@ -251,15 +251,15 @@ namespace smx_config UpdatingUI = true; // Set the range for the slider. - if(config.masterVersion < 4) + if(config.fsr()) { - // 8-bit load cell thresholds - slider.Minimum = 20; - slider.Maximum = 200; - } else { // 16-bit FSR thresholds slider.Minimum = 5; slider.Maximum = 1023; + } else { + // 8-bit load cell thresholds + slider.Minimum = 20; + slider.Maximum = 200; } int lower, upper;