Skip to content

Commit

Permalink
feat: brought updates in from feature/refactorInputFB branch that was…
Browse files Browse the repository at this point in the history
… stale and out of date
  • Loading branch information
jkdevito committed May 9, 2022
1 parent e290caa commit e58d77d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 32 deletions.
86 changes: 64 additions & 22 deletions epi-display-samsung-mdc/SamsungMdc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,31 @@ public class SamsungMdcDisplayController : TwoWayDisplayBase, IBasicVolumeWithFe
public IntFeedback CurrentLedTemperatureFahrenheitFeedback;

public List<BoolFeedback> InputFeedback;
public IntFeedback InputNumberFeedback;


private RoutingInputPort _currentInputPort;

private int _currentLedTemperatureCelsius;
private int _currentLedTemperatureFahrenheit;
private byte[] _incomingBuffer = {};

private int _inputNumber;
public IntFeedback InputNumberFeedback;

public int CurrentInputNumber
{
get
{
return _currentInputNumber;
}
private set
{
_currentInputNumber = value;
InputNumberFeedback.FireUpdate();
UpdateBooleanFeedback();
}
}
private int _currentInputNumber;

private bool _isCoolingDown;
private bool _isMuted;
private bool _isPoweringOnIgnorePowerFb;
Expand Down Expand Up @@ -89,10 +107,17 @@ public SamsungMdcDisplayController(string key, string name, SamsungMDCDisplayPro
public byte Id { get; private set; }
public IntFeedback StatusFeedback { get; set; }

public int InputNumber
public int SetInput
{
get { return _inputNumber; }
set { ExecuteSwitch(InputPorts.ElementAt(value).Selector); }
get { return CurrentInputNumber; }
set
{
if (value > 0 && value < InputPorts.Count)
{
ExecuteSwitch(InputPorts.ElementAt(value - 1).Selector);
CurrentInputNumber = value;
}
}
}

private bool ScaleVolume { get; set; }
Expand Down Expand Up @@ -665,7 +690,18 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
StatusFeedback.LinkInputSig(trilist.UShortInput[joinMap.Status.JoinNumber]);

// Power Off
// input analog feedback
InputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]);
// led temperature analog feedback
CurrentLedTemperatureCelsiusFeedback.LinkInputSig(
trilist.UShortInput[joinMap.LedTemperatureCelsius.JoinNumber]);

CurrentLedTemperatureCelsiusFeedback.LinkInputSig(
trilist.UShortInput[joinMap.LedTemperatureCelsius.JoinNumber]);

CurrentInputFeedback.OutputChange +=
(sender, args) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", args.StringValue);
// Power Off
trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, PowerOff);
PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]);

Expand All @@ -680,8 +716,9 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
foreach (var input in InputPorts)
{
var i = input;
var inputIndex = count;
trilist.SetSigTrueAction((ushort) (joinMap.InputSelectOffset.JoinNumber + count),
() => ExecuteSwitch(InputPorts[i.Key].Selector));
() => SetInput = inputIndex + 1);

var friendlyName = _config.FriendlyNames.FirstOrDefault(n => n.InputKey == i.Key);

Expand All @@ -708,7 +745,7 @@ public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, E
}
else if (a > 0 && a < InputPorts.Count)
{
InputNumber = a + 1;
SetInput = a + 1;
}
else if (a == 102)
{
Expand Down Expand Up @@ -879,13 +916,13 @@ private void InitInputPortsAndFeedbacks()
{
var j = i;

InputFeedback.Add(new BoolFeedback(() => _inputNumber == j + 1));
InputFeedback.Add(new BoolFeedback(() => CurrentInputNumber == j + 1));
}

InputNumberFeedback = new IntFeedback(() =>
{
Debug.Console(2, this, "Change Input number {0}", _inputNumber);
return _inputNumber;
Debug.Console(2, this, "Change Input number {0}", CurrentInputNumber);
return CurrentInputNumber;
});
}

Expand Down Expand Up @@ -1169,6 +1206,10 @@ private void OnDeviceInfoChange()
private void UpdatePowerFb(byte powerByte)
{
var newVal = powerByte == 1;
if (!newVal)
{
CurrentInputNumber = 0;
}
if (newVal == _powerIsOn)
{
return;
Expand Down Expand Up @@ -1228,31 +1269,32 @@ private void UpdateInputFb(byte b)
switch (key)
{
case "hdmiIn1":
_inputNumber = 1;
CurrentInputNumber = 1;
break;
case "hdmiIn2":
_inputNumber = 2;
CurrentInputNumber = 2;
break;
case "hdmiIn3":
_inputNumber = 3;
CurrentInputNumber = 3;
break;
case "hdmiIn4":
_inputNumber = 4;
CurrentInputNumber = 4;
break;
case "displayPortIn1":
_inputNumber = 5;
CurrentInputNumber = 5;
break;
case "displayPortIn2":
_inputNumber = 6;
CurrentInputNumber = 6;
break;
case "dviIn":
_inputNumber = 7;
CurrentInputNumber = 7;
break;
}
InputNumberFeedback.FireUpdate();
}

InputNumberFeedback.FireUpdate();
UpdateBooleanFeedback();


}

/// <summary>
Expand Down Expand Up @@ -1345,8 +1387,8 @@ public override void PowerOff()
SendBytes(new byte[] {Header, PowerControlCmd, 0x00, 0x01, PowerControlOff, 0x00});
_isCoolingDown = true;
_powerIsOn = false;
_inputNumber = 0;
UpdateBooleanFeedback();
CurrentInputNumber = 0;

InputNumberFeedback.FireUpdate();
PowerIsOnFeedback.FireUpdate();
IsCoolingDownFeedback.FireUpdate();
Expand Down
1 change: 0 additions & 1 deletion epi-display-samsung-mdc/SamsungMdcConfigObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using System;

namespace PepperDash.Plugin.Display.SamsungMdc
{
Expand Down
18 changes: 9 additions & 9 deletions epi-display-samsung-mdc/epi-display-samsung-mdc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,26 @@
<ItemGroup>
<Reference Include="Crestron.SimplSharpPro.DeviceSupport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll</HintPath>
<HintPath>..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll</HintPath>
</Reference>
<Reference Include="Essentials Devices Common, Version=1.6.7.29775, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Essentials Devices Common, Version=1.9.7.31145, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\PepperDashEssentials\lib\net35\Essentials Devices Common.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="PepperDashEssentials, Version=1.6.7.29782, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="PepperDashEssentials, Version=1.9.7.31153, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\PepperDashEssentials\lib\net35\PepperDashEssentials.dll</HintPath>
</Reference>
<Reference Include="PepperDash_Core, Version=1.0.43.36276, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="PepperDash_Core, Version=1.1.0.33266, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll</HintPath>
</Reference>
<Reference Include="PepperDash_Essentials_Core, Version=1.6.7.29770, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="PepperDash_Essentials_Core, Version=1.9.7.31139, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_Core.dll</HintPath>
</Reference>
<Reference Include="PepperDash_Essentials_DM, Version=1.6.7.29778, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="PepperDash_Essentials_DM, Version=1.9.7.31149, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_DM.dll</HintPath>
</Reference>
Expand All @@ -83,7 +83,7 @@
</Reference>
<Reference Include="SimplSharpNewtonsoft, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll</HintPath>
<HintPath>..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll</HintPath>
</Reference>
<Reference Include="SimplSharpPro, Version=1.5.3.17, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -92,11 +92,11 @@
</Reference>
<Reference Include="SimplSharpReflectionInterface, Version=1.0.5583.25238, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll</HintPath>
<HintPath>..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll</HintPath>
</Reference>
<Reference Include="SimplSharpTimerEventInterface, Version=1.0.6197.20052, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll</HintPath>
<HintPath>..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down

0 comments on commit e58d77d

Please sign in to comment.