8-bit FSR thresholds.

master
Glenn Maynard 6 years ago
parent b1f675c56c
commit 9facc93548
  1. 10
      sdk/SMX.h
  2. 8
      smx-config/ConfigPresets.cs
  3. 4
      smx-config/DiagnosticsWidgets.cs
  4. 4
      smx-config/Helpers.cs
  5. 10
      smx-config/SMX.cs
  6. 6
      smx-config/Widgets.cs

@ -160,14 +160,14 @@ struct packed_sensor_settings_t {
uint8_t loadCellHighThreshold; uint8_t loadCellHighThreshold;
// FSR thresholds: // FSR thresholds:
uint16_t fsrLowThreshold[4]; uint8_t fsrLowThreshold[4];
uint16_t fsrHighThreshold[4]; uint8_t fsrHighThreshold[4];
// This must be left unchanged. // This must be left unchanged.
uint16_t reserved; uint16_t reserved;
}; };
static_assert(sizeof(packed_sensor_settings_t) == 20, "Incorrect packed_sensor_settings_t size"); static_assert(sizeof(packed_sensor_settings_t) == 12, "Incorrect packed_sensor_settings_t size");
// The configuration for a connected controller. This can be retrieved with SMX_GetConfig // The configuration for a connected controller. This can be retrieved with SMX_GetConfig
// and modified with SMX_SetConfig. // and modified with SMX_SetConfig.
@ -258,11 +258,11 @@ struct SMXConfig
// Pad the struct to 250 bytes. This keeps this struct size from changing // Pad the struct to 250 bytes. This keeps this struct size from changing
// as we add fields, so the ABI doesn't change. Applications should leave // as we add fields, so the ABI doesn't change. Applications should leave
// any data in here unchanged when calling SMX_SetConfig. // any data in here unchanged when calling SMX_SetConfig.
uint8_t padding[13]; uint8_t padding[85];
}; };
#pragma pack(pop) #pragma pack(pop)
static_assert(offsetof(SMXConfig, padding) == 237, "Incorrect padding alignment"); static_assert(offsetof(SMXConfig, padding) == 165, "Incorrect padding alignment");
static_assert(sizeof(SMXConfig) == 250, "Expected 250 bytes"); static_assert(sizeof(SMXConfig) == 250, "Expected 250 bytes");
// The values (except for Off) correspond with the protocol and must not be changed. // The values (except for Off) correspond with the protocol and must not be changed.

@ -63,7 +63,7 @@ namespace smx_config
static private void SetPreset(ref SMX.SMXConfig config, static private void SetPreset(ref SMX.SMXConfig config,
byte loadCellLow, byte loadCellHigh, byte loadCellLowCenter, byte loadCellHighCenter, byte loadCellLow, byte loadCellHigh, byte loadCellLowCenter, byte loadCellHighCenter,
UInt16 fsrLow, UInt16 fsrHigh, UInt16 fsrLowCenter, UInt16 fsrHighCenter) byte fsrLow, byte fsrHigh, byte fsrLowCenter, byte fsrHighCenter)
{ {
for(int panel = 0; panel < 9; ++panel) for(int panel = 0; panel < 9; ++panel)
{ {
@ -96,21 +96,21 @@ namespace smx_config
{ {
SetPreset(ref config, SetPreset(ref config,
20, 25, 20, 30, 20, 25, 20, 30,
275, 300, 275, 300); 100, 112, 100, 112);
} }
static private void SetNormalPreset(ref SMX.SMXConfig config) static private void SetNormalPreset(ref SMX.SMXConfig config)
{ {
SetPreset(ref config, SetPreset(ref config,
33, 42, 35, 60, 33, 42, 35, 60,
650, 700, 845, 895); 162, 175, 212, 225);
} }
static private void SetLowPreset(ref SMX.SMXConfig config) static private void SetLowPreset(ref SMX.SMXConfig config)
{ {
SetPreset(ref config, SetPreset(ref config,
70, 80, 100, 120, 70, 80, 100, 120,
800, 875, 845, 895); 200, 219, 212, 225);
} }
// The simplified configuration scheme sets thresholds for up, center, cardinal directions // The simplified configuration scheme sets thresholds for up, center, cardinal directions

@ -325,7 +325,9 @@ namespace smx_config
// Scale differently depending on if this is an FSR panel or a load cell panel. // Scale differently depending on if this is an FSR panel or a load cell panel.
bool isFSR = controllerData.config.masterVersion >= 4 && (controllerData.config.configFlags & SMX.SMXConfigFlags.PlatformFlags_FSR) != 0; bool isFSR = controllerData.config.masterVersion >= 4 && (controllerData.config.configFlags & SMX.SMXConfigFlags.PlatformFlags_FSR) != 0;
float maxValue = isFSR? 1023:500; if(isFSR)
value >>= 2;
float maxValue = isFSR? 250:500;
LevelBars[sensor].Value = value / maxValue; LevelBars[sensor].Value = value / maxValue;
LevelBarText[sensor].Content = value; LevelBarText[sensor].Content = value;
LevelBars[sensor].Error = false; LevelBars[sensor].Error = false;

@ -592,8 +592,8 @@ namespace smx_config
{ {
for(int sensor = 0; sensor < 4; ++sensor) for(int sensor = 0; sensor < 4; ++sensor)
{ {
config.panelSettings[panel].fsrLowThreshold[sensor] = (UInt16) newPanelLowThresholds.Get(panel, (int) config.panelSettings[panel].fsrLowThreshold[sensor]); config.panelSettings[panel].fsrLowThreshold[sensor] = (byte) newPanelLowThresholds.Get(panel, (int) config.panelSettings[panel].fsrLowThreshold[sensor]);
config.panelSettings[panel].fsrHighThreshold[sensor] = (UInt16) newPanelHighThresholds.Get(panel, (int) config.panelSettings[panel].fsrHighThreshold[sensor]); config.panelSettings[panel].fsrHighThreshold[sensor] = (byte) newPanelHighThresholds.Get(panel, (int) config.panelSettings[panel].fsrHighThreshold[sensor]);
} }
} }
} }

@ -34,10 +34,10 @@ namespace SMX
// FSR thresholds (16-bit): // FSR thresholds (16-bit):
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public UInt16[] fsrLowThreshold; public Byte[] fsrLowThreshold;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public UInt16[] fsrHighThreshold; public Byte[] fsrHighThreshold;
// This must be left unchanged. // This must be left unchanged.
public UInt16 reserved; public UInt16 reserved;
@ -88,7 +88,7 @@ namespace SMX
public Byte preDetailsDelayMilliseconds; public Byte preDetailsDelayMilliseconds;
// Pad this struct to exactly 250 bytes. // Pad this struct to exactly 250 bytes.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 85)]
public Byte[] padding; public Byte[] padding;
// It would be simpler to set flags to [MarshalAs(UnmanagedType.U8)], but // It would be simpler to set flags to [MarshalAs(UnmanagedType.U8)], but
@ -213,8 +213,8 @@ namespace SMX
result.platformStripColor = new Byte[3]; result.platformStripColor = new Byte[3];
for(int panel = 0; panel < 9; ++panel) for(int panel = 0; panel < 9; ++panel)
{ {
result.panelSettings[panel].fsrLowThreshold = new UInt16[4]; result.panelSettings[panel].fsrLowThreshold = new Byte[4];
result.panelSettings[panel].fsrHighThreshold = new UInt16[4]; result.panelSettings[panel].fsrHighThreshold = new Byte[4];
} }
return result; return result;
} }

@ -166,8 +166,8 @@ namespace smx_config
config.panelSettings[panelIdx].loadCellLowThreshold = lower; config.panelSettings[panelIdx].loadCellLowThreshold = lower;
config.panelSettings[panelIdx].loadCellHighThreshold = upper; config.panelSettings[panelIdx].loadCellHighThreshold = upper;
} else { } else {
UInt16 lower = (UInt16) slider.LowerValue; byte lower = (byte) slider.LowerValue;
UInt16 upper = (UInt16) slider.UpperValue; byte upper = (byte) slider.UpperValue;
for(int sensor = 0; sensor < 4; ++sensor) for(int sensor = 0; sensor < 4; ++sensor)
{ {
config.panelSettings[panelIdx].fsrLowThreshold[sensor] = lower; config.panelSettings[panelIdx].fsrLowThreshold[sensor] = lower;
@ -222,7 +222,7 @@ namespace smx_config
{ {
// 16-bit FSR thresholds. // 16-bit FSR thresholds.
slider.Minimum = 5; slider.Minimum = 5;
slider.Maximum = 1023; slider.Maximum = 250;
slider.MinimumDistance = 5; slider.MinimumDistance = 5;
} else { } else {
// 8-bit load cell thresholds // 8-bit load cell thresholds

Loading…
Cancel
Save