Add an option to enable or disable lighting on panels with no sensors.

master
Glenn Maynard 6 years ago
parent f35f596cee
commit 1b01f53796
  1. 4
      sdk/Windows/SMXPanelAnimation.cpp
  2. 16
      smx-config/MainWindow.xaml
  3. 29
      smx-config/SMX.cs
  4. 46
      smx-config/Widgets.cs

@ -187,6 +187,10 @@ struct AnimationStateForPad
// The portion of lights data for this panel:
char *out = &result[panel*iBytesPerPanel];
// Skip this panel if it's not in autoLightPanelMask.
if(!(config.autoLightPanelMask & (1 << panel)))
continue;
// Add the released animation, then overlay the pressed animation if we're pressed.
OverlayLights(out, animations[SMX_LightsType_Released][panel].GetAnimationFrame());
bool bPressed = bool(iPadState & (1 << panel));

@ -879,8 +879,22 @@ Input will be disabled from deselected panels.</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<controls:PanelSelector Focusable="false" />
</StackPanel>
<Separator Margin="0,10,0,10" />
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,10" VerticalAlignment="Top" TextAlignment="Center"
xml:space="preserve" FontSize="16">Options</TextBlock>
<controls:LightAllPanelsCheckbox VerticalAlignment="Center"
x:Name="LightAllPanelsCheckbox"
DockPanel.Dock="Right" Content="Light all panels"
HorizontalAlignment="Center"
IsChecked="{Binding Path=LightAllPanels, Mode=TwoWay, RelativeSource={RelativeSource Self}}"
/>
<TextBlock xml:space="preserve" HorizontalAlignment="Center" Margin="0,0,0,0" TextAlignment="Center">Show light animations on all panels
instead of only panels with sensors.</TextBlock>
<Separator Margin="0,10,0,10" />
<TextBlock HorizontalAlignment="Center"
xml:space="preserve" FontSize="16">Import/export settings</TextBlock>
<TextBlock xml:space="preserve" HorizontalAlignment="Center" Margin="0,5,0,0" TextAlignment="Center"

@ -221,6 +221,35 @@ namespace SMX
return result;
}
// autoLightPanelMask controls which lights the master controller will light. Only the
// first 9 bits (0x1ff) are meaningful for our 9 panels. As a special case, we use 0xFFFF
// to indicate that "light all panels" was checked. The controller doesn't care about this
// since it only looks at the first 9 bits.
public bool getLightAllPanelsMode() { return autoLightPanelMask == 0xFFFF; }
public void setLightAllPanelsMode(bool enable)
{
if(enable)
autoLightPanelMask = 0xFFFF;
else
refreshAutoLightPanelMask(false);
}
// If we're not in light all panels mode, set autoLightPanelMask to the currently
// enabled panels. This should be called if enabledSensors is changed.
public void refreshAutoLightPanelMask(bool onlyIfEnabled=true)
{
if(onlyIfEnabled && getLightAllPanelsMode())
return;
// Set autoLightPanelMask to just the enabled panels.
autoLightPanelMask = 0;
bool[] enabledPanels = GetEnabledPanels();
for(int i = 0; i < 9; ++i)
if(enabledPanels[i])
autoLightPanelMask |= (UInt16) (1 << i);
}
};
public struct SMXSensorTestModeData

@ -909,6 +909,10 @@ namespace smx_config
config.enabledSensors[index] |= (byte) mask;
}
// If we're not in "light all panels" mode, sync up autoLightPanelMask
// with the new enabledSensors.
config.refreshAutoLightPanelMask();
SMX.SMX.SetConfig(pad, config);
}
}
@ -985,4 +989,46 @@ namespace smx_config
this.Source = ImageFrames[Frame];
}
};
public class LightAllPanelsCheckbox: CheckBox
{
public static readonly DependencyProperty LightAllPanelsProperty = DependencyProperty.Register("LightAllPanels",
typeof(bool), typeof(LightAllPanelsCheckbox), new FrameworkPropertyMetadata(false));
public bool LightAllPanels {
get { return (bool) GetValue(LightAllPanelsProperty); }
set { SetValue(LightAllPanelsProperty, value); }
}
OnConfigChange onConfigChange;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
onConfigChange = new OnConfigChange(this, delegate (LoadFromConfigDelegateArgs args) {
LoadUIFromConfig(ActivePad.GetFirstActivePadConfig(args));
});
}
private void LoadUIFromConfig(SMX.SMXConfig config)
{
LightAllPanels = config.getLightAllPanelsMode();
}
protected override void OnClick()
{
//SMX.SMXConfig firstConfig = ActivePad.GetFirstActivePadConfig();
foreach(Tuple<int,SMX.SMXConfig> activePad in ActivePad.ActivePads())
{
int pad = activePad.Item1;
SMX.SMXConfig config = activePad.Item2;
config.setLightAllPanelsMode(!LightAllPanels);
SMX.SMX.SetConfig(pad, config);
}
CurrentSMXDevice.singleton.FireConfigurationChanged(this);
// Refresh the UI.
//LoadUIFromConfig(firstConfig);
}
}
}

Loading…
Cancel
Save